OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Copyright 2010 Google Inc. 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. |
4 | 5 |
5 """Script for test playback. | 6 """Tests playback. |
6 | 7 |
7 Prerequisites: | 8 Prerequisites: |
8 1. OpenSSL library - http://www.openssl.org/ | 9 1. OpenSSL library - http://www.openssl.org/ |
9 2. Python interface to the OpenSSL library - https://launchpad.net/pyopenssl | 10 2. Python interface to the OpenSSL library - https://launchpad.net/pyopenssl |
10 | 11 |
11 Example usage: | 12 Example usage: |
12 python run.py -t <test_dir> | 13 python run.py -t <test_dir> |
13 """ | 14 """ |
14 | 15 |
15 from optparse import OptionParser | 16 from optparse import OptionParser |
| 17 import sys |
16 | 18 |
17 import playback_driver | 19 import playback_driver |
18 import proxy_handler | 20 import proxy_handler |
19 | 21 |
20 | 22 |
21 def Run(options): | 23 def Run(options): |
22 driver = playback_driver.PlaybackRequestHandler(options.test_dir) | 24 driver = playback_driver.PlaybackRequestHandler(options.test_dir) |
23 httpd = proxy_handler.CreateServer(driver, options.port) | 25 httpd = proxy_handler.CreateServer(driver, options.port) |
24 sa = httpd.socket.getsockname() | 26 sa = httpd.socket.getsockname() |
25 print "Serving HTTP on", sa[0], "port", sa[1], "..." | 27 print "Serving HTTP on", sa[0], "port", sa[1], "..." |
26 httpd.serve_forever() | 28 httpd.serve_forever() |
27 | 29 |
28 | 30 |
29 if __name__ == '__main__': | 31 def main(): |
30 parser = OptionParser() | 32 parser = OptionParser() |
31 parser.add_option("-t", "--test-dir", dest="test_dir", | 33 parser.add_option("-t", "--test-dir", dest="test_dir", |
32 help="directory containing recorded test data") | 34 help="directory containing recorded test data") |
33 parser.add_option("-p", "--port", dest="port", type="int", default=8000) | 35 parser.add_option("-p", "--port", dest="port", type="int", default=8000) |
34 options = parser.parse_args()[0] | 36 options = parser.parse_args()[0] |
35 if not options.test_dir: | 37 if not options.test_dir: |
36 raise Exception('please specify test directory') | 38 raise Exception('please specify test directory') |
37 | 39 |
38 Run(options) | 40 Run(options) |
39 | 41 |
| 42 |
| 43 if __name__ == '__main__': |
| 44 sys.exit(main()) |
OLD | NEW |