diff options
author | petrcermak <petrcermak@chromium.org> | 2015-01-19 10:36:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-19 18:36:45 +0000 |
commit | 61758728e9db570bc71e4d6b88bccafaf5ae78e5 (patch) | |
tree | b73b6716c81cea2af31fe88e924515e3478bd977 /tools/memory_inspector | |
parent | 8d4fbd88af6461eed50ea0c6b49654c6933a3b0d (diff) | |
download | chromium_src-61758728e9db570bc71e4d6b88bccafaf5ae78e5.zip chromium_src-61758728e9db570bc71e4d6b88bccafaf5ae78e5.tar.gz chromium_src-61758728e9db570bc71e4d6b88bccafaf5ae78e5.tar.bz2 |
Add command-line arguments to start_web_ui in Memory Inspector
This patch adds two optional arguments:
-p PORT, --port PORT the port on which the memory inspector server will run
-n, --no-browser do not open the memory inspector in a web browser
This change will make the start_web_ui file reusable for the Memory
Inspector Chrome App.
BUG=448399
Review URL: https://codereview.chromium.org/852013004
Cr-Commit-Position: refs/heads/master@{#312136}
Diffstat (limited to 'tools/memory_inspector')
-rwxr-xr-x | tools/memory_inspector/start_web_ui | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/tools/memory_inspector/start_web_ui b/tools/memory_inspector/start_web_ui index 27a0e08..2c16b64 100755 --- a/tools/memory_inspector/start_web_ui +++ b/tools/memory_inspector/start_web_ui @@ -3,15 +3,36 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import argparse import logging -import webbrowser from memory_inspector.frontends import www_server +DEFAULT_HTTP_PORT = 8089 + + +def _ParseArguments(): + parser = argparse.ArgumentParser(description='Start the memory inspector.') + parser.add_argument( + '-p', '--port', + type=int, + default=DEFAULT_HTTP_PORT, + help='the port on which the memory inspector server will run') + parser.add_argument( + '-n', '--no-browser', + action='store_true', + default=False, + help=('start the memory inspector server without launching the web-based ' + 'frontend')) + return parser.parse_args() + + if __name__ == '__main__': - HTTP_PORT=8089 + options = _ParseArguments() logging.getLogger().setLevel(logging.WARNING) - print 'Serving on port %d' % HTTP_PORT - webbrowser.open('http://localhost:%d' % HTTP_PORT) - www_server.Start(HTTP_PORT)
\ No newline at end of file + print 'Serving on port %d' % options.port + if not options.no_browser: + import webbrowser + webbrowser.open('http://localhost:%d' % options.port) + www_server.Start(options.port) |