|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
# bureau
|
|
|
|
|
import configparser
|
|
|
|
|
import functools
|
|
|
|
|
import inspect
|
|
|
|
|
import json
|
|
|
|
@ -16,6 +15,7 @@ import PIL
|
|
|
|
|
import zmq
|
|
|
|
|
from escpos import printer
|
|
|
|
|
from mako.template import Template
|
|
|
|
|
from ruamel.yaml import YAML
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_commands(cls):
|
|
|
|
@ -63,8 +63,7 @@ class Bureau(object):
|
|
|
|
|
name = "TEST"
|
|
|
|
|
prefix = "00"
|
|
|
|
|
version = 0
|
|
|
|
|
|
|
|
|
|
default_config = {"smallprinter": "/dev/usb/lp0"}
|
|
|
|
|
default_config = {}
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
""" set up ZeroMQ connections and register commands"""
|
|
|
|
@ -93,7 +92,6 @@ class Bureau(object):
|
|
|
|
|
logging.basicConfig(filename=logfile, level=logging.DEBUG)
|
|
|
|
|
self.log = logging.getLogger(self.prefix)
|
|
|
|
|
|
|
|
|
|
self.config = configparser.ConfigParser()
|
|
|
|
|
self.load_config()
|
|
|
|
|
|
|
|
|
|
# setup a dir to store files and data
|
|
|
|
@ -117,14 +115,13 @@ class Bureau(object):
|
|
|
|
|
"""
|
|
|
|
|
load (or reload) config data from file
|
|
|
|
|
"""
|
|
|
|
|
cfgfile = self.prefix + ".ini"
|
|
|
|
|
if os.path.exists(cfgfile):
|
|
|
|
|
self.config.read(cfgfile)
|
|
|
|
|
else:
|
|
|
|
|
self.config["DEFAULT"] = self.default_config
|
|
|
|
|
self.config["bureau"] = self.default_config
|
|
|
|
|
yaml = YAML()
|
|
|
|
|
cfgfile = self.prefix + ".yml"
|
|
|
|
|
if not os.path.exists(cfgfile):
|
|
|
|
|
with open(cfgfile, "w") as configfile:
|
|
|
|
|
self.config.write(configfile)
|
|
|
|
|
yaml.dump(self.default_config, configfile)
|
|
|
|
|
with open(cfgfile) as cfp:
|
|
|
|
|
self.config = yaml.load(cfp)
|
|
|
|
|
|
|
|
|
|
def send(self, recipient, message, data=None):
|
|
|
|
|
"""
|
|
|
|
|