| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 # Kill previous running instance of devserver if it exists. | 29 # Kill previous running instance of devserver if it exists. |
| 30 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, | 30 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, |
| 31 print_cmd=False) | 31 print_cmd=False) |
| 32 cros_lib.RunCommand(['sudo', | 32 cros_lib.RunCommand(['sudo', |
| 33 'start_devserver', | 33 'start_devserver', |
| 34 '--archive_dir=./static', | 34 '--archive_dir=./static', |
| 35 '--client_prefix=ChromeOSUpdateEngine', | 35 '--client_prefix=ChromeOSUpdateEngine', |
| 36 '--production', | 36 '--production', |
| 37 ], enter_chroot=True, print_cmd=False, | 37 ], enter_chroot=True, print_cmd=False, |
| 38 log_to_file=os.path.join(self.test_root, | 38 log_to_file=os.path.join(self.test_root, |
| 39 'dev_server.log')) | 39 'dev_server.log'), |
| 40 cwd=cros_lib.GetCrosUtilsPath()) |
| 40 | 41 |
| 41 def Stop(self): | 42 def Stop(self): |
| 42 """Kills the devserver instance.""" | 43 """Kills the devserver instance.""" |
| 43 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, | 44 cros_lib.RunCommand(['sudo', 'pkill', '-f', 'devserver.py'], error_ok=True, |
| 44 print_cmd=False) | 45 print_cmd=False) |
| 45 | 46 |
| 46 @classmethod | 47 @classmethod |
| 47 def GetDevServerURL(cls, port, sub_dir): | 48 def GetDevServerURL(cls, port, sub_dir): |
| 48 """Returns the dev server url for a given port and sub directory.""" | 49 """Returns the dev server url for a given port and sub directory.""" |
| 49 ip_addr = cros_lib.GetIPAddress() | 50 ip_addr = cros_lib.GetIPAddress() |
| 50 if not port: port = 8080 | 51 if not port: port = 8080 |
| 51 url = 'http://%(ip)s:%(port)s/%(dir)s' % {'ip': ip_addr, | 52 url = 'http://%(ip)s:%(port)s/%(dir)s' % {'ip': ip_addr, |
| 52 'port': str(port), | 53 'port': str(port), |
| 53 'dir': sub_dir} | 54 'dir': sub_dir} |
| 54 return url | 55 return url |
| OLD | NEW |