Actualizacion
Realizando de la siguiente manera:
from lxml import etree
import shlex, subprocess
import base64 # encriptar archivo
from xml.etree import ElementTree as ET
import io
PATH_FIRMA_ABSOLUTA = os.path.join(os.path.dirname(os.path.dirname(__file__)),'static/SRI/betty_elena_romo_vega.p12')
PATH_FIRMAR_JAVA = os.path.join(os.path.dirname(os.path.dirname(__file__)),'static/SRI/firmaXadesBes.jar')
file_pk12 = PATH_FIRMA_ABSOLUTA
password = 'Rgberv1792'
JAR_PATH = PATH_FIRMAR_JAVA
JAVA_CMD = 'java'
ds_document = False
PATH_XML_ABSOLUTO = os.path.join(os.path.dirname(os.path.dirname(__file__)),path_xml_generado)
tree = etree.parse(str(PATH_XML_ABSOLUTO))
xml_str = etree.tostring(tree, encoding='utf8', method='xml')
command = [
JAVA_CMD,
'-jar',
JAR_PATH,
xml_str,
base64.b64encode(file_pk12),
base64.b64encode(password)
]
print command
p = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
#shell=True
)
res = p.communicate()
# guardar xml firmado
documento_firmado = res[0]
print "DOCUMENTO JAVA FIRMADO"
print documento_firmado
# guardar xml firmado
string_xml = documento_firmado
tree = ET.XML(string_xml)
Funciona locamente en modo deployment con apache y mod_wsgi, pero al subir al servidor Amazon que esta en modo deploy con apache y mod_wsgi me genera el error:
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/html/facturacionelectronica/ventas/views.py" in GrabarVenta
362. stderr=subprocess.STDOUT,
File "/usr/lib64/python2.7/subprocess.py" in __init__
711. errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py" in _execute_child
1327. raise child_exception
Exception Type: OSError at /ventas/grabar_venta
Exception Value: [Errno 2] No such file or directory
Gracias cualquier sugerencia..!!