| #!/usr/bin/env python |
| # Copyright 2014 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import argparse |
| import logging |
| |
| 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__': |
| options = _ParseArguments() |
| logging.getLogger().setLevel(logging.WARNING) |
| print 'Serving on port %d' % options.port |
| if not options.no_browser: |
| import webbrowser |
| webbrowser.open('http://127.0.0.1:%d' % options.port) |
| www_server.Start(options.port) |