Add simple wrappers for webplot
This CL adds in two simple wrapper scripts for webplot to be run on
the user's development machine. They essentially just set all the
command line flags of webplot for you, because they're somewhat easy
to forget.
To make this work even easier I add a new flag to the webplot.py main
function "--automatically_start_browser" which leverages python's
webbrowser module to fire up a browser pointed to the webplot server
without the user having to, which saves you one more step in the
process.
Now you can simply run: "webplot_chromeos_touchpad.sh 192.168.0.4"
and it'll start up webplot and a browser tab that shows you the events
coming from the touchpad on the DUT with IP address 192.168.0.4.
BUG=chromium:508594
TEST=manually tested on my desktop using a ChromeOS device and both
scripts worked nice and easy for me
Change-Id: Ia0ef625d5ffe926dafcb0941fd397498ed56d251
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284618
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
diff --git a/webplot/webplot.py b/webplot/webplot.py
index 294d091..25a6986 100755
--- a/webplot/webplot.py
+++ b/webplot/webplot.py
@@ -16,6 +16,7 @@
import subprocess
import time
import threading
+import webbrowser
import cherrypy
@@ -514,6 +515,10 @@
help='the address the webplot http server listens to')
parser.add_argument('-t', '--dut_type', default='chromeos', type=str.lower,
help='dut type: chromeos, android')
+ parser.add_argument('--automatically_start_browser', action='store_true',
+ help=('When this flag is set the script will try to '
+ 'start a web browser automatically once webplot '
+ 'is ready, instead of waiting for the user to.'))
args = parser.parse_args()
args.grab = not args.nograb
@@ -543,9 +548,9 @@
print '-' * 70 + '\n\n'
if args.server_port == 80:
- url = args.server_addr
+ url = 'http://%s' % args.server_addr
else:
- url = '%s:%d' % (args.server_addr, args.server_port)
+ url = 'http://%s:%d' % (args.server_addr, args.server_port)
msg = 'Type "%s" in browser %s to see finger traces.\n'
if args.server_addr == '127.0.0.1':
@@ -571,6 +576,16 @@
is_behind_iptables_firewall=args.behind_firewall)
webplot.start()
+ if args.automatically_start_browser:
+ opened_successfully = webbrowser.open(url)
+ if opened_successfully:
+ print 'Web browser opened successfully!'
+ else:
+ print '!' * 80
+ print 'Sorry, we were unable to automatically open a web browser for you'
+ print 'Please navigate to "%s" in a browser manually, instead' % url
+ print '!' * 80
+
# Get touch snapshots from the touch device and have clients plot them.
webplot.GetAndPlotSnapshots()