| Index: client/example/3_swarming_trigger_collect.py
|
| diff --git a/client/example/3_swarming_trigger_collect.py b/client/example/3_swarming_trigger_collect.py
|
| index 75b7a3bea0af6b255212a7fed2771cee6a77288d..99c735fd1262766a89c69f67095e9d172b6ad0aa 100755
|
| --- a/client/example/3_swarming_trigger_collect.py
|
| +++ b/client/example/3_swarming_trigger_collect.py
|
| @@ -8,9 +8,11 @@ slave.
|
|
|
| It compiles and archives via 'isolate.py archive', then discard the local files.
|
| After, it triggers and finally collects the results.
|
| +
|
| +Creates 2 shards and instructs the script to produce a file in the output
|
| +directory.
|
| """
|
|
|
| -import hashlib
|
| import os
|
| import shutil
|
| import subprocess
|
| @@ -27,24 +29,8 @@ def main():
|
| try:
|
| tempdir = tempfile.mkdtemp(prefix=u'hello_world')
|
| try:
|
| - # All the files are put in a temporary directory. This is optional and
|
| - # simply done so the current directory doesn't have the following files
|
| - # created:
|
| - # - hello_world.isolated
|
| - # - hello_world.isolated.state
|
| - isolated = os.path.join(tempdir, 'hello_world.isolated')
|
| - common.note('Archiving to %s' % options.isolate_server)
|
| - common.run(
|
| - [
|
| - 'isolate.py',
|
| - 'archive',
|
| - '--isolate', os.path.join('payload', 'hello_world.isolate'),
|
| - '--isolated', isolated,
|
| - '--isolate-server', options.isolate_server,
|
| - '--config-variable', 'OS', options.swarming_os,
|
| - ], options.verbose)
|
| - with open(isolated, 'rb') as f:
|
| - hashval = hashlib.sha1(f.read()).hexdigest()
|
| + _, hashval = common.isolate(
|
| + tempdir, options.isolate_server, options.swarming_os, options.verbose)
|
|
|
| json_file = os.path.join(tempdir, 'task.json')
|
| common.note('Running on %s' % options.swarming)
|
| @@ -57,11 +43,13 @@ def main():
|
| '--task-name', options.task_name,
|
| '--dump-json', json_file,
|
| '--isolated', hashval,
|
| + '--shards', '2',
|
| ]
|
| if options.idempotent:
|
| cmd.append('--idempotent')
|
| if options.priority is not None:
|
| cmd.extend(('--priority', str(options.priority)))
|
| + cmd.extend(('--', '${ISOLATED_OUTDIR}'))
|
| common.run(cmd, options.verbose)
|
|
|
| common.note('Getting results from %s' % options.swarming)
|
| @@ -71,12 +59,19 @@ def main():
|
| 'collect',
|
| '--swarming', options.swarming,
|
| '--json', json_file,
|
| + '--task-output-dir', 'example_result',
|
| ], options.verbose)
|
| + for root, _, files in os.walk('example_result'):
|
| + for name in files:
|
| + p = os.path.join(root, name)
|
| + with open(p, 'rb') as f:
|
| + print('%s content:' % p)
|
| + print(f.read())
|
| return 0
|
| finally:
|
| shutil.rmtree(tempdir)
|
| except subprocess.CalledProcessError as e:
|
| - print e.returncode or 1
|
| + return e.returncode
|
|
|
|
|
| if __name__ == '__main__':
|
|
|