2 # Copyright 2012 The Swarming Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 that
4 # can be found in the LICENSE file.
6 """Runs hello_world.py, through hello_world.isolate, remotely on a Swarming
9 It first 'compiles' hello_world.isolate into hello_word.isolated, then requests
10 via swarming.py to archives, run and collect results for this task.
19 # Pylint can't find common.py that's in the same directory as this file.
20 # pylint: disable=F0401
25 options = common.parse_args(use_isolate_server=True, use_swarming=True)
26 tempdir = tempfile.mkdtemp(prefix='hello_world')
28 # All the files are put in a temporary directory. This is optional and
29 # simply done so the current directory doesn't have the following files
31 # - hello_world.isolated
32 # - hello_world.isolated.state
33 isolated = os.path.join(tempdir, 'hello_world.isolated')
36 'Creating hello_world.isolated. Note that this doesn\'t archives '
42 '--isolate', os.path.join('payload', 'hello_world.isolate'),
43 '--isolated', isolated,
44 '--config-variable', 'OS', options.swarming_os,
48 'Running the job remotely. This:\n'
50 ' - runs and collect results via %s' %
51 (options.isolate_server, options.swarming))
55 '--swarming', options.swarming,
56 '--isolate-server', options.isolate_server,
57 '--dimension', 'os', options.swarming_os,
58 '--task-name', options.task_name,
61 if options.priority is not None:
62 cmd.extend(('--priority', str(options.priority)))
63 common.run(cmd, options.verbose)
65 except subprocess.CalledProcessError as e:
68 shutil.rmtree(tempdir)
71 if __name__ == '__main__':