OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 """Run the webpages_playback automation script.""" | 7 """Run the webpages_playback automation script.""" |
8 | 8 |
9 | 9 |
10 import os | 10 import os |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 try: | 65 try: |
66 shell_utils.run(webpages_playback_cmd) | 66 shell_utils.run(webpages_playback_cmd) |
67 finally: | 67 finally: |
68 # Clean up any leftover browser instances. This can happen if there are | 68 # Clean up any leftover browser instances. This can happen if there are |
69 # telemetry crashes, processes are not always cleaned up appropriately by | 69 # telemetry crashes, processes are not always cleaned up appropriately by |
70 # the webpagereplay and telemetry frameworks. | 70 # the webpagereplay and telemetry frameworks. |
71 procs = subprocess.check_output(['ps', 'ax']) | 71 procs = subprocess.check_output(['ps', 'ax']) |
72 for line in procs.splitlines(): | 72 for line in procs.splitlines(): |
73 if browser_executable in line: | 73 if browser_executable in line: |
74 pid = line.strip().split(' ')[0] | 74 pid = line.strip().split(' ')[0] |
75 if pid != str(os.getpid()): | 75 if pid != str(os.getpid()) and not 'python' in line: |
76 try: | 76 try: |
77 shell_utils.run(['kill', '-9', pid]) | 77 shell_utils.run(['kill', '-9', pid]) |
78 except shell_utils.CommandFailedException as e: | 78 except shell_utils.CommandFailedException as e: |
79 print e | 79 print e |
80 else: | 80 else: |
81 print 'Refusing to kill self.' | 81 print 'Refusing to kill self.' |
82 | 82 |
83 print 'writing %s: %s' % (SKP_VERSION_FILE, skp_version) | 83 print 'writing %s: %s' % (SKP_VERSION_FILE, skp_version) |
84 with open(SKP_VERSION_FILE, 'w') as f: | 84 with open(SKP_VERSION_FILE, 'w') as f: |
85 f.write(str(skp_version)) | 85 f.write(str(skp_version)) |
86 | 86 |
87 | 87 |
88 if '__main__' == __name__: | 88 if '__main__' == __name__: |
89 if len(sys.argv) != 3: | 89 if len(sys.argv) != 3: |
90 print >> sys.stderr, 'USAGE: %s <chrome src path> <browser executable>' | 90 print >> sys.stderr, 'USAGE: %s <chrome src path> <browser executable>' |
91 sys.exit(1) | 91 sys.exit(1) |
92 main(*sys.argv[1:]) | 92 main(*sys.argv[1:]) |
OLD | NEW |