| OLD | NEW |
| 1 #!/bin/env python | 1 #!/bin/env python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 stdout=subprocess.PIPE, | 169 stdout=subprocess.PIPE, |
| 170 stderr=subprocess.PIPE) | 170 stderr=subprocess.PIPE) |
| 171 | 171 |
| 172 if '__main__' == __name__: | 172 if '__main__' == __name__: |
| 173 # Provide some command line params for starting/stopping the http server | 173 # Provide some command line params for starting/stopping the http server |
| 174 # manually. | 174 # manually. |
| 175 option_parser = optparse.OptionParser() | 175 option_parser = optparse.OptionParser() |
| 176 option_parser.add_option('-k', '--server', help='Server action (start|stop)') | 176 option_parser.add_option('-k', '--server', help='Server action (start|stop)') |
| 177 option_parser.add_option('-r', '--root', help='Document root (optional)') | 177 option_parser.add_option('-r', '--root', help='Document root (optional)') |
| 178 option_parser.add_option('-a', '--apache2', action='store_true', | 178 option_parser.add_option('-a', '--apache2', action='store_true', |
| 179 default=False, help='Starts Apache 2 instead of Apache 1.3 (default).') | 179 default=False, help='Starts Apache 2 instead of Apache 1.3 (default). ' |
| 180 'Ignored on Mac (apache2 is used always)') |
| 180 options, args = option_parser.parse_args() | 181 options, args = option_parser.parse_args() |
| 181 | 182 |
| 182 if not options.server: | 183 if not options.server: |
| 183 print ("Usage: %s -k {start|stop} [-r document_root] [--apache2]" % | 184 print ("Usage: %s -k {start|stop} [-r document_root] [--apache2]" % |
| 184 sys.argv[0]) | 185 sys.argv[0]) |
| 185 sys.exit(0) | 186 sys.exit(0) |
| 186 | 187 |
| 187 document_root = None | 188 document_root = None |
| 188 if options.root: | 189 if options.root: |
| 189 document_root = options.root | 190 document_root = options.root |
| 190 | 191 |
| 191 if 'start' == options.server: | 192 if 'start' == options.server: |
| 192 StartServer(document_root, apache2=options.apache2) | 193 StartServer(document_root, apache2=options.apache2) |
| 193 else: | 194 else: |
| 194 StopServers(apache2=options.apache2) | 195 StopServers(apache2=options.apache2) |
| 195 | 196 |
| OLD | NEW |