From 8102698dfdcdb72d52b9ac8945b07448641e76f4 Mon Sep 17 00:00:00 2001 From: Edi Santoso Date: Sun, 13 Aug 2017 14:05:22 +0700 Subject: [PATCH] [FIX] hw_proxy: error when check status in debug mode when access status hw_proxy in debug mode it's will raise error, it's happens because hw_proxy uses subprocess module to get a list of usb but the subprocess module not imported. Introduced at 56456359 Closes #18820 --- addons/hw_proxy/controllers/main.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/hw_proxy/controllers/main.py b/addons/hw_proxy/controllers/main.py index 91aee8708e8..cd90ffd16ed 100644 --- a/addons/hw_proxy/controllers/main.py +++ b/addons/hw_proxy/controllers/main.py @@ -4,6 +4,7 @@ import commands import logging import time +import subprocess from threading import Lock @@ -22,7 +23,7 @@ BANNED_DEVICES = set([ ]) -# drivers modules must add to drivers an object with a get_status() method +# drivers modules must add to drivers an object with a get_status() method # so that 'status' can return the status of all active drivers drivers = {} @@ -107,7 +108,7 @@ class Proxy(http.Controller): if not (device_id in BANNED_DEVICES): resp+= "
"+device_name+"
\n" count += 1 - + if count == 0: resp += "
No USB Device Found
" @@ -125,7 +126,7 @@ class Proxy(http.Controller): """ % subprocess.check_output('lsusb -v', shell=True) return request.make_response(resp,{ - 'Cache-Control': 'no-cache', + 'Cache-Control': 'no-cache', 'Content-Type': 'text/html; charset=utf-8', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', @@ -166,7 +167,7 @@ class Proxy(http.Controller): @http.route('/hw_proxy/payment_request', type='json', auth='none', cors='*') def payment_request(self, price): """ - The PoS will activate the method payment + The PoS will activate the method payment """ print "payment_request: price:"+str(price) return 'ok' @@ -174,7 +175,7 @@ class Proxy(http.Controller): @http.route('/hw_proxy/payment_status', type='json', auth='none', cors='*') def payment_status(self): print "payment_status" - return { 'status':'waiting' } + return { 'status':'waiting' } @http.route('/hw_proxy/payment_cancel', type='json', auth='none', cors='*') def payment_cancel(self): @@ -206,12 +207,12 @@ class Proxy(http.Controller): @http.route('/hw_proxy/is_scanner_connected', type='json', auth='none', cors='*') def is_scanner_connected(self, receipt): - print 'is_scanner_connected?' + print 'is_scanner_connected?' return False @http.route('/hw_proxy/scanner', type='json', auth='none', cors='*') def scanner(self, receipt): - print 'scanner' + print 'scanner' time.sleep(10) return ''