Fix missing dependency "centroiding" of webplot
Set import centroiding conditionally to avoid the dependency issue if
webplot runs locally on Chromebook.
clean up unnecessary space line by the way.
BUG=chromium:563725
TEST=manual test
Change-Id: Id6a1c8c743c121392ff6ed46e7d22c0909bd6b72
Reviewed-on: https://chromium-review.googlesource.com/316468
Commit-Ready: Pin-chih Lin <johnylin@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
diff --git a/webplot/webplot.py b/webplot/webplot.py
index 2df21ff..52c1852 100755
--- a/webplot/webplot.py
+++ b/webplot/webplot.py
@@ -25,7 +25,6 @@
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import WebSocket
-from centroiding import CentroidingDataReceiver, CentroidingDevice
from remote import ChromeOSTouchDevice, AndroidTouchDevice
@@ -600,8 +599,11 @@
configure_logger(level=logging.ERROR)
args = _ParseArguments()
+ # Specify Webplot for centroiding purpose.
+ is_centroiding = args.dut_type == 'centroiding'
+
print '\n' + '-' * 70
- if args.dut_type == 'centroiding':
+ if is_centroiding:
cherrypy.log('**** Centroiding Data Visualizing Tool ****')
cherrypy.log('dut config file: %s' % args.config)
cherrypy.log('dut address: %s' % args.dut_addr)
@@ -642,11 +644,13 @@
device = ChromeOSTouchDevice(addr, args.is_touchscreen, grab=args.grab)
elif args.dut_type == 'android':
device = AndroidTouchDevice(args.dut_addr, True)
- else: # args.dut_type == 'centroiding'
+ elif is_centroiding: # args.dut_type == 'centroiding'
+ # Import centroiding library conditionally to avoid missing dependency.
+ from centroiding import CentroidingDataReceiver, CentroidingDevice
device = CentroidingDevice(args.config)
-
- # Specify Webplot for centroiding purpose.
- is_centroiding = args.dut_type == 'centroiding'
+ else:
+ print 'Unrecognized dut_type: %s. Webplot is aborted...' % args.dut_type
+ exit(1)
# Instantiate a webplot server daemon and start it.
webplot = Webplot(args.server_addr, args.server_port, device, logging=True,