_logger = logging.getLogger(__name__)
+
class EscposDriver(Thread):
def __init__(self):
Thread.__init__(self)
def connected_usb_devices(self):
connected = []
+
for device in supported_devices.device_list:
if usb.core.find(idVendor=device['vendor'], idProduct=device['product']) != None:
connected.append(device)
self.push_task('status')
return self.status
+
+
def open_cashbox(self,printer):
printer.cashdraw(2)
printer.cashdraw(5)
# -*- coding: utf-8 -*-
import logging
+import commands
import simplejson
import os
import os.path
@http.route('/hw_proxy/status', type='http', auth='none', cors='*')
def status_http(self):
- resp = '<html>\n<body>\n<h1>Hardware Proxy Status</h1>\n'
+ resp = """
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>OpenERP's PosBox</title>
+ <style>
+ body {
+ width: 480px;
+ margin: 60px auto;
+ font-family: sans-serif;
+ text-align: justify;
+ color: #6B6B6B;
+ }
+ .device {
+ border-bottom: solid 1px rgb(216,216,216);
+ padding: 9px;
+ }
+ .device:nth-child(2n) {
+ background:rgb(240,240,240);
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Hardware Status</h1>
+ <p>The list of enabled drivers and their status</p>
+"""
statuses = self.get_status()
for driver in statuses:
else:
color = 'red'
- resp += "<h2 style='color:"+color+";'>"+driver+' : '+status['status']+"</h2>\n"
+ resp += "<h3 style='color:"+color+";'>"+driver+' : '+status['status']+"</h3>\n"
resp += "<ul>\n"
for msg in status['messages']:
resp += '<li>'+msg+'</li>\n'
resp += "</ul>\n"
- resp += "<script>\n\tsetTimeout(function(){window.location.reload();},30000);\n</script>\n</body>\n</html>\n\n"
+ resp += """
+ <h2>Connected Devices</h2>
+ <p>The list of connected USB devices as seen by the posbox</p>
+ """
+ devices = commands.getoutput("lsusb").split('\n')
+ resp += "<div class='devices'>\n"
+ for device in devices:
+ device_name = device[device.find('ID')+2:]
+ resp+= "<div class='device' data-device='"+device+"'>"+device_name+"</div>\n"
+ resp += "</div>\n"
+ resp += "</body>\n</html>\n\n"
return request.make_response(resp,{
'Cache-Control': 'no-cache',