Browse Source

subprocess para check_call

pull/7/head
Leonardo Tada 10 years ago
parent
commit
af1129c8f7
  1. 12
      pynfe/processamento/assinatura.py

12
pynfe/processamento/assinatura.py

@ -55,7 +55,7 @@ class AssinaturaA1(Assinatura):
with open('testes.xml', 'w') as arquivo: with open('testes.xml', 'w') as arquivo:
arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False))) arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False)))
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'testes.xml'])
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'testes.xml'])
xml = etree.parse('funfa.xml').getroot() xml = etree.parse('funfa.xml').getroot()
if retorna_string: if retorna_string:
@ -109,7 +109,7 @@ class AssinaturaA1(Assinatura):
texto = texto.replace('ns1:', '').replace(':ns1', '') texto = texto.replace('ns1:', '').replace(':ns1', '')
arquivo.write(texto) arquivo.write(texto)
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado,
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado,
'--pwd', self.senha, '--crypto', 'openssl', '--output', '--pwd', self.senha, '--crypto', 'openssl', '--output',
'nfse.xml', '--id-attr:Id', tag, 'nfse.xml']) 'nfse.xml', '--id-attr:Id', tag, 'nfse.xml'])
@ -154,7 +154,7 @@ class AssinaturaA1(Assinatura):
texto = remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False)) texto = remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False))
arquivo.write(texto) arquivo.write(texto)
# assina lote # assina lote
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado,
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado,
'--pwd', self.senha, '--crypto', 'openssl', '--output', '--pwd', self.senha, '--crypto', 'openssl', '--output',
'nfse.xml', '--id-attr:Id', tag, 'nfse.xml']) 'nfse.xml', '--id-attr:Id', tag, 'nfse.xml'])
@ -217,7 +217,7 @@ class AssinaturaA1(Assinatura):
with open('nfse.xml', 'w') as arquivo: with open('nfse.xml', 'w') as arquivo:
arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n',''))) arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n','')))
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
if retorna_string: if retorna_string:
return open('funfa.xml', 'r').read() return open('funfa.xml', 'r').read()
@ -254,7 +254,7 @@ class AssinaturaA1(Assinatura):
with open('nfse.xml', 'w') as arquivo: with open('nfse.xml', 'w') as arquivo:
arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n',''))) arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n','')))
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
xml = etree.parse('funfa.xml').getroot() xml = etree.parse('funfa.xml').getroot()
if retorna_string: if retorna_string:
@ -305,7 +305,7 @@ class AssinaturaA1(Assinatura):
with open('nfse.xml', 'w') as arquivo: with open('nfse.xml', 'w') as arquivo:
arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n',''))) arquivo.write(remover_acentos(etree.tostring(xml, encoding="unicode", pretty_print=False).replace('\n','')))
subprocess.call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
subprocess.check_call(['xmlsec1', '--sign', '--pkcs12', self.certificado, '--pwd', self.senha, '--crypto', 'openssl', '--output', 'funfa.xml', '--id-attr:Id', tag, 'nfse.xml'])
xml = etree.parse('funfa.xml').getroot() xml = etree.parse('funfa.xml').getroot()
if retorna_string: if retorna_string:

Loading…
Cancel
Save