| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # run_slavelastic.py: Runs a test based off of a slavelastic manifest file. | 5 # run_slavelastic.py: Runs a test based off of a slavelastic manifest file. |
| 6 | 6 |
| 7 from __future__ import with_statement | 7 from __future__ import with_statement |
| 8 import glob |
| 8 import json | 9 import json |
| 9 import optparse | 10 import optparse |
| 10 import os | 11 import os |
| 11 import socket | 12 import socket |
| 12 import shutil | |
| 13 import sys | 13 import sys |
| 14 import time | 14 import time |
| 15 import urllib | 15 import urllib |
| 16 import urllib2 | 16 import urllib2 |
| 17 import zipfile | 17 import zipfile |
| 18 | 18 |
| 19 | 19 |
| 20 DESCRIPTION = """This script takes a slavelastic manifest file, packages it, | 20 DESCRIPTION = """This script takes a slavelastic manifest file, packages it, |
| 21 and sends a swarm manifest file to the swarm server. This is expected to be | 21 and sends a swarm manifest file to the swarm server. This is expected to be |
| 22 called as a build step with the cwd as the parent of the src/ directory. | 22 called as a build step with the cwd as the parent of the src/ directory. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if not options.os_image: | 203 if not options.os_image: |
| 204 parser.error('Must specify an os image') | 204 parser.error('Must specify an os image') |
| 205 if not options.hashtable_dir: | 205 if not options.hashtable_dir: |
| 206 parser.error('Must specify the hashtable directory') | 206 parser.error('Must specify the hashtable directory') |
| 207 if not options.data_dest_dir: | 207 if not options.data_dest_dir: |
| 208 parser.error('Must specify the server directory') | 208 parser.error('Must specify the server directory') |
| 209 | 209 |
| 210 # Remove the old data if there is any | 210 # Remove the old data if there is any |
| 211 if os.path.isdir(options.data_dest_dir): | 211 if os.path.isdir(options.data_dest_dir): |
| 212 print 'Removing old swarm files...' | 212 print 'Removing old swarm files...' |
| 213 shutil.rmtree(options.data_dest_dir) | 213 for filename in glob.glob('swarm_tempfile_*.zip'): |
| 214 os.remove(filename) |
| 214 | 215 |
| 215 # Send off the swarm test requests. | 216 # Send off the swarm test requests. |
| 216 highest_exit_code = 0 | 217 highest_exit_code = 0 |
| 217 for filename in args: | 218 for filename in args: |
| 218 highest_exit_code = max(highest_exit_code, | 219 highest_exit_code = max(highest_exit_code, |
| 219 ProcessManifest(filename, options)) | 220 ProcessManifest(filename, options)) |
| 220 | 221 |
| 221 return highest_exit_code | 222 return highest_exit_code |
| 222 | 223 |
| 223 | 224 |
| 224 if __name__ == '__main__': | 225 if __name__ == '__main__': |
| 225 sys.exit(main()) | 226 sys.exit(main()) |
| OLD | NEW |