def UpdateDbItem(self, jsonData, id): debug('') bVal = True try: setClause = 'data = ?' whereClause = 'id = ?' with self.mutex: DbManager.Update(self.tablename, setClause, jsonData, whereClause, id) except: bVal = False return bVal
def test_delayed_load(self): self.test_engine.stop() del self.test_engine del self.test_client now = datetime.datetime.utcnow() if (now.second > 35): print('Sleep until the minute rolls over') time.sleep(60 - now.second) now = datetime.datetime.strftime(datetime.datetime.utcnow(), '%Y-%m-%dT%H:%M:%S.%fZ') self.schedule_events = [{ 'id': 'delay_1', 'title': 'date_job', 'actions': ['date_job_action'], 'config': { 'type': 'date', 'start_date': now } }, { 'id': 'delay_2', 'title': 'daily_job', 'actions': ['daily_job_action'], 'config': { 'type': 'interval', 'unit': 'day', 'interval': 1, 'start_date': now } }, { 'id': 'delay_3', 'title': 'weekly_job', 'actions': ['weekly_job_action'], 'config': { 'type': 'interval', 'unit': 'week', 'interval': 1, 'start_date': now } }, { 'id': 'delay_4', 'title': 'monthly_job', 'actions': ['monthly_job_action'], 'config': { 'type': 'interval', 'unit': 'month', 'interval': 1, 'start_date': now } }, { 'id': 'delay_5', 'title': 'yearly_job', 'actions': ['yearly_job_action'], 'config': { 'type': 'interval', 'unit': 'year', 'interval': 1, 'start_date': now } }] for event in self.schedule_events: event_json = json.dumps(event) try: DbManager.Insert('scheduled_events', event['id'], event_json) except sqlite3.IntegrityError as e: DbManager.Update('scheduled_events', 'event = ?', event_json, 'id = ?', event['id']) print('Pause before loading scheduler') time.sleep(20) print('Starting scheduler, time is {}'.format( datetime.datetime.utcnow())) self.test_client = TestClient() self.test_engine = SchedulerEngine(self.test_client, 'test') self.check_schedules_run(self.schedule_events)