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

Side by Side Diff: appengine/swarming/swarming_bot/__main__.py

Issue 2496803002: swarming: Reload the google py library after initializing a bot's path. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Runs either task_runner.py, bot_main.py or bot_config.py. 5 """Runs either task_runner.py, bot_main.py or bot_config.py.
6 6
7 The imports are done late so if an ImportError occurs, it is localized to this 7 The imports are done late so if an ImportError occurs, it is localized to this
8 command only. 8 command only.
9 """ 9 """
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 # libusb1 expects to be directly in sys.path. 29 # libusb1 expects to be directly in sys.path.
30 sys.path.insert(0, os.path.join(THIS_FILE, 'python_libusb1')) 30 sys.path.insert(0, os.path.join(THIS_FILE, 'python_libusb1'))
31 31
32 # Copied from //client/utils/oauth.py. 32 # Copied from //client/utils/oauth.py.
33 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party')) 33 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party'))
34 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'pyasn1')) 34 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'pyasn1'))
35 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'pyasn1-modules')) 35 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'pyasn1-modules'))
36 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'rsa')) 36 sys.path.insert(0, os.path.join(THIS_FILE, 'third_party', 'rsa'))
37 37
38 # The google library can occasionally get imported prior to the path
39 # maipulation above. If this happens, reload the module to pick up the version
40 # packaged in the bot_code in third_party.
41 path_to_zip = os.path.dirname(os.path.realpath(__file__))
42 path_to_google = os.path.join(path_to_zip, 'third_party', 'google')
43 import google
44 if google.__path__[0] != path_to_google:
45 google = reload(google)
46
38 from bot_code import common 47 from bot_code import common
39 48
40 49
41 # TODO(maruel): Use depot_tools/subcommand.py. The goal here is to have all the 50 # TODO(maruel): Use depot_tools/subcommand.py. The goal here is to have all the
42 # sub commands packed into the single .zip file as a swiss army knife (think 51 # sub commands packed into the single .zip file as a swiss army knife (think
43 # busybox but worse). 52 # busybox but worse).
44 53
45 54
46 def CMDattributes(_args): 55 def CMDattributes(_args):
47 """Prints out the bot's attributes.""" 56 """Prints out the bot's attributes."""
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 with zipfile.ZipFile(THIS_FILE, 'r') as f: 248 with zipfile.ZipFile(THIS_FILE, 'r') as f:
240 logging.error('Files in %s:\n%s', THIS_FILE, f.namelist()) 249 logging.error('Files in %s:\n%s', THIS_FILE, f.namelist())
241 return 1 250 return 1
242 251
243 print >> sys.stderr, 'Unknown command %s' % cmd 252 print >> sys.stderr, 'Unknown command %s' % cmd
244 return 1 253 return 1
245 254
246 255
247 if __name__ == '__main__': 256 if __name__ == '__main__':
248 sys.exit(main()) 257 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698