Skip to content
Snippets Groups Projects
Unverified Commit 03dd52bc authored by Jonathan Weth's avatar Jonathan Weth Committed by GitHub
Browse files

Merge pull request #3 from hansegucker/feature/tox

Setup tox
parents 8fcabcb3 16270fe8
No related branches found
No related tags found
No related merge requests found
name: Lint
on:
push:
jobs:
lint:
name: Run lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
- name: Install dependencies
run: pip install tox
- name: Lint
run: tox -e lint,security
......@@ -5,7 +5,7 @@ on:
jobs:
black:
name: Run black
name: Run black/isort
runs-on: ubuntu-latest
steps:
......@@ -13,12 +13,15 @@ jobs:
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Run Black
uses: lgeiger/black-action@master
- uses: actions/setup-python@v2
with:
args: "."
python-version: 3.9
- name: Install poetry
uses: abatilo/actions-poetry@v2.0.0
- name: Install dependencies
run: pip install tox
- name: Reformat
run: tox -e reformat
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Reformat code using black"
......
import json
import subprocess
import subprocess # noqa
import time
import requests
from barcode import Code128
from barcode.writer import ImageWriter
from escpos.printer import Usb
......@@ -81,10 +80,7 @@ def print_server():
# Get auth token
r = requests.post(
login_url,
json={
"username": config.get("username"),
"password": config.get("password"),
},
json={"username": config.get("username"), "password": config.get("password"),},
)
token = r.json()["token"]
headers = {"Authorization": f"Token {token}"}
......@@ -115,11 +111,11 @@ def print_server():
f.write(r.content)
# Send barcode label to printer
subprocess.Popen(
subprocess.Popen( # noqa
["lp", "-d", config.get("barcode_printer"), "barcode-tmp.pdf"],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
) # noqa
printed = True
elif report == "info_page":
......@@ -128,9 +124,7 @@ def print_server():
# Mark print job as printed
if printed:
r3 = requests.post(
f"{jobs_url}{job_id}/mark_as_printed/", headers=headers
)
r3 = requests.post(f"{jobs_url}{job_id}/mark_as_printed/", headers=headers)
time.sleep(3)
......
This diff is collapsed.
......@@ -12,6 +12,27 @@ python-barcode = "^0.13.1"
requests = "^2.25.1"
[tool.poetry.dev-dependencies]
sphinx = "^3.0"
sphinx-autodoc-typehints = "^1.7"
pytest = "^6.0"
safety = "^1.8.5"
flake8 = "^3.7.9"
flake8-fixme = "^1.1.1"
flake8-mypy = "^17.8.0"
flake8-bandit = "^2.1.2"
flake8-builtins = "^1.4.1"
flake8-docstrings = "^1.5.0"
flake8-rst-docstrings = "^0.0.14"
black = "^19.10b0"
flake8-black = "^0.2.0"
isort = "^5.0.0"
flake8-isort = "^4.0.0"
pytest-cov = "^2.8.1"
pytest-sugar = "^0.9.2"
tox = "^3.21.3"
[tool.black]
line-length = 100
[tool.poetry.scripts]
documento-printserver = "documento_printserver.print_server:print_server"
......
tox.ini 0 → 100644
[tox]
skipsdist = True
skip_missing_interpreters = true
envlist = py37,py38,py39
[testenv]
whitelist_externals = poetry
sudo
skip_install = true
envdir = {toxworkdir}/globalenv
commands_pre =
poetry install
commands =
poetry run pytest --cov=. {posargs} .
[testenv:lint]
commands =
poetry run black --check --diff .
poetry run isort -c --skip-gitignore --diff --stdout .
poetry run flake8 {posargs} .
[testenv:security]
commands =
poetry show --no-dev
poetry run safety check --full-report
[testenv:build]
commands = poetry build
[testenv:docs]
commands = poetry run make -C docs/ html {posargs}
[testenv:reformat]
commands =
poetry run isort --skip-gitignore .
poetry run black .
[flake8]
max_line_length = 100
exclude = tests,.tox
ignore = BLK100,E203,E231,W503,D100,D101,D102,D103,D104,D105,D106,D107,RST215,RST214,F821,F841,S106,T100,T101,DJ05
[isort]
profile = black
line_length = 100
default_section = THIRDPARTY
known_first_party = documento_client
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
[mypy]
plugins = mypy_django_plugin.main
python_version = 3.8
platform = linux
show_column_numbers = True
follow_imports = skip
ignore_missing_imports = True
cache_dir = /dev/null
[pytest]
junit_family = legacy
[coverage:run]
omit =
*/tests/*
.tox/*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment