|
|
@ -62,6 +62,20 @@ def add_api(apistr, name=""):
|
|
|
|
return decorator
|
|
|
|
return decorator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_webview(webstr, name, in_menu=True):
|
|
|
|
|
|
|
|
""" decorator for making a method available on the web-admin"""
|
|
|
|
|
|
|
|
def decorator(func):
|
|
|
|
|
|
|
|
""" the decorator iteself """
|
|
|
|
|
|
|
|
@functools.wraps(func)
|
|
|
|
|
|
|
|
def func_wrap(*args, **kwargs):
|
|
|
|
|
|
|
|
""" this is to avoid roaching the namespace """
|
|
|
|
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
|
|
|
|
func_wrap.webview = webstr
|
|
|
|
|
|
|
|
func_wrap.name = name
|
|
|
|
|
|
|
|
return func_wrap
|
|
|
|
|
|
|
|
return decorator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LogPrinter(logging.Handler):
|
|
|
|
class LogPrinter(logging.Handler):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
LogPrinter prints logs on a receipt printer for screenless debugging.
|
|
|
|
LogPrinter prints logs on a receipt printer for screenless debugging.
|
|
|
@ -329,7 +343,8 @@ class Bureau(object):
|
|
|
|
method = getattr(self, member)
|
|
|
|
method = getattr(self, member)
|
|
|
|
# ignore anything that is not a method with command or api details
|
|
|
|
# ignore anything that is not a method with command or api details
|
|
|
|
if not (callable(method) and (hasattr(method, "command") or
|
|
|
|
if not (callable(method) and (hasattr(method, "command") or
|
|
|
|
hasattr(method, "api"))):
|
|
|
|
hasattr(method, "api") or
|
|
|
|
|
|
|
|
hasattr(method, "webview"))):
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
if hasattr(method, "command"):
|
|
|
|
if hasattr(method, "command"):
|
|
|
|
self.commands[method.command] = method
|
|
|
|
self.commands[method.command] = method
|
|
|
@ -353,6 +368,17 @@ class Bureau(object):
|
|
|
|
method(api_detail)
|
|
|
|
method(api_detail)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.send("IR", "addapi", api_detail)
|
|
|
|
self.send("IR", "addapi", api_detail)
|
|
|
|
|
|
|
|
elif hasattr(method, "webview"):
|
|
|
|
|
|
|
|
self.webview[method.webview] = method
|
|
|
|
|
|
|
|
webview_detail = { "name": method.name,
|
|
|
|
|
|
|
|
"prefix": self.prefix,
|
|
|
|
|
|
|
|
"webview": method.webview,
|
|
|
|
|
|
|
|
"desc": method.__doc__ }
|
|
|
|
|
|
|
|
if self.prefix == "IR":
|
|
|
|
|
|
|
|
method = getattr(self, "add_webview")
|
|
|
|
|
|
|
|
method(webview_detail)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.send("IR", "addweb", webview_detail)
|
|
|
|
|
|
|
|
|
|
|
|
self.log.debug("registered:")
|
|
|
|
self.log.debug("registered:")
|
|
|
|
self.log.debug(str(self.commands))
|
|
|
|
self.log.debug(str(self.commands))
|
|
|
|