| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import imp |
| 6 import os | 7 import os |
| 7 import sys | 8 import sys |
| 8 | 9 |
| 9 HOME = os.path.dirname(os.path.realpath(__file__)) | 10 def main(args): |
| 10 # TODO(ngeoffray): does not work on Windows. | 11 # Try to find frog.py from the current location. |
| 11 HOME = os.path.join(HOME, os.pardir, os.pardir) | 12 home = os.path.join(os.curdir, 'frog.py') |
| 13 if not os.path.exists(home): |
| 14 home = os.path.join(os.curdir, 'frog', 'frog.py') |
| 12 | 15 |
| 13 sys.path.append(HOME) | 16 if not os.path.exists(home): |
| 14 import frog | 17 print "Could not find frog" |
| 18 return 1 |
| 15 | 19 |
| 16 def main(args): | 20 filename = None |
| 17 return frog.main(args) | 21 exit_code = 1 |
| 22 try: |
| 23 # Load frog.py and invoke it. |
| 24 paths = [os.path.dirname(home)] |
| 25 (filename, pathname, description) = imp.find_module('frog', paths) |
| 26 module = imp.load_module('frog', filename, pathname, description) |
| 27 exit_code = module.main(args) |
| 28 finally: |
| 29 if filename: |
| 30 filename.close() |
| 31 |
| 32 return exit_code |
| 18 | 33 |
| 19 | 34 |
| 20 if __name__ == '__main__': | 35 if __name__ == '__main__': |
| 21 sys.exit(main(sys.argv)) | 36 sys.exit(main(sys.argv)) |
| OLD | NEW |