| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. |
| 8 | 8 |
| 9 Usage: | 9 Usage: |
| 10 ./provision_devices.py [-d <device serial number>] | 10 ./provision_devices.py [-d <device serial number>] |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | 29 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, |
| 30 'third_party', 'android_testrunner')) | 30 'third_party', 'android_testrunner')) |
| 31 import errors | 31 import errors |
| 32 | 32 |
| 33 def KillHostHeartbeat(): | 33 def KillHostHeartbeat(): |
| 34 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) | 34 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) |
| 35 stdout, _ = ps.communicate() | 35 stdout, _ = ps.communicate() |
| 36 matches = re.findall('\\n.*host_heartbeat.*', stdout) | 36 matches = re.findall('\\n.*host_heartbeat.*', stdout) |
| 37 for match in matches: | 37 for match in matches: |
| 38 logging.info('An instance of host heart beart running... will kill') | 38 logging.info('An instance of host heart beart running... will kill') |
| 39 pid = re.findall('(\d+)', match)[0] | 39 pid = re.findall('(\S+)', match)[1] |
| 40 subprocess.call(['kill', str(pid)]) | 40 subprocess.call(['kill', str(pid)]) |
| 41 | 41 |
| 42 | 42 |
| 43 def LaunchHostHeartbeat(): | 43 def LaunchHostHeartbeat(): |
| 44 # Kill if existing host_heartbeat | 44 # Kill if existing host_heartbeat |
| 45 KillHostHeartbeat() | 45 KillHostHeartbeat() |
| 46 # Launch a new host_heartbeat | 46 # Launch a new host_heartbeat |
| 47 logging.info('Spawning host heartbeat...') | 47 logging.info('Spawning host heartbeat...') |
| 48 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, | 48 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, |
| 49 'build/android/host_heartbeat.py')]) | 49 'build/android/host_heartbeat.py')]) |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 if args: | 292 if args: |
| 293 print >> sys.stderr, 'Unused args %s' % args | 293 print >> sys.stderr, 'Unused args %s' % args |
| 294 return 1 | 294 return 1 |
| 295 | 295 |
| 296 ProvisionDevices(options) | 296 ProvisionDevices(options) |
| 297 | 297 |
| 298 | 298 |
| 299 if __name__ == '__main__': | 299 if __name__ == '__main__': |
| 300 sys.exit(main(sys.argv)) | 300 sys.exit(main(sys.argv)) |
| OLD | NEW |