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

Side by Side Diff: appengine/swarming/tools/start_bot.py

Issue 2636993002: swarming: Fix named cache support. (Closed)
Patch Set: Fix swarming_test.py Created 3 years, 11 months 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
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | client/named_cache.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The LUCI Authors. All rights reserved. 2 # Copyright 2015 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Starts a local bot to connect to a local server.""" 6 """Starts a local bot to connect to a local server."""
7 7
8 import glob 8 import glob
9 import logging
9 import os 10 import os
10 import signal 11 import signal
11 import socket 12 import socket
12 import sys 13 import sys
13 import tempfile 14 import tempfile
14 import urllib 15 import urllib
15 16
16 17
17 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) 18 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
18 CLIENT_DIR = os.path.join(THIS_DIR, '..', '..', '..', 'client') 19 CLIENT_DIR = os.path.join(THIS_DIR, '..', '..', '..', 'client')
(...skipping 12 matching lines...) Expand all
31 """ 32 """
32 def __init__(self, swarming_server_url, redirect=True): 33 def __init__(self, swarming_server_url, redirect=True):
33 self._tmpdir = tempfile.mkdtemp(prefix='swarming_bot') 34 self._tmpdir = tempfile.mkdtemp(prefix='swarming_bot')
34 self._swarming_server_url = swarming_server_url 35 self._swarming_server_url = swarming_server_url
35 self._proc = None 36 self._proc = None
36 self._logs = {} 37 self._logs = {}
37 self._redirect = redirect 38 self._redirect = redirect
38 39
39 def wipe_cache(self): 40 def wipe_cache(self):
40 """Blows away this bot's cache.""" 41 """Blows away this bot's cache."""
41 cache_dir = os.path.join(self._tmpdir, 'isolated_cache') 42 for i in ('c', 'isolated_cache'):
42 if os.path.exists(cache_dir): 43 cache_dir = os.path.join(self._tmpdir, i)
43 try: 44 if os.path.exists(cache_dir):
44 file_path.rmtree(cache_dir) 45 try:
45 except OSError: 46 file_path.rmtree(cache_dir)
46 pass 47 except OSError:
48 logging.info('Failed to deleted %s', cache_dir)
47 49
48 @property 50 @property
49 def bot_id(self): 51 def bot_id(self):
50 # TODO(maruel): Big assumption. 52 # TODO(maruel): Big assumption.
51 return socket.getfqdn().split('.')[0] 53 return socket.getfqdn().split('.')[0]
52 54
53 @property 55 @property
54 def log(self): 56 def log(self):
55 """Returns the log output. Only set after calling stop().""" 57 """Returns the log output. Only set after calling stop()."""
56 return '\n'.join(self._logs.itervalues()) if self._logs else None 58 return '\n'.join(self._logs.itervalues()) if self._logs else None
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 bot.dump_log() 144 bot.dump_log()
143 except KeyboardInterrupt: 145 except KeyboardInterrupt:
144 print >> sys.stderr, '<Ctrl-C> received; stopping bot' 146 print >> sys.stderr, '<Ctrl-C> received; stopping bot'
145 finally: 147 finally:
146 exit_code = bot.stop(False) 148 exit_code = bot.stop(False)
147 return exit_code 149 return exit_code
148 150
149 151
150 if __name__ == '__main__': 152 if __name__ == '__main__':
151 sys.exit(main()) 153 sys.exit(main())
OLDNEW
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | client/named_cache.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698