Browse Source

Initial Commit

master
subnixr 4 years ago
commit
619f5f51f8
  1. 102
      .gitignore
  2. 42
      autostampa.py
  3. 14
      config.json.skel
  4. 17
      requirements.txt

102
.gitignore

@ -0,0 +1,102 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# macao-pos files
conf/
pos.db
pos.log*
# configurations
config.json

42
autostampa.py

@ -0,0 +1,42 @@
import json
from escpos import printer
class Item:
def __init__(self, text, icon):
self.text = text
self.icon = icon
def print(self, conn):
conn.text(f"{self.text}\n")
# TODO: conn.image(self.icon)
conn.cut()
def connect(connection_cfg):
if "file" in connection_cfg:
return printer.File(connection_cfg["file"])
else:
return printer.Dummy()
def load_items(items_cfg):
return [Item(c['text'], c['img']) for c in items_cfg]
def main():
with open("config.json") as fh:
cfg = json.load(fh)
items = load_items(cfg['items'])
conn = connect(cfg["connection"])
for i in items:
i.print(conn)
print(conn.output.decode('UTF-8'))
if __name__ == "__main__":
main()

14
config.json.skel

@ -0,0 +1,14 @@
{
// for now dummy only
"connection": {},
"items": [
{
"text": "birra",
"img": "assets/birra.jpg"
},
{
"text": "acqua",
"img": "assets/acqua.jpg"
}
]
}

17
requirements.txt

@ -0,0 +1,17 @@
appdirs==1.4.3
argcomplete==1.9.3
astroid==1.6.1
autopep8==1.3.4
isort==4.3.1
lazy-object-proxy==1.3.1
mccabe==0.6.1
Pillow==5.0.0
pycodestyle==2.3.1
pylint==1.8.2
pyserial==3.4
python-escpos==2.2.0
pyusb==1.0.2
PyYAML==3.12
qrcode==5.3
six==1.11.0
wrapt==1.10.11
Loading…
Cancel
Save