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 a manually crafted hello_world.isolated, remotely
9 No .isolate file is involved at all.
11 It creates hello_world.isolated and archives via 'isolateserver.py archive',
12 then trigger and finally collect the results.
14 It never create a local file.
23 # Pylint can't find common.py that's in the same directory as this file.
24 # pylint: disable=F0401
29 options = common.parse_args(use_isolate_server=True, use_swarming=True)
32 'Archiving directory \'payload\' to %s' % options.isolate_server)
33 payload_isolated_sha1 = common.capture(
37 '--isolate-server', options.isolate_server,
42 'Archiving custom .isolated file to %s' % options.isolate_server)
43 handle, isolated = tempfile.mkstemp(
44 prefix='hello_world', suffix='.isolated')
49 'command': ['python', 'hello_world.py', 'Custom'],
50 'includes': [payload_isolated_sha1],
53 with open(isolated, 'wb') as f:
54 json.dump(data, f, sort_keys=True, separators=(',',':'))
55 isolated_sha1 = common.capture(
59 '--isolate-server', options.isolate_server,
63 common.note('Deleting temporary file, it is not necessary anymore.')
66 # Now trigger as usual. You could look at run_exmaple_swarming_involved for
67 # the involved way but use the short way here.
69 common.note('Running %s on %s' % (isolated_sha1, options.swarming))
73 '--swarming', options.swarming,
74 '--isolate-server', options.isolate_server,
75 '--dimension', 'os', options.swarming_os,
76 '--task-name', options.task_name,
79 if options.priority is not None:
80 cmd.extend(('--priority', str(options.priority)))
81 common.run(cmd, options.verbose)
83 except subprocess.CalledProcessError as e:
84 print e.returncode or 1
87 if __name__ == '__main__':