| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import socket | 5 import socket |
| 6 import subprocess | 6 import subprocess |
| 7 import logging | 7 import logging |
| 8 import os.path | 8 import os.path |
| 9 | 9 |
| 10 SKYPY_PATH = os.path.dirname(__file__) | 10 SKYPY_PATH = os.path.dirname(os.path.abspath(__file__)) |
| 11 SKY_TOOLS_PATH = os.path.dirname(SKYPY_PATH) | 11 SKY_TOOLS_PATH = os.path.dirname(SKYPY_PATH) |
| 12 SKY_ROOT = os.path.dirname(SKY_TOOLS_PATH) | 12 SKY_ROOT = os.path.dirname(SKY_TOOLS_PATH) |
| 13 SRC_ROOT = os.path.dirname(SKY_ROOT) | 13 SRC_ROOT = os.path.dirname(SKY_ROOT) |
| 14 | 14 |
| 15 class SkyServer(object): | 15 class SkyServer(object): |
| 16 def __init__(self, port, configuration, root): | 16 def __init__(self, port, configuration, root): |
| 17 self.port = port | 17 self.port = port |
| 18 self.configuration = configuration | 18 self.configuration = configuration |
| 19 self.root = root | 19 self.root = root |
| 20 self.server = None | 20 self.server = None |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 def __exit__(self, exc_type, exc_value, traceback): | 56 def __exit__(self, exc_type, exc_value, traceback): |
| 57 self.stop() | 57 self.stop() |
| 58 | 58 |
| 59 def path_as_url(self, path): | 59 def path_as_url(self, path): |
| 60 return self.url_for_path(self.port, self.root, path) | 60 return self.url_for_path(self.port, self.root, path) |
| 61 | 61 |
| 62 @staticmethod | 62 @staticmethod |
| 63 def url_for_path(port, root, path): | 63 def url_for_path(port, root, path): |
| 64 relative_path = os.path.relpath(path, root) | 64 relative_path = os.path.relpath(path, root) |
| 65 return 'http://localhost:%s/%s' % (port, relative_path) | 65 return 'http://localhost:%s/%s' % (port, relative_path) |
| OLD | NEW |