Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: tools/dom/scripts/multiemitter.py

Issue 18534002: Adding debug information to multiemitter.py (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import subprocess
10 import emitter 12 import emitter
11 import logging 13 import logging
12 14
13 _logger = logging.getLogger('multiemitter') 15 _logger = logging.getLogger('multiemitter')
14 16
15 class MultiEmitter(object): 17 class MultiEmitter(object):
16 """A set of Emitters that write to different files. 18 """A set of Emitters that write to different files.
17 19
18 Each entry has a key. 20 Each entry has a key.
19 21
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 emitter = self._filename_to_emitter[file] 67 emitter = self._filename_to_emitter[file]
66 writer(file, emitter.Fragments()) 68 writer(file, emitter.Fragments())
67 69
68 70
69 def _WriteFile(path, lines): 71 def _WriteFile(path, lines):
70 (dir, file) = os.path.split(path) 72 (dir, file) = os.path.split(path)
71 73
72 # Ensure dir exists. 74 # Ensure dir exists.
73 if dir: 75 if dir:
74 if not os.path.isdir(dir): 76 if not os.path.isdir(dir):
77 _logger.info('Mkdir - %s' % dir)
75 os.makedirs(dir) 78 os.makedirs(dir)
76 79
77 # Remove file if pre-existing. 80 # Remove file if pre-existing.
78 if os.path.exists(path): 81 if os.path.exists(path):
82 _logger.info('Removing - %s' % path)
79 os.remove(path) 83 os.remove(path)
80 84
81 # Write the file. 85 # Write the file.
82 # _logger.info('Flushing - %s' % path) 86 try:
83 f = open(path, 'w') 87 _logger.info('Writing - %s' % path)
84 f.writelines(lines) 88 f = open(path, 'w')
85 f.close() 89 f.writelines(lines)
90 f.close()
91 except OSError as error:
92 # FIXME(kustermann): Remove this later on.
93 # 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.
95 # (hypothesis: Another process has already opened the file.)
96 _logger.info('Got exception (%s) ' % error)
97
98 if sys.platform == 'win32':
99 handle_file = r'E:\handle.exe'
100 if os.path.exists(handle_file):
101 _logger.info('Running handle.exe for debugging purposes')
102 subprocess.call([handle_file])
103 else:
104 _logger.info("Couldn't find %s. Not printing open handles."
105 % handle_file)
106 raise error
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698