Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/test/functional/perf/endure_server.py

Issue 10837114: Automate Chrome Endure setup process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Start an HTTP server which serves Chrome Endure graphs.
7
8 Usage:
9 python endure_server.py [options]
10
11 To view Chrome Endure graphs from a browser,
12 run this script to start a local HTTP server that serves the directory
13 where graph code and test results are located. A port will be automatically
14 picked. You can then view the graphs via http://localhost:<GIVEN_PORT>.
15
16 Examples:
17 python endure_server.py
dennis_jeffrey 2012/08/15 17:53:08 add a ">" at the beginning of this line to highlig
fdeng1 2012/08/17 00:26:10 Done.
18 Start a server which serves the default location
19 <CURRENT_WORKING_DIR>/chrome_graph.
20
21 python endure_server.py --graph-dir=/home/user/Document/graph_dir
dennis_jeffrey 2012/08/15 17:53:08 same comment as line 17 above
fdeng1 2012/08/17 00:26:10 Done.
22 Start a server which serves /home/user/Document/graph_dir which
23 is where your graph code and test results are.
24 """
25 import BaseHTTPServer
dennis_jeffrey 2012/08/15 17:53:08 nit: add a blank line above this to separate the d
fdeng1 2012/08/17 00:26:10 Done.
26 import logging
27 import optparse
28 import os
29 import SimpleHTTPServer
30 import sys
31
32
33 class HelpFormatter(optparse.IndentedHelpFormatter):
34 """Format the help message of this script."""
35
36 def format_description(self, description):
dennis_jeffrey 2012/08/15 17:53:08 add a comment to explain why you're overriding thi
fdeng1 2012/08/17 00:26:10 Done.
37 if description:
38 return description + '\n'
39 else:
40 return ''
dennis_jeffrey 2012/08/15 17:53:08 i think this could be combined into a one-liner:
fdeng1 2012/08/17 00:26:10 Done.
41
42
43 def _ParseArgs(argv):
44 parser = optparse.OptionParser(
45 usage='%prog [options]',
46 formatter=HelpFormatter(),
47 description=__doc__)
48 parser.add_option(
49 '-g', '--graph-dir', type='string',
50 default=os.path.join(os.getcwd(), 'chrome_graph'),
51 help='The directory that contains graph code ' \
52 'and data files of test results. Default value is ' \
53 '<CURRENT_WORKING_DIR>/chrome_graph')
54 return parser.parse_args(argv)
55
56
57 def Run(argv):
58 """Start an HTTP server which serves Chrome Endure graphs."""
59 logging.basicConfig(format='[%(levelname)s] %(message)s', level=logging.DEBUG)
60 options, _ = _ParseArgs(argv)
61 graph_dir = os.path.abspath(options.graph_dir)
62 cur_dir = os.getcwd()
63 os.chdir(graph_dir)
64 httpd = BaseHTTPServer.HTTPServer(
65 ('', 0), SimpleHTTPServer.SimpleHTTPRequestHandler)
66 try:
67 logging.info('Serving %s at port %d', graph_dir, httpd.server_port)
68 logging.info('View graphs at http://localhost:%d', httpd.server_port)
69 logging.info('Press Ctrl-C to stop the server.')
70 httpd.serve_forever()
71 except KeyboardInterrupt:
72 logging.info('Shutting down ...')
73 httpd.shutdown()
74 finally:
75 os.chdir(cur_dir)
76 return 0
77
78
79 if '__main__' == __name__:
80 sys.exit(Run(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/perf/endure_setup.py » ('j') | chrome/test/functional/perf/endure_setup.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698