OLD | NEW |
1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # 1. Redistributions of source code must retain the above copyright | 7 # 1. Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # 2. Redistributions in binary form must reproduce the above copyright | 9 # 2. Redistributions in binary form must reproduce the above copyright |
10 # notice, this list of conditions and the following disclaimer in the | 10 # notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand | 28 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand |
29 | 29 |
30 | 30 |
31 class AbstractLocalServerCommand(AbstractDeclarativeCommand): | 31 class AbstractLocalServerCommand(AbstractDeclarativeCommand): |
32 server = None | 32 server = None |
33 launch_path = "/" | 33 launch_path = "/" |
34 | 34 |
35 def __init__(self): | 35 def __init__(self): |
36 options = [ | 36 options = [ |
37 make_option("--httpd-port", action="store", type="int", default=8127
, help="Port to use for the HTTP server"), | 37 make_option("--httpd-port", action="store", type="int", default=8127
, help="Port to use for the HTTP server"), |
38 make_option("--no-show-results", action="store_false", default=True,
dest="show_results", help="Don't launch a browser with the rebaseline server"), | 38 make_option("--no-show-results", action="store_false", default=True,
dest="show_results", |
| 39 help="Don't launch a browser with the rebaseline server"
), |
39 ] | 40 ] |
40 AbstractDeclarativeCommand.__init__(self, options=options) | 41 AbstractDeclarativeCommand.__init__(self, options=options) |
41 | 42 |
42 def _prepare_config(self, options, args, tool): | 43 def _prepare_config(self, options, args, tool): |
43 return None | 44 return None |
44 | 45 |
45 def execute(self, options, args, tool): | 46 def execute(self, options, args, tool): |
46 config = self._prepare_config(options, args, tool) | 47 config = self._prepare_config(options, args, tool) |
47 | 48 |
48 server_url = "http://localhost:%d%s" % (options.httpd_port, self.launch_
path) | 49 server_url = "http://localhost:%d%s" % (options.httpd_port, self.launch_
path) |
49 print "Starting server at %s" % server_url | 50 print "Starting server at %s" % server_url |
50 print "Use the 'Exit' link in the UI, %squitquitquit or Ctrl-C to stop"
% server_url | 51 print "Use the 'Exit' link in the UI, %squitquitquit or Ctrl-C to stop"
% server_url |
51 | 52 |
52 if options.show_results: | 53 if options.show_results: |
53 # FIXME: This seems racy. | 54 # FIXME: This seems racy. |
54 threading.Timer(0.1, lambda: self._tool.user.open_url(server_url)).s
tart() | 55 threading.Timer(0.1, lambda: self._tool.user.open_url(server_url)).s
tart() |
55 | 56 |
56 httpd = self.server(httpd_port=options.httpd_port, config=config) # pyl
int: disable=E1102 | 57 httpd = self.server(httpd_port=options.httpd_port, config=config) # pyl
int: disable=E1102 |
57 httpd.serve_forever() | 58 httpd.serve_forever() |
OLD | NEW |