Commits

Chris Perl committed 3075fcd

Still a work in progress

Comments (0)

Files changed (1)

 import subprocess
 import shlex
 import readline
+import traceback
 
 from datetime import datetime, timedelta
 from optparse import OptionParser, OptionValueError
         self.start = None
         self.end = None
 
-        self.cmd_map = {
+        self.aggr_map = {
             "topurls": TopUrls(self),
             "lquantize-timeofday": LinearQuantizeTimeOfDay(self),
         }
                 if not line or line.lstrip().rstrip() == '':
                     continue
 
-                # TODO: This splitting is not appropriate for all cases and causes exceptions, i.e.
-                # 'nocmd'
+                # TODO: This splitting is broken, i.e. nocmd causes exception
                 func, args = line.split(' ', 1)
                 if func.startswith('\\'):
                         # internal command, not for an aggregator
                             getattr(self, method)(*args.split(' '))
                             continue
 
-                for cmd in self.cmd_map.keys():
+                for cmd in self.aggr_map.keys():
                     if func.lower() == cmd:
-                        self.cmd_map[cmd](self.start, self.end, *args.split(' '))
+                        self.aggr_map[cmd](self.start, self.end, *args.split(' '))
                         break
                 else:
                     print "Unknown Command: %s" % line
-            except EOFError:
+
+            except EOFError, e:
+                print ""
                 break
 
+            except StandardError, e:
+                traceback.print_exc()
+                continue
+
     def parse_logfile(self, path):
         cmds = []
         if path.endswith(".gz"):
 
     def _set(self, what, arg):
         if what == "start":
-            self.start = datetime(*[ int(x) for x in arg.split('-') ])
+            self.start = datetime(*[ int(x) for x in re.split('[-:]', arg)])
         elif what == "end":
-            self.end = datetime(*[int(x) for x in arg.split('-')])
+            self.end = datetime(*[int(x) for x in re.split('[-:]', arg)])
         else:
             pass