# HG changeset patch # User Nicolas Chauvat # Date 1238346409 -7200 # Node ID 6937dfb242fb89cd8d473a5a824f9535c59806d7 # Parent 450c435d69b940e4e3241cf2e92f3d8157ee0d13 [devtools] ExamineLog command does not fail on strange input and outputs to csv diff -r 450c435d69b9 -r 6937dfb242fb devtools/devctl.py --- a/devtools/devctl.py Fri Mar 27 12:27:43 2009 +0100 +++ b/devtools/devctl.py Sun Mar 29 19:06:49 2009 +0200 @@ -513,17 +513,20 @@ raise BadCommandUsage("no argument expected") import re requests = {} - for line in sys.stdin: + for lineno, line in enumerate(sys.stdin): if not ' WHERE ' in line: continue #sys.stderr.write( line ) - rql, time = line.split('--') - rql = re.sub("(\'\w+': \d*)", '', rql) - req = requests.setdefault(rql, []) - time.strip() - chunks = time.split() - cputime = float(chunks[-3]) - req.append( cputime ) + try: + rql, time = line.split('--') + rql = re.sub("(\'\w+': \d*)", '', rql) + req = requests.setdefault(rql, []) + time.strip() + chunks = time.split() + cputime = float(chunks[-3]) + req.append( cputime ) + except Exception, exc: + sys.stderr.write('Line %s: %s\n' % (lineno, exc)) stat = [] for rql, times in requests.items(): @@ -531,8 +534,9 @@ stat.sort() stat.reverse() + print 'Time ; Occurences ; Query' for time, occ, rql in stat: - print time, occ, rql + print time, ';', occ, ';', rql register_commands((UpdateCubicWebCatalogCommand, UpdateTemplateCatalogCommand,