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

Side by Side Diff: chromite

Issue 6487003: Update to chromite wrapper to properly report import errors.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
« 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Wrapper for the chromite shell. 6 """Wrapper for the chromite shell.
7 7
8 This script is intended to run in several ways: 8 This script is intended to run in several ways:
9 - Outside the chroot, it should be _copied_ to someplace that is in the 9 - Outside the chroot, it should be _copied_ to someplace that is in the
10 path (like depot_tools). It will search for the right chromite by looking 10 path (like depot_tools). It will search for the right chromite by looking
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 yield [path] 48 yield [path]
49 path, prev_path = os.path.dirname(path), path 49 path, prev_path = os.path.dirname(path), path
50 50
51 51
52 for path in Search(os.getcwd()): 52 for path in Search(os.getcwd()):
53 sys.path = path + sys.path 53 sys.path = path + sys.path
54 try: 54 try:
55 import chromite.shell.main 55 import chromite.shell.main
56 break 56 break
57 except ImportError, e: 57 except ImportError, e:
58 # Just in case there is actually something wrong with Chromite, print
59 # a sensible error. We match only the end of the string so that we can
60 # handle an error within the chromite directory.
61 # The full error is 'No module named (chromite.)shell.main'
62 # Note: If you hit the directory containing chromite on the way up, then
63 # the error will be 'No module named shell.main' so we must check only the
64 # shell.main part.
65 if not str(e).endswith('shell.main'):
66 raise
67
58 # We've got different modules named chromite in the tree, pulling in the 68 # We've got different modules named chromite in the tree, pulling in the
59 # wrong one will break the right one. So unload it. 69 # wrong one will break the right one. So unload it.
60 if 'chromite' in sys.modules: 70 if 'chromite' in sys.modules:
61 del sys.modules['chromite'] 71 del sys.modules['chromite']
62 sys.path = sys.path[len(path):] 72 sys.path = sys.path[len(path):]
63 else: 73 else:
64 # TODO(dianders): Should we actually print out the 'repo init' call that 74 # TODO(dianders): Should we actually print out the 'repo init' call that
65 # the user should use? 75 # the user should use?
66 sys.stderr.write( 76 sys.stderr.write(
67 "ERROR: Couldn't find the chromite tool.\n" 77 "ERROR: Couldn't find the chromite tool.\n"
68 "\n" 78 "\n"
69 "Please change to a directory inside your Chromium OS source tree\n" 79 "Please change to a directory inside your Chromium OS source tree\n"
70 "and retry. If you need to setup a Chromium OS source tree, see:\n" 80 "and retry. If you need to setup a Chromium OS source tree, see:\n"
71 " http://www.chromium.org/chromium-os/developer-guide\n") 81 " http://www.chromium.org/chromium-os/developer-guide\n")
72 sys.exit(1) 82 sys.exit(1)
73 83
74 chromite.shell.main.main() 84 chromite.shell.main.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