OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 will never lack write permission on *path's parent. | 209 will never lack write permission on *path's parent. |
210 """ | 210 """ |
211 if not os.path.exists(path): | 211 if not os.path.exists(path): |
212 return | 212 return |
213 | 213 |
214 if os.path.islink(path) or not os.path.isdir(path): | 214 if os.path.islink(path) or not os.path.isdir(path): |
215 raise Error('Called rmtree(%s) in non-directory' % path) | 215 raise Error('Called rmtree(%s) in non-directory' % path) |
216 | 216 |
217 if sys.platform == 'win32': | 217 if sys.platform == 'win32': |
218 # Some people don't have the APIs installed. In that case we'll do without. | 218 # Some people don't have the APIs installed. In that case we'll do without. |
| 219 win32api = None |
| 220 win32con = None |
219 try: | 221 try: |
220 win32api = __import__('win32api') | 222 # Unable to import 'XX' |
221 win32con = __import__('win32con') | 223 # pylint: disable=F0401 |
| 224 import win32api, win32con |
222 except ImportError: | 225 except ImportError: |
223 pass | 226 pass |
224 else: | 227 else: |
225 # On POSIX systems, we need the x-bit set on the directory to access it, | 228 # On POSIX systems, we need the x-bit set on the directory to access it, |
226 # the r-bit to see its contents, and the w-bit to remove files from it. | 229 # the r-bit to see its contents, and the w-bit to remove files from it. |
227 # The actual modes of the files within the directory is irrelevant. | 230 # The actual modes of the files within the directory is irrelevant. |
228 os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) | 231 os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) |
229 | 232 |
230 def remove(func, subpath): | 233 def remove(func, subpath): |
231 if sys.platform == 'win32': | 234 if sys.platform == 'win32': |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 logging.info('Caught exception in thread %s' % self.item.name) | 703 logging.info('Caught exception in thread %s' % self.item.name) |
701 logging.info(str(sys.exc_info())) | 704 logging.info(str(sys.exc_info())) |
702 work_queue.exceptions.put(sys.exc_info()) | 705 work_queue.exceptions.put(sys.exc_info()) |
703 logging.info('Task %s done' % self.item.name) | 706 logging.info('Task %s done' % self.item.name) |
704 | 707 |
705 work_queue.ready_cond.acquire() | 708 work_queue.ready_cond.acquire() |
706 try: | 709 try: |
707 work_queue.ready_cond.notifyAll() | 710 work_queue.ready_cond.notifyAll() |
708 finally: | 711 finally: |
709 work_queue.ready_cond.release() | 712 work_queue.ready_cond.release() |
OLD | NEW |