OLD | NEW |
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS 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 """Module containing methods and classes to interact with a devserver instance. | 5 """Module containing methods and classes to interact with a devserver instance. |
6 """ | 6 """ |
7 | 7 |
8 import os | 8 import os |
9 import threading | 9 import threading |
10 | 10 |
11 import cros_build_lib as cros_lib | 11 import cros_build_lib as cros_lib |
12 | 12 |
13 def GenerateUpdateId(target, src, key): | 13 def GenerateUpdateId(target, src, key): |
14 """Returns a simple representation id of target and src paths.""" | 14 """Returns a simple representation id of target and src paths.""" |
15 update_id = target | 15 update_id = target |
16 if src: update_id = '->'.join([update_id, src]) | 16 if src: update_id = '->'.join([src, update_id]) |
17 if key: update_id = '+'.join([update_id, key]) | 17 if key: update_id = '+'.join([update_id, key]) |
18 return update_id | 18 return update_id |
19 | 19 |
20 class DevServerWrapper(threading.Thread): | 20 class DevServerWrapper(threading.Thread): |
21 """A Simple wrapper around a dev server instance.""" | 21 """A Simple wrapper around a dev server instance.""" |
22 | 22 |
23 def __init__(self, test_root): | 23 def __init__(self, test_root): |
24 self.proc = None | 24 self.proc = None |
25 self.test_root = test_root | 25 self.test_root = test_root |
26 threading.Thread.__init__(self) | 26 threading.Thread.__init__(self) |
(...skipping 18 matching lines...) Expand all Loading... |
45 | 45 |
46 @classmethod | 46 @classmethod |
47 def GetDevServerURL(cls, port, sub_dir): | 47 def GetDevServerURL(cls, port, sub_dir): |
48 """Returns the dev server url for a given port and sub directory.""" | 48 """Returns the dev server url for a given port and sub directory.""" |
49 ip_addr = cros_lib.GetIPAddress() | 49 ip_addr = cros_lib.GetIPAddress() |
50 if not port: port = 8080 | 50 if not port: port = 8080 |
51 url = 'http://%(ip)s:%(port)s/%(dir)s' % {'ip': ip_addr, | 51 url = 'http://%(ip)s:%(port)s/%(dir)s' % {'ip': ip_addr, |
52 'port': str(port), | 52 'port': str(port), |
53 'dir': sub_dir} | 53 'dir': sub_dir} |
54 return url | 54 return url |
OLD | NEW |