Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: swarm_client/example/run_example_local.py

Issue 69143004: Delete swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swarm_client/example/run_example_cad.py ('k') | swarm_client/example/run_example_swarm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """Runs hello_world.py, through hello_world.isolate, locally in a temporary
7 directory.
8 """
9
10 import hashlib
11 import optparse
12 import os
13 import shutil
14 import subprocess
15 import sys
16 import tempfile
17
18 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
19
20
21 def run(cmd):
22 print('Running: %s' % ' '.join(cmd))
23 cmd = [sys.executable, os.path.join(ROOT_DIR, '..', cmd[0])] + cmd[1:]
24 if sys.platform != 'win32':
25 cmd = ['time', '-p'] + cmd
26 subprocess.check_call(cmd)
27
28
29 def main():
30 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
31 parser.add_option('-v', '--verbose', action='count', default=0)
32 options, args = parser.parse_args()
33 if args:
34 parser.error('Unsupported argument %s' % args)
35
36 os.environ['ISOLATE_DEBUG'] = str(options.verbose)
37
38 try:
39 # All the files are put in a temporary directory. This is optional and
40 # simply done so the current directory doesn't have the following files
41 # created:
42 # - hello_world.isolated
43 # - hello_world.isolated.state
44 # - cache/
45 # - hashtable/
46 tempdir = tempfile.mkdtemp(prefix='hello_world')
47 cachedir = os.path.join(tempdir, 'cache')
48 hashtabledir = os.path.join(tempdir, 'hashtable')
49 isolateddir = os.path.join(tempdir, 'isolated')
50 isolated = os.path.join(isolateddir, 'hello_world.isolated')
51
52 os.mkdir(isolateddir)
53
54 print('Archiving')
55 run(
56 [
57 'isolate.py',
58 'archive',
59 '--isolate', os.path.join(ROOT_DIR, 'hello_world.isolate'),
60 '--isolated', isolated,
61 '--outdir', hashtabledir,
62 ])
63
64 print('\nRunning')
65 hashval = hashlib.sha1(open(isolated, 'rb').read()).hexdigest()
66 run(
67 [
68 'run_isolated.py',
69 '--cache', cachedir,
70 '--isolate-server', hashtabledir,
71 '--hash', hashval,
72 '--no-log',
73 ])
74 return 0
75 except subprocess.CalledProcessError as e:
76 return e.returncode
77 finally:
78 shutil.rmtree(tempdir)
79
80
81 if __name__ == '__main__':
82 sys.exit(main())
OLDNEW
« no previous file with comments | « swarm_client/example/run_example_cad.py ('k') | swarm_client/example/run_example_swarm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698