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 17 matching lines...) Expand all Loading... |
28 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | 28 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, |
29 'third_party', 'android_testrunner')) | 29 'third_party', 'android_testrunner')) |
30 import errors | 30 import errors |
31 | 31 |
32 def KillHostHeartbeat(): | 32 def KillHostHeartbeat(): |
33 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) | 33 ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) |
34 stdout, _ = ps.communicate() | 34 stdout, _ = ps.communicate() |
35 matches = re.findall('\\n.*host_heartbeat.*', stdout) | 35 matches = re.findall('\\n.*host_heartbeat.*', stdout) |
36 for match in matches: | 36 for match in matches: |
37 print 'An instance of host heart beart running... will kill' | 37 print 'An instance of host heart beart running... will kill' |
38 pid = re.findall('(\d+)', match)[1] | 38 pid = re.findall('(\d+)', match)[0] |
39 subprocess.call(['kill', str(pid)]) | 39 subprocess.call(['kill', str(pid)]) |
40 | 40 |
41 | 41 |
42 def LaunchHostHeartbeat(): | 42 def LaunchHostHeartbeat(): |
43 # Kill if existing host_heartbeat | 43 # Kill if existing host_heartbeat |
44 KillHostHeartbeat() | 44 KillHostHeartbeat() |
45 # Launch a new host_heartbeat | 45 # Launch a new host_heartbeat |
46 print 'Spawning host heartbeat...' | 46 print 'Spawning host heartbeat...' |
47 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, | 47 subprocess.Popen([os.path.join(constants.DIR_SOURCE_ROOT, |
48 'build/android/host_heartbeat.py')]) | 48 'build/android/host_heartbeat.py')]) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 if args: | 274 if args: |
275 print >> sys.stderr, 'Unused args %s' % args | 275 print >> sys.stderr, 'Unused args %s' % args |
276 return 1 | 276 return 1 |
277 | 277 |
278 ProvisionDevices(options) | 278 ProvisionDevices(options) |
279 | 279 |
280 | 280 |
281 if __name__ == '__main__': | 281 if __name__ == '__main__': |
282 sys.exit(main(sys.argv)) | 282 sys.exit(main(sys.argv)) |
OLD | NEW |