Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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' | |
|
diandersAtChromium
2011/02/09 19:46:01
Simon: can you give me an example of the error str
| |
| 62 if str(e) [-10:] != 'shell.main': | |
| 63 raise | |
| 64 | |
| 58 # We've got different modules named chromite in the tree, pulling in the | 65 # We've got different modules named chromite in the tree, pulling in the |
| 59 # wrong one will break the right one. So unload it. | 66 # wrong one will break the right one. So unload it. |
| 60 if 'chromite' in sys.modules: | 67 if 'chromite' in sys.modules: |
| 61 del sys.modules['chromite'] | 68 del sys.modules['chromite'] |
| 62 sys.path = sys.path[len(path):] | 69 sys.path = sys.path[len(path):] |
| 63 else: | 70 else: |
| 64 # TODO(dianders): Should we actually print out the 'repo init' call that | 71 # TODO(dianders): Should we actually print out the 'repo init' call that |
| 65 # the user should use? | 72 # the user should use? |
| 66 sys.stderr.write( | 73 sys.stderr.write( |
| 67 "ERROR: Couldn't find the chromite tool.\n" | 74 "ERROR: Couldn't find the chromite tool.\n" |
| 68 "\n" | 75 "\n" |
| 69 "Please change to a directory inside your Chromium OS source tree\n" | 76 "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" | 77 "and retry. If you need to setup a Chromium OS source tree, see:\n" |
| 71 " http://www.chromium.org/chromium-os/developer-guide\n") | 78 " http://www.chromium.org/chromium-os/developer-guide\n") |
| 72 sys.exit(1) | 79 sys.exit(1) |
| 73 | 80 |
| 74 chromite.shell.main.main() | 81 chromite.shell.main.main() |
| OLD | NEW |