| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 """Templating to help generate structured text.""" | 6 """Templating to help generate structured text.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 # Ensure dir exists. | 74 # Ensure dir exists. |
| 75 if dir: | 75 if dir: |
| 76 if not os.path.isdir(dir): | 76 if not os.path.isdir(dir): |
| 77 _logger.info('Mkdir - %s' % dir) | 77 _logger.info('Mkdir - %s' % dir) |
| 78 os.makedirs(dir) | 78 os.makedirs(dir) |
| 79 | 79 |
| 80 # Remove file if pre-existing. | 80 # Remove file if pre-existing. |
| 81 if os.path.exists(path): | 81 if os.path.exists(path): |
| 82 _logger.info('Removing - %s' % path) | 82 _logger.info('Removing - %s' % path) |
| 83 os.remove(path) | 83 os.remove(path) |
| 84 if os.path.exists(path): |
| 85 _logger.info('Warning: File still exists- %s' % path) |
| 84 | 86 |
| 85 # Write the file. | 87 # Write the file. |
| 86 try: | 88 try: |
| 87 _logger.info('Writing - %s' % path) | 89 _logger.info('Writing - %s' % path) |
| 88 f = open(path, 'w') | 90 f = open(path, 'w') |
| 89 f.writelines(lines) | 91 f.writelines(lines) |
| 90 f.close() | 92 f.close() |
| 91 except IOError as error: | 93 except IOError as error: |
| 92 # FIXME(kustermann): Remove this later on. | 94 # FIXME(kustermann): Remove this later on. |
| 93 # We try to get more debugging information to figure out why we sometimes | 95 # We try to get more debugging information to figure out why we sometimes |
| 94 # get a "Permission denied" error when opening the file for writing. | 96 # get a "Permission denied" error when opening the file for writing. |
| 95 # (hypothesis: Another process has already opened the file.) | 97 # (hypothesis: Another process has already opened the file.) |
| 96 _logger.info('Got exception (%s) ' % error) | 98 _logger.info('Got exception (%s) ' % error) |
| 97 | 99 |
| 98 if sys.platform == 'win32': | 100 if sys.platform == 'win32': |
| 99 handle_file = r'E:\handle.exe' | 101 handle_file = r'E:\handle.exe' |
| 100 if os.path.exists(handle_file): | 102 if os.path.exists(handle_file): |
| 101 _logger.info('Running handle.exe for debugging purposes') | 103 _logger.info('Running handle.exe for debugging purposes') |
| 102 subprocess.call([handle_file]) | 104 subprocess.call([handle_file, '-a', r'E:\b\build\slave']) |
| 103 else: | 105 else: |
| 104 _logger.info("Couldn't find %s. Not printing open handles." | 106 _logger.info("Couldn't find %s. Not printing open handles." |
| 105 % handle_file) | 107 % handle_file) |
| 106 raise error | 108 raise error |
| OLD | NEW |