| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import errno | 7 import errno |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import Queue | 10 import Queue |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 if not subpath.startswith(root): | 425 if not subpath.startswith(root): |
| 426 return None | 426 return None |
| 427 # If the root does not have a trailing \ or /, we add it so the returned | 427 # If the root does not have a trailing \ or /, we add it so the returned |
| 428 # path starts immediately after the seperator regardless of whether it is | 428 # path starts immediately after the seperator regardless of whether it is |
| 429 # provided. | 429 # provided. |
| 430 root = os.path.join(root, '') | 430 root = os.path.join(root, '') |
| 431 return subpath[len(root):] | 431 return subpath[len(root):] |
| 432 | 432 |
| 433 | 433 |
| 434 def FindFileUpwards(filename, path=None): | 434 def FindFileUpwards(filename, path=None): |
| 435 """Search upwards from the a directory (default: current) to find a file.""" | 435 """Search upwards from the a directory (default: current) to find a file. |
| 436 |
| 437 Returns nearest upper-level directory with the passed in file. |
| 438 """ |
| 436 if not path: | 439 if not path: |
| 437 path = os.getcwd() | 440 path = os.getcwd() |
| 438 path = os.path.realpath(path) | 441 path = os.path.realpath(path) |
| 439 while True: | 442 while True: |
| 440 file_path = os.path.join(path, filename) | 443 file_path = os.path.join(path, filename) |
| 441 if os.path.isfile(file_path): | 444 if os.path.exists(file_path): |
| 442 return file_path | 445 return path |
| 443 (new_path, _) = os.path.split(path) | 446 (new_path, _) = os.path.split(path) |
| 444 if new_path == path: | 447 if new_path == path: |
| 445 return None | 448 return None |
| 446 path = new_path | 449 path = new_path |
| 447 | 450 |
| 448 | 451 |
| 449 def GetGClientRootAndEntries(path=None): | 452 def GetGClientRootAndEntries(path=None): |
| 450 """Returns the gclient root and the dict of entries.""" | 453 """Returns the gclient root and the dict of entries.""" |
| 451 config_file = '.gclient_entries' | 454 config_file = '.gclient_entries' |
| 452 config_path = FindFileUpwards(config_file, path) | 455 config_path = os.path.join(FindFileUpwards(config_file, path), config_file) |
| 453 | 456 |
| 454 if not config_path: | 457 if not config_path: |
| 455 print "Can't find %s" % config_file | 458 print "Can't find %s" % config_file |
| 456 return None | 459 return None |
| 457 | 460 |
| 458 env = {} | 461 env = {} |
| 459 execfile(config_path, env) | 462 execfile(config_path, env) |
| 460 config_dir = os.path.dirname(config_path) | 463 config_dir = os.path.dirname(config_path) |
| 461 return config_dir, env['entries'] | 464 return config_dir, env['entries'] |
| 462 | 465 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 logging.info('Caught exception in thread %s' % self.item.name) | 661 logging.info('Caught exception in thread %s' % self.item.name) |
| 659 logging.info(str(sys.exc_info())) | 662 logging.info(str(sys.exc_info())) |
| 660 work_queue.exceptions.put(sys.exc_info()) | 663 work_queue.exceptions.put(sys.exc_info()) |
| 661 logging.info('_Worker.run(%s) done' % self.item.name) | 664 logging.info('_Worker.run(%s) done' % self.item.name) |
| 662 | 665 |
| 663 work_queue.ready_cond.acquire() | 666 work_queue.ready_cond.acquire() |
| 664 try: | 667 try: |
| 665 work_queue.ready_cond.notifyAll() | 668 work_queue.ready_cond.notifyAll() |
| 666 finally: | 669 finally: |
| 667 work_queue.ready_cond.release() | 670 work_queue.ready_cond.release() |
| OLD | NEW |