Skip to content

Commit

Permalink
Merge branch 'master3' into master-fix
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	pytrustnfe/nfe/danfe.py
#	setup.py
  • Loading branch information
danimaribeiro committed Feb 8, 2018
2 parents 4899184 + 55031fe commit 57997f9
Show file tree
Hide file tree
Showing 71 changed files with 808 additions and 255 deletions.
32 changes: 32 additions & 0 deletions .appveyor.yml
@@ -0,0 +1,32 @@
version: 1.3.{build}

environment:
matrix:
- python: 35
- python: 35-x64
- python: 36
- python: 36-x64

install:
- SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH%
- python -m pip.__main__ install -U pip wheel setuptools
- pip install -r requirements.txt

build: off
build_script:
# configure version
- ps: >-
If ($env:APPVEYOR_REPO_TAG -Eq "true" ) {
$version = "$env:APPVEYOR_REPO_TAG_NAME"
} Else {
$version = "$env:APPVEYOR_BUILD_VERSION.dev0"
}
$version | Set-Content version.txt
- python setup.py build bdist_wheel
- ps: Get-ChildItem dist\*.whl | % { pip install $_.FullName }

test: off
test_script:
- pip list
- py.test -v tests
- ps: Get-ChildItem dist\*.whl | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -11,4 +11,4 @@ dist/
*egg*/
docs/_build
.vscode/tags
.cache/
.cache
10 changes: 6 additions & 4 deletions .travis.yml
@@ -1,13 +1,15 @@
dist: precise
language: python
python:
- '2.7'
- "3.4"
- "3.5"
- "3.6"
virtual_env:
system_site_packages: true
install:
- pip install --upgrade pip
- pip install -r requirements.txt
script: coverage run --source=pytrustnfe setup.py nosetests
script:
pytest --cov=pytrustnfe
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq python-dev libffi-dev libxml2-dev libxslt1-dev libssl-dev
Expand All @@ -19,5 +21,5 @@ deploy:
password:
secure: wV+DH+WVji4qyCRXxugOsu8/u9MgUN9YggIBozh2Si1z6OlONZVr/oCaJDW8UD+Qg0EF87RbHuEmmlpAZVERAZv5uGsxjSO/NyvAsr99sOlTy9TSLi6TLp4aPnOCgjBTFDWkwkNyDTGYGNfendS7KO2jaHUsr/eDZcpTz42lOfDgpmccz822wwI6Uu1hNC61qlskPkKVzFhHT61/XAgmjHvw1wAMWVmv9/E6J8VAlZoI9/v3K0RTRisB/+0+sSvY86crYyuW/zIEhQJnMu/gfFWDSxNdY+0S3VyFgERn5S7IYlpBPUUlukX5aPXy+OQD2ygeu7w9f6aOSaJZsoyhe4pPXDjA9XNyfiazuZrz51fzhricMvdsMPAcukK/sJzGICAFgOutAjy+nGBkNqA2genKL8gMtJGUrPW5Yq5MGMC7FEgEQi5SgEj+01FgSY5mHlR3qo9bEgXWcxhNL/uZ3C1ElnGNLbyn5hjWzCnMEe70JwfWNQxGgtNm73vrrsZJ7M5wGjrEKVAvTERQegRQm2ObX7YsPmTY+tF15Hxs8GiZ0T/MzpxGe6yAkIutKI0CxpoUMXBnrmcMbn74GT8KWQjS724AA3K5ePO5ogLECxIq3huyB9USeeXmYBhUtcLpKSSH7gA/8vT/tvXK0+/YNTKzIIrOjuZ9IOVrwq2PyUY=
on:
branch: master
branch: master3
distributions: "bdist_wheel"
15 changes: 7 additions & 8 deletions README.md
@@ -1,25 +1,25 @@
# PyTrustNFe
Biblioteca Python que tem por objetivo enviar NFe, NFCe e NFSe no Brasil

[![Coverage Status](https://coveralls.io/repos/danimaribeiro/PyTrustNFe/badge.svg?branch=master)](https://coveralls.io/r/danimaribeiro/PyTrustNFe?branch=master)
[![Code Health](https://landscape.io/github/danimaribeiro/PyTrustNFe/master/landscape.svg?style=flat)](https://landscape.io/github/danimaribeiro/PyTrustNFe/master)
[![Build Status](https://travis-ci.org/danimaribeiro/PyTrustNFe.svg?branch=master)](https://travis-ci.org/danimaribeiro/PyTrustNFe)
[![PyPI version](https://badge.fury.io/py/PyTrustNFe.svg)](https://badge.fury.io/py/PyTrustNFe)
[![Coverage Status](https://coveralls.io/repos/danimaribeiro/PyTrustNFe/badge.svg?branch=master3)](https://coveralls.io/r/danimaribeiro/PyTrustNFe?branch=master3)
[![Code Health](https://landscape.io/github/danimaribeiro/PyTrustNFe/master3/landscape.svg?style=flat)](https://landscape.io/github/danimaribeiro/PyTrustNFe/master3)
[![Build Status](https://travis-ci.org/danimaribeiro/PyTrustNFe.svg?branch=master3)](https://travis-ci.org/danimaribeiro/PyTrustNFe)
[![PyPI version](https://badge.fury.io/py/PyTrustNFe3.svg)](https://badge.fury.io/py/PyTrustNFe3)

Dependências:
* PyXmlSec
* lxml
* signxml
* suds
* suds_requests
* suds-jurko
* suds-jurko-requests
* reportlab
* Jinja2

NFSe - Cidades atendidas
--------------
* [Ariss](cidades/ariss.md) - 4 cidades atendidas
* [Simpliss](cidades/simpliss.md) - 18 cidade atendidas

* [GINFES](cidades/ginfes.md) - 79 cidades atendidas

Roadmap
--------------
Expand All @@ -31,7 +31,6 @@ Compatibilidade [python 2 e 3](https://github.com/danimaribeiro/PyTrustNFe/pull/

Implementar novos provedores de NFSe
* [Betha](cidades/betha.md) - 81 cidades atendidas WIP
* [GINFES](cidades/ginfes.md) - 79 cidades atendidas
* [WebISS](cidades/webiss.md) - 51 cidades atendidas
* [ISSIntel](cidades/issintel.md) - 32 cidades atendidas
* [ISSNET](cidades/issnet.md) - 32 cidades atendidas
Expand Down
4 changes: 2 additions & 2 deletions pytrustnfe/Servidores.py
Expand Up @@ -37,8 +37,8 @@
NFCE_AMBIENTE_PRODUCAO = 1
NFCE_AMBIENTE_HOMOLOGACAO = 2

NFE_MODELO = u'55'
NFCE_MODELO = u'65'
NFE_MODELO = '55'
NFCE_MODELO = '65'

SIGLA_ESTADO = {
'12': 'AC',
Expand Down
8 changes: 4 additions & 4 deletions pytrustnfe/__init__.py
Expand Up @@ -12,10 +12,10 @@ def __init__(self, url):

def _headers(self, action):
return {
u'Content-type':
u'text/xml; charset=utf-8;',
u'Accept': u'application/soap+xml; charset=utf-8',
u'SOAPAction': action
'Content-type':
'text/xml; charset=utf-8;',
'Accept': 'application/soap+xml; charset=utf-8',
'SOAPAction': action
}

def post_soap(self, xml_soap, action):
Expand Down
13 changes: 6 additions & 7 deletions pytrustnfe/certificado.py
Expand Up @@ -2,8 +2,7 @@
# © 2016 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


from uuid import uuid4
import tempfile
from OpenSSL import crypto


Expand All @@ -13,8 +12,8 @@ def __init__(self, pfx, password):
self.password = password

def save_pfx(self):
pfx_temp = '/tmp/' + uuid4().hex
arq_temp = open(pfx_temp, 'w')
pfx_temp = tempfile.mkstemp()[1]
arq_temp = open(pfx_temp, 'wb')
arq_temp.write(self.pfx)
arq_temp.close()
return pfx_temp
Expand All @@ -28,12 +27,12 @@ def extract_cert_and_key_from_pfx(pfx, password):
# PEM formatted certificate
cert = crypto.dump_certificate(crypto.FILETYPE_PEM,
pfx.get_certificate())
return cert, key
return cert.decode(), key.decode()


def save_cert_key(cert, key):
cert_temp = '/tmp/' + uuid4().hex
key_temp = '/tmp/' + uuid4().hex
cert_temp = tempfile.mkstemp()[1]
key_temp = tempfile.mkstemp()[1]

arq_temp = open(cert_temp, 'w')
arq_temp.write(cert)
Expand Down
16 changes: 11 additions & 5 deletions pytrustnfe/client.py
Expand Up @@ -42,14 +42,20 @@ def __init__(self, url, cert_path, key_path):
self.cert_path = cert_path
self.key_path = key_path

def _headers(self, action):
def _headers(self, action, send_raw):
if send_raw:
return {
'Content-type': 'text/xml; charset=utf-8; action="http://www.portalfiscal.inf.br/nfe/wsdl/%s"' % action,
'Accept': 'application/soap+xml; charset=utf-8',
}

return {
u'Content-type': u'application/soap+xml; charset=utf-8; action="http://www.portalfiscal.inf.br/nfe/wsdl/%s"' % action,
u'Accept': u'application/soap+xml; charset=utf-8',
'Content-type': 'application/soap+xml; charset=utf-8; action="http://www.portalfiscal.inf.br/nfe/wsdl/%s"' % action,
'Accept': 'application/soap+xml; charset=utf-8',
}

def post_soap(self, xml_soap, cabecalho):
header = self._headers(cabecalho.soap_action)
def post_soap(self, xml_soap, cabecalho, send_raw):
header = self._headers(cabecalho.soap_action, send_raw)
urllib3.disable_warnings(category=InsecureRequestWarning)
res = requests.post(self.url, data=xml_soap,
cert=(self.cert_path, self.key_path),
Expand Down

0 comments on commit 57997f9

Please sign in to comment.