Example #1
0
File: db.py Project: genba/smiley
 def trace(self, run_id, call_id, event,
           func_name, line_no, filename,
           trace_arg, local_vars,
           timestamp):
     "Record an event during a run."
     # LOG.debug('trace(filename=%s)', filename)
     with transaction(self.conn) as c:
         c.execute(
             u"""
             INSERT INTO trace
             (run_id, call_id, event,
              func_name, line_no, filename,
              trace_arg, local_vars,
              timestamp)
             VALUES
             (:run_id, :call_id, :event,
              :func_name, :line_no, :filename,
              :trace_arg, :local_vars,
              :timestamp)
             """,
             {'run_id': run_id,
              'call_id': call_id,
              'event': event,
              'func_name': func_name,
              'line_no': line_no,
              'filename': filename,
              'trace_arg': jsonutil.dumps(trace_arg),
              'local_vars': jsonutil.dumps(local_vars),
              'timestamp': timestamp,
              }
         )
 def trace(self, run_id, thread_id, call_id, event,
           func_name, line_no, filename,
           trace_arg, local_vars,
           timestamp):
     "Record an event during a run."
     # LOG.debug('trace(filename=%s)', filename)
     with transaction(self.conn) as c:
         c.execute(
             u"""
             INSERT INTO trace
             (run_id, thread_id, call_id, event,
              func_name, line_no, filename,
              trace_arg, local_vars,
              timestamp)
             VALUES
             (:run_id, :thread_id, :call_id, :event,
              :func_name, :line_no, :filename,
              :trace_arg, :local_vars,
              :timestamp)
             """,
             {'run_id': run_id,
              'thread_id': thread_id,
              'call_id': call_id,
              'event': event,
              'func_name': func_name,
              'line_no': line_no,
              'filename': filename,
              'trace_arg': jsonutil.dumps(trace_arg),
              'local_vars': jsonutil.dumps(local_vars),
              'timestamp': timestamp,
              }
         )
Example #3
0
File: db.py Project: genba/smiley
 def start_run(self, run_id, cwd, description, start_time):
     "Record the beginning of a run."
     with transaction(self.conn) as c:
         c.execute(
             u"""
             INSERT INTO run (id, cwd, description, start_time)
             VALUES (:id, :cwd, :description, :start_time)
             """,
             {'id': run_id,
              'cwd': cwd,
              'description': jsonutil.dumps(description),
              'start_time': start_time}
         )
Example #4
0
 def start_run(self, run_id, cwd, description, start_time):
     "Record the beginning of a run."
     with transaction(self.conn) as c:
         c.execute(
             """
             INSERT INTO run (id, cwd, description, start_time)
             VALUES (:id, :cwd, :description, :start_time)
             """, {
                 'id': run_id,
                 'cwd': cwd,
                 'description': jsonutil.dumps(description),
                 'start_time': start_time
             })
Example #5
0
 def _send(self, msg_type, data):
     old_trace = None
     try:
         old_trace = sys.gettrace()
         sys.settrace(None)
         msg = [
             msg_type,
             jsonutil.dumps(data),
         ]
         LOG.debug('SENDING: %r', msg)
         self.pub_socket.send_multipart(msg)
     finally:
         if old_trace is not None:
             sys.settrace(old_trace)
Example #6
0
 def _send(self, msg_type, data):
     old_trace = None
     try:
         old_trace = sys.gettrace()
         sys.settrace(None)
         msg = [
             msg_type,
             jsonutil.dumps(data),
         ]
         LOG.debug('SENDING: %r', msg)
         self.pub_socket.send_multipart(msg)
     finally:
         if old_trace is not None:
             sys.settrace(old_trace)
Example #7
0
 def end_run(self, run_id, end_time, message, traceback):
     "Record the end of a run."
     with transaction(self.conn) as c:
         c.execute(
             """
             UPDATE run
             SET
                 end_time = :end_time,
                 error_message = :message,
                 traceback = :traceback
             WHERE id = :id
             """,
             {'id': run_id,
              'end_time': end_time,
              'message': message,
              'traceback': jsonutil.dumps(traceback)},
         )
Example #8
0
 def _send(self, msg_type, data):
     # FIXME: Need to replace the thread trace func, too?
     # FIXME: Need to disable the profiler?
     old_trace = None
     try:
         old_trace = sys.gettrace()
         sys.settrace(None)
         msg = [
             m.encode('utf-8') for m in [
                 msg_type,
                 jsonutil.dumps(data),
             ]
         ]
         LOG.debug('SENDING: %r', msg)
         self.pub_socket.send_multipart(msg)
     finally:
         if old_trace is not None:
             sys.settrace(old_trace)
 def start_run(self, run_id, cwd, description, start_time):
     "Record the beginning of a run."
     # LOG.debug('start_run(%s)', run_id)
     with transaction(self.conn) as c:
         try:
             c.execute(
                 u"""
                 INSERT INTO run (id, cwd, description, start_time)
                 VALUES (:id, :cwd, :description, :start_time)
                 """,
                 {'id': run_id,
                  'cwd': cwd,
                  'description': jsonutil.dumps(description),
                  'start_time': start_time}
             )
         except sqlite3.IntegrityError:
             raise ValueError('There is already a run with id %s in %s' % (
                 run_id, self._name))
Example #10
0
File: db.py Project: genba/smiley
 def end_run(self, run_id, end_time, message, traceback, stats):
     "Record the end of a run."
     with transaction(self.conn) as c:
         c.execute(
             u"""
             UPDATE run
             SET
                 end_time = :end_time,
                 error_message = :message,
                 traceback = :traceback,
                 stats = :stats
             WHERE id = :id
             """,
             {'id': run_id,
              'end_time': end_time,
              'message': message,
              'traceback': jsonutil.dumps(traceback),
              'stats': base64.b64encode(stats) if stats else None},
         )
Example #11
0
 def _send(self, msg_type, data):
     # FIXME: Need to replace the thread trace func, too?
     # FIXME: Need to disable the profiler?
     old_trace = None
     try:
         old_trace = sys.gettrace()
         sys.settrace(None)
         msg = [
             m.encode('utf-8')
             for m in [
                 msg_type,
                 jsonutil.dumps(data),
             ]
         ]
         LOG.debug('SENDING: %r', msg)
         self.pub_socket.send_multipart(msg)
     finally:
         if old_trace is not None:
             sys.settrace(old_trace)
 def end_run(self, run_id, end_time, message, traceback, stats):
     "Record the end of a run."
     # LOG.debug('end_run(%s)', run_id)
     with transaction(self.conn) as c:
         c.execute(
             u"""
             UPDATE run
             SET
                 end_time = :end_time,
                 error_message = :message,
                 traceback = :traceback,
                 stats = :stats
             WHERE id = :id
             """,
             {'id': run_id,
              'end_time': end_time,
              'message': message,
              'traceback': jsonutil.dumps(traceback),
              'stats': stats or None}
         )
Example #13
0
 def end_run(self, run_id, end_time, message, traceback, stats):
     "Record the end of a run."
     with transaction(self.conn) as c:
         c.execute(
             """
             UPDATE run
             SET
                 end_time = :end_time,
                 error_message = :message,
                 traceback = :traceback,
                 stats = :stats
             WHERE id = :id
             """,
             {
                 'id': run_id,
                 'end_time': end_time,
                 'message': message,
                 'traceback': jsonutil.dumps(traceback),
                 'stats': base64.b64encode(stats) if stats else None
             },
         )