summaryrefslogtreecommitdiffstats
path: root/tools/memory_inspector/start_web_ui
blob: 3d0f8d81858ecd7362e28dfde91b48aaaab5195b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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)