Initial Commit

master
subnixr 2018-02-03 02:19:32 +01:00
commit 619f5f51f8
4 changed files with 175 additions and 0 deletions

102
.gitignore vendored 100644
View File

@ -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 100644
View File

@ -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 100644
View File

@ -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 100644
View File

@ -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