Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pyar/pyafipws into main
Browse files Browse the repository at this point in the history
  • Loading branch information
reingart committed Jan 7, 2024
2 parents d4562d5 + aa7fd36 commit 90ef00f
Show file tree
Hide file tree
Showing 11 changed files with 446 additions and 167 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# This workflow will build pyafipws package and deploy on pypi.
# For more information see: https://github.com/py2exe/py2exe/blob/master/.github/workflows/CI.yml

name: Deploy to PyPi

on:
workflow_run:
workflows: ["python-package", "windows-installer"]
types:
- completed
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, 3.11]

steps:
- uses: actions/checkout@v2
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build PyAfipWs Package
run: |
mkdir ./dist
pip install wheel
python setup.py bdist_wheel sdist
- name: Publish Package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/


test:
name: "Test Deployed PyAfipWs Package"
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.9, 3.11]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install PyAfipWs from PyPi
run: |
pip install -i https://test.pypi.org/simple/ PyAfipWs
- name: Download certificate and private key
run: |
wget "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -O reingart2019.zip
unzip reingart2019.zip
- name: Test WSAA servers
run: |
python -m pyafipws.wsaa
- name: Test WSFEV1
run: |
python -m pyafipws.wsfev1 --dummy
37 changes: 37 additions & 0 deletions .github/workflows/windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ jobs:
- name: Build executables
run: |
python setup_win.py py2exe
- name: Download Visual Studio Redistributable (32bits)
if: matrix.targetplatform == 'x86'
run: |
curl -L https://aka.ms/vs/17/release/vc_redist.x86.exe -o vcredist.exe
- name: Download Visual Studio 22 Redistributable (64bits)
if: matrix.targetplatform != 'x86'
run: |
curl -L https://aka.ms/vs/17/release/vc_redist.x64.exe -o vcredist.exe
- name: Copy Visual Studio Redistributable
run: |
copy vcredist.exe .\dist\
- name: Install NSIS for building Installers
run: |
curl -L https://sourceforge.net/projects/nsis/files/latest/download -o NSISInstaller.exe
Start-Process -FilePath "NSISInstaller.exe" -ArgumentList "/S" -Wait
del "NSISInstaller.exe"
- name: Build PyAfipWs Installer
run: |
makensis.exe base.nsi
- name: Remove uneeded libs (TK)
run: |
Remove-Item .\dist\lib\tcl -recurse
Expand All @@ -65,6 +84,12 @@ jobs:
name: dist-${{ matrix.targetplatform }}
path: |
dist/
- name: Deploy PyAfipWs Installer
uses: actions/upload-artifact@v3
with:
name: PyAfipWs-Installer-${{ matrix.targetplatform }}
path: |
**/PyAfipWs-*-full.exe
test:
name: "Full End-2-End test"
Expand Down Expand Up @@ -136,6 +161,16 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- name: Download 64Bit Installer
uses: actions/download-artifact@v3
with:
name: PyAfipWs-Installer-x64
path: PyAfipWs-Installer-x64.exe
- name: Download 32bit Installer
uses: actions/download-artifact@v3
with:
name: PyAfipWs-Installer-x86
path: PyAfipWs-Installer-x86.exe
- name: Download distribution binaries
uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -163,5 +198,7 @@ jobs:
prerelease: ${{ (github.ref != 'main') }}
title: "Dev Build ${{ env.release_version }} ${{ env.git_branch }} @ ${{ env.git_short_hash }}"
files: |
PyAfipWs-Installer-x64.exe
PyAfipWs-Installer-x86.exe
dist-32.zip
dist-64.zip
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@ test:
.venv/bin/py.test tests

clean:
rm -Rf .venv
rm -Rf .venv

.PHONY: install test
# Works with bash and linux
# This command first copies all the configuration settings from the conf folder
# to the main folder and next it downloads test key and digital certificate that
# that can be used for testing and lastly the python module is used to decompress
# the files
get-auth:
cp conf/*.ini .
curl -o reingart.zip https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip
python -m zipfile -e reingart.zip .

access-ticket:
python -m pyafipws.wsaa

sample-invoice:
python -m pyafipws.wsfev1 --prueba

# Use "git clean -n" to see the files to be cleaned
# Use only when only the config files are untracked
# Finally use "git clean -f" to remove untracked files(in this case test files)
# This command will list all the files that are untracked. You can clean them verbosely
# using git clean -i. Else, if you are sure, you can se -f to remove all untracked files
# without a prompt
clean-test:
git clean -n
git clean -i

.PHONY: install test get-auth sample-invoice sign-cert
27 changes: 14 additions & 13 deletions iibb.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
__license__ = "LGPL-3.0-or-later"
__version__ = "3.01b"

import md5, os, sys, tempfile, traceback
import os, sys, tempfile, traceback
try:
from hashlib import md5
except ImportError:
from md5 import md5
from pysimplesoap.simplexml import SimpleXMLElement

from pyafipws.utils import WebClient
Expand Down Expand Up @@ -122,30 +126,27 @@ def ConsultarContribuyentes(self, fecha_desde, fecha_hasta, cuit_contribuyente):
self.xml.contribuyentes.contribuyente.cuitContribuyente = cuit_contribuyente

xml = self.xml.as_xml()
self.CodigoHash = md5.md5(xml).hexdigest()
self.CodigoHash = md5(xml).hexdigest()
nombre = "DFEServicioConsulta_%s.xml" % self.CodigoHash

# guardo el xml en el archivo a enviar y luego lo re-abro:
archivo = open(os.path.join(tempfile.gettempdir(), nombre), "w")
archivo.write(xml)
archivo.close()
archivo = open(os.path.join(tempfile.gettempdir(), nombre), "r")
with open(os.path.join(tempfile.gettempdir(), nombre), "wb") as archivo:
archivo.write(xml)

if not self.testing:
response = self.client(
user=self.Usuario, password=self.Password, file=archivo
)
with open(os.path.join(tempfile.gettempdir(), nombre), "r") as archivo:
response = self.client(
user=self.Usuario, password=self.Password, file=archivo)
else:
response = open(self.testing).read()
with open(self.testing) as archivo:
response = archivo.read()
self.XmlResponse = response
self.xml = SimpleXMLElement(response)
if "tipoError" in self.xml:
self.TipoError = str(self.xml.tipoError)
self.CodigoError = str(self.xml.codigoError)
self.MensajeError = (
str(self.xml.mensajeError)
.decode("latin1")
.encode("ascii", "replace")
)
if "numeroComprobante" in self.xml:
self.NumeroComprobante = str(self.xml.numeroComprobante)
Expand Down Expand Up @@ -327,4 +328,4 @@ def main():
)

if __name__ == "__main__":
main()
main()
6 changes: 3 additions & 3 deletions nsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@
StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022" vcredist_ok vcredist_install
vcredist_install:
File "vcredist_x86.exe"
File "vcredist.exe"
DetailPrint "Installing Microsoft Visual C++ 2008 Redistributable"
ExecWait '"$INSTDIR\vcredist_x86.exe" /q' $0
Delete $INSTDIR\vcredist_x86.exe
ExecWait '"$INSTDIR\vcredist.exe" /q' $0
Delete $INSTDIR\vcredist.exe
vcredist_ok:
"""
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
httplib2==0.9.2; python_version <= '2.7'
httplib2==0.20.4; python_version > '3'
pysimplesoap==1.08.14; python_version <= '2.7'
git+https://github.com/pysimplesoap/pysimplesoap.git@py311#pysimplesoap; python_version > '3'
pysimplesoap==1.8.22; python_version > '3'
cryptography==3.3.2; python_version <= '2.7'
cryptography==3.4.7; python_version > '3'
cryptography==41.0.1; python_version > '3'
fpdf>=1.7.2
dbf>=0.88.019
Pillow>=2.0.0
Pillow<=9.5.0; platform_machine!='x86_64'
Pillow>=2.0.0; platform_machine=='x86_64'
tabulate==0.8.5
certifi>=2020.4.5.1
qrcode==6.1
Expand Down
39 changes: 22 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,39 @@
opts = {}
data_files = [("pyafipws/plantillas", glob.glob("plantillas/*"))]


long_desc = (
"Interfases, herramientas y aplicativos para Servicios Web"
"AFIP (Factura Electrónica, Granos, Aduana, etc.), "
"ANMAT (Trazabilidad de Medicamentos), "
"RENPRE (Trazabilidad de Precursores Químicos), "
"ARBA (Remito Electrónico)"
)

# convert the README and format in restructured text (only when registering)
if "sdist" in sys.argv and os.path.exists("README.md") and sys.platform == "linux2":
try:
cmd = ["pandoc", "--from=markdown", "--to=rst", "README.md"]
long_desc = subprocess.check_output(cmd).decode("utf8")
open("README.rst", "w").write(long_desc.encode("utf8"))
except Exception as e:
warnings.warn("Exception when converting the README format: %s" % e)

# from docs https://packaging.python.org/en/latest/guides/making-a-pypi-friendly-readme/
parent_dir = os.getcwd()
long_desc = open(os.path.join(parent_dir, "README.md")).read()

setup(
name="PyAfipWs",
version=__version__,
description=desc,
long_description=long_desc,
long_description_content_type="text/markdown",
author="Mariano Reingart",
author_email="[email protected]",
url="https://github.com/reingart/pyafipws",
license="LGPL-3.0-or-later",
install_requires=[
"httplib2==0.9.2;python_version <= '2.7'",
"httplib2>=0.20.4;python_version > '3'",
"pysimplesoap==1.08.14;python_version <= '2.7'",
"pysimplesoap==1.8.22;python_version > '3'",
"cryptography==3.3.2;python_version <= '2.7'",
"cryptography>=3.4.7;python_version > '3'",
"fpdf>=1.7.2",
"dbf>=0.88.019",
"Pillow>=2.0.0",
"tabulate>=0.8.5",
"certifi>=2020.4.5.1",
"qrcode>=6.1",
"future>=0.18.2",
],
extras_require={
"opt": ["pywin32==304;sys_platform == 'win32' and python_version > '3'"]
},
options=opts,
data_files=data_files,
classifiers=[
Expand Down
Loading

0 comments on commit 90ef00f

Please sign in to comment.