| OLD | NEW |
| 1 #!/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A class to help start/stop a local apache http server.""" | 6 """A class to help start/stop a local apache http server.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| 11 import subprocess | 11 import subprocess |
| 12 import sys | 12 import sys |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 stdout=subprocess.PIPE, | 162 stdout=subprocess.PIPE, |
| 163 stderr=subprocess.PIPE) | 163 stderr=subprocess.PIPE) |
| 164 logging.info('%s\n%s' % (kill_proc.stdout.read(), | 164 logging.info('%s\n%s' % (kill_proc.stdout.read(), |
| 165 kill_proc.stderr.read())) | 165 kill_proc.stderr.read())) |
| 166 self._http_server_proc = None | 166 self._http_server_proc = None |
| 167 if self._cygserver_path: | 167 if self._cygserver_path: |
| 168 subprocess.Popen(["taskkill.exe", "/f", "/im", "cygserver.exe"], | 168 subprocess.Popen(["taskkill.exe", "/f", "/im", "cygserver.exe"], |
| 169 stdout=subprocess.PIPE, | 169 stdout=subprocess.PIPE, |
| 170 stderr=subprocess.PIPE) | 170 stderr=subprocess.PIPE) |
| 171 | 171 |
| 172 if '__main__' == __name__: | 172 |
| 173 def main(): |
| 173 # Provide some command line params for starting/stopping the http server | 174 # Provide some command line params for starting/stopping the http server |
| 174 # manually. | 175 # manually. |
| 175 option_parser = optparse.OptionParser() | 176 option_parser = optparse.OptionParser() |
| 176 option_parser.add_option('-k', '--server', help='Server action (start|stop)') | 177 option_parser.add_option('-k', '--server', help='Server action (start|stop)') |
| 177 option_parser.add_option('-r', '--root', help='Document root (optional)') | 178 option_parser.add_option('-r', '--root', help='Document root (optional)') |
| 178 option_parser.add_option('-a', '--apache2', action='store_true', | 179 option_parser.add_option('-a', '--apache2', action='store_true', |
| 179 default=False, help='Starts Apache 2 instead of Apache 1.3 (default). ' | 180 default=False, help='Starts Apache 2 instead of Apache 1.3 (default). ' |
| 180 'Ignored on Mac (apache2 is used always)') | 181 'Ignored on Mac (apache2 is used always)') |
| 181 options, args = option_parser.parse_args() | 182 options, args = option_parser.parse_args() |
| 182 | 183 |
| 183 if not options.server: | 184 if not options.server: |
| 184 print ("Usage: %s -k {start|stop} [-r document_root] [--apache2]" % | 185 print ("Usage: %s -k {start|stop} [-r document_root] [--apache2]" % |
| 185 sys.argv[0]) | 186 sys.argv[0]) |
| 186 sys.exit(0) | 187 return 1 |
| 187 | 188 |
| 188 document_root = None | 189 document_root = None |
| 189 if options.root: | 190 if options.root: |
| 190 document_root = options.root | 191 document_root = options.root |
| 191 | 192 |
| 192 if 'start' == options.server: | 193 if 'start' == options.server: |
| 193 StartServer(document_root, apache2=options.apache2) | 194 StartServer(document_root, apache2=options.apache2) |
| 194 else: | 195 else: |
| 195 StopServers(apache2=options.apache2) | 196 StopServers(apache2=options.apache2) |
| 196 | 197 |
| 198 |
| 199 if '__main__' == __name__: |
| 200 sys.exit(main()) |
| OLD | NEW |