6 from datetime
import datetime
28 default_context_padding,
58 cols =
'name input_filename wav_filename num_segs default_context_padding test_index completed pick_randomly'.split()
62 last_ids = db.insert(
'checks', cols, [row])
63 self.
db_id = last_ids[0]
67 if cur_filter.db_id ==
None:
68 cur_filter.db_insert(db)
71 db.insert(
'checks_to_seg_filters',
'seg_filter_id check_id'.split(), [[cur_filter.db_id, self.
db_id]])
79 checks_rows = db.select(
'checks', [
"datetime(created,'localtime')"],
'id=?', [str(self.
db_id)])
80 self.
created = datetime.strptime(checks_rows[0][0], DBConstants.DB_DATETIME_FMT)
82 for cur_test
in self.
tests:
83 if cur_test.db_id ==
None:
84 cur_test.db_insert(db)
93 cur_filter.db_delete(db)
95 for cur_test
in self.
tests:
96 cur_test.db_delete(db)
99 rows = db.delete(
'checks',
'id=?', [self.
db_id])
109 DBObject.db_select(db, ids)
114 where_cond = DBObject._build_where_cond_from_ids(ids)
117 rows = db.select(
'checks',
'name input_filename wav_filename num_segs default_context_padding test_index datetime(completed,\'localtime\') datetime(created,\'localtime\') id pick_randomly datetime(last_run,\'localtime\')'.split(), where_cond)
120 check_id = cur_row[8]
122 filters = SegFilter.db_select_by_ref(db,
'checks_to_seg_filters',
'seg_filter_id',
'check_id', check_id)
124 tests = Test.db_select_by_check(db, cur_row[8])
126 checks.append(
Check(cur_row[0],
133 datetime.strptime(cur_row[6], DBConstants.DB_DATETIME_FMT)
if cur_row[6] !=
None else None,
134 datetime.strptime(cur_row[7], DBConstants.DB_DATETIME_FMT)
if cur_row[7] !=
None else None,
136 pick_randomly=bool(int(cur_row[9])),
137 last_run=datetime.strptime(cur_row[10], DBConstants.DB_DATETIME_FMT)
if cur_row[10] !=
None else None,
147 if self.
db_id !=
None:
149 db.update_timestamp_col(
'checks', attr_name,
'id=?', [self.
db_id])
152 rows = db.select(
'checks', [
"datetime(%s,'localtime')" % (attr_name)],
'id=?', [self.
db_id])
154 setattr(self, attr_name, datetime.strptime(rows[0][0], DBConstants.DB_DATETIME_FMT))
156 raise Exception(
'Cannot update timestamp because Check object is not in the database.')
174 if self.
db_id !=
None:
175 db.update(
'checks', [
'test_index'],
'id=?', [self.
test_index, self.
db_id])
177 raise Exception(
'Cannot update test_index because Check instance is not in the database.')