OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. | 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. |
6 | 6 |
7 It's used to accept requests from the device to spawn and kill instances of the | 7 It's used to accept requests from the device to spawn and kill instances of the |
8 chrome test server on the host. | 8 chrome test server on the host. |
9 """ | 9 """ |
10 # pylint: disable=W0702 | 10 # pylint: disable=W0702 |
11 | 11 |
12 import BaseHTTPServer | 12 import BaseHTTPServer |
13 import json | 13 import json |
14 import logging | 14 import logging |
15 import os | 15 import os |
16 import select | 16 import select |
17 import struct | 17 import struct |
18 import subprocess | 18 import subprocess |
19 import sys | 19 import sys |
20 import threading | 20 import threading |
21 import time | 21 import time |
22 import urlparse | 22 import urlparse |
23 | 23 |
| 24 from devil.android import ports |
| 25 |
24 from pylib import constants | 26 from pylib import constants |
25 from pylib import ports | |
26 | |
27 from pylib.forwarder import Forwarder | 27 from pylib.forwarder import Forwarder |
28 | 28 |
29 | 29 |
30 # Path that are needed to import necessary modules when launching a testserver. | 30 # Path that are needed to import necessary modules when launching a testserver. |
31 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' | 31 os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + (':%s:%s:%s:%s:%s' |
32 % (os.path.join(constants.DIR_SOURCE_ROOT, 'third_party'), | 32 % (os.path.join(constants.DIR_SOURCE_ROOT, 'third_party'), |
33 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'tlslite'), | 33 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'tlslite'), |
34 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib', | 34 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pyftpdlib', |
35 'src'), | 35 'src'), |
36 os.path.join(constants.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'), | 36 os.path.join(constants.DIR_SOURCE_ROOT, 'net', 'tools', 'testserver'), |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 413 |
414 def CleanupState(self): | 414 def CleanupState(self): |
415 """Cleans up the spawning server state. | 415 """Cleans up the spawning server state. |
416 | 416 |
417 This should be called if the test server spawner is reused, | 417 This should be called if the test server spawner is reused, |
418 to avoid sharing the test server instance. | 418 to avoid sharing the test server instance. |
419 """ | 419 """ |
420 if self.server.test_server_instance: | 420 if self.server.test_server_instance: |
421 self.server.test_server_instance.Stop() | 421 self.server.test_server_instance.Stop() |
422 self.server.test_server_instance = None | 422 self.server.test_server_instance = None |
OLD | NEW |