Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Module containing methods and classes to interact with a devserver instance. | |
| 6 """ | |
| 7 | |
| 8 import threading | |
| 9 | |
| 10 import cros_build_lib as cros_lib | |
| 11 | |
| 12 def GenerateUpdateId(target, src, key): | |
| 13 """Returns a simple representation id of target and src paths.""" | |
| 14 update_id = target | |
| 15 if src: update_id = '->'.join([update_id, src]) | |
| 16 if key: update_id = '+'.join([update_id, key]) | |
| 17 return update_id | |
| 18 | |
| 19 class DevServerWrapper(threading.Thread): | |
| 20 """A Simple wrapper around a dev server instance.""" | |
| 21 | |
| 22 def __init__(self): | |
| 23 self.proc = None | |
| 24 threading.Thread.__init__(self) | |
| 25 | |
| 26 def run(self): | |
| 27 # Kill previous running instance of devserver if it exists. | |
| 28 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, | |
| 29 print_cmd=False) | |
| 30 cros_lib.RunCommand(['sudo', | |
| 31 'start_devserver', | |
| 32 '--archive_dir=./static', | |
| 33 '--client_prefix=ChromeOSUpdateEngine', | |
| 34 '--production', | |
| 35 ], enter_chroot=True, print_cmd=False) | |
| 36 | |
| 37 def Stop(self): | |
| 38 """Kills the devserver instance.""" | |
| 39 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, | |
| 40 print_cmd=False) | |
| 41 | |
| 42 @classmethod | |
|
dgarrett
2011/03/03 02:17:21
Again, not a problem, I'm just curious.
sosa
2011/03/03 03:11:41
Static method. Doesn't use any specific variables
| |
| 43 def GetDevServerURL(cls, port, sub_dir): | |
| 44 """Returns the dev server url for a given port and sub directory.""" | |
| 45 ip_addr = cros_lib.GetIPAddress() | |
| 46 if not port: port = 8080 | |
| 47 url = 'http://%(ip)s:%(port)s/%(dir)s' % {'ip': ip_addr, | |
| 48 'port': str(port), | |
| 49 'dir': sub_dir} | |
| 50 return url | |
| OLD | NEW |