def take_action(self, parsed_args): self.db = db.DB(parsed_args.database) cache = db_linecache.DBLineCache(self.db, parsed_args.run_id) self.out = output.OutputFormatter(cache.getline) run_details = self.db.get_run(parsed_args.run_id) self.out.start_run( run_details.id, run_details.cwd, run_details.description, run_details.start_time, ) for t in self.db.get_trace(parsed_args.run_id): self.out.trace( t.run_id, t.event, t.func_name, t.line_no, t.filename, t.trace_arg, t.local_vars, t.timestamp, ) self.out.end_run( run_details.id, run_details.end_time, run_details.error_message, None, # run_details.traceback, )
def __init__(self, run_id, output_dir, database, title, per_page): self.run_id = run_id self.output_dir = output_dir self.db = database self.title = title self.per_page = per_page self.run_details = self.db.get_run(self.run_id) self.line_cache = db_linecache.DBLineCache(self.db, self.run_id) self.report_dir = os.path.dirname(__file__) self.template_dir = os.path.join(self.report_dir, 'templates') self.template_lookup = TemplateLookup(directories=[self.template_dir]) self.syntax_line_cache = syntax.StyledLineCache(self.db, self.run_id)
def setUp(self): super(DBFileCacheTest, self).setUp() self.useFixture(fixtures.FakeLogger()) self.db = db.DB(':memory:') self.db.start_run( '12345', '/no/such/dir', ['command', 'line', 'would', 'go', 'here'], 1370436103.65, ) self.db.cache_file_for_run( '12345', 'test-file.txt', 'this would be the body\nline two\nline three', ) self.cache = db_linecache.DBLineCache(self.db, '12345')
def setUp(self): super(DBFileCacheTest, self).setUp() self.useFixture(fixtures.FakeLogger()) self.db = db.DB(':memory:') self.db.start_run( '12345', '/no/such/dir', ['command', 'line', 'would', 'go', 'here'], 1370436103.65, ) self.db.cache_file_for_run( '12345', 'test-file.txt', 'this would be the body\nline two\nline three', ) self.db.cache_file_for_run( '12345', 'with-comments.txt', '\n'.join([ '# start comment', 'line two', '', ' # middle comment', '', 'end line', '# comment', 'last line', ]), ) self.db.cache_file_for_run( '12345', 'multi-line-comments.txt', '\n'.join([ '# start comment', '# comment line 2', 'non-comment 1', '', ' # middle comment', ' # middle comment line 2', '', 'middle line', '# last comment', '# last comment line 2', 'last line', ]), ) self.cache = db_linecache.DBLineCache(self.db, '12345')
def __init__(self, db, run_id): self._db = db self._run_id = run_id self._files = {} self._plain_line_cache = db_linecache.DBLineCache(db, run_id)