def setschedulercallback(calltype, timelist, argument, callbackname, jobname): # jobname is used as unique identifier of the job iserror = False callback = schedulercallback[callbackname] if calltype == "periodic": try: theinterval = timelist[1] randomsecond = timelist[2] thedateloc = datetime.now() + timedelta(seconds=randomsecond) #convert to UTC time thedate = clockmod.convertLOCtoUTC_datetime(thedateloc) try: if not FASTSCHEDULER: SchedulerMod.sched.add_job(callback, 'interval', minutes=theinterval, start_date=thedate, args=argument, misfire_grace_time=120, name=jobname) else: SchedulerMod.sched.add_job(callback, 'interval', seconds=theinterval, start_date=thedate, args=argument, misfire_grace_time=120, name=jobname) except ValueError: iserror = True print 'Date value for job scheduler not valid' except ValueError as e: iserror = True print 'Error: ', e else: # one shot type tday = date.today() todaydate = datetime(tday.year, tday.month, tday.day, 0, 0, 0) thedateloc = todaydate + timedelta( hours=timelist[0], minutes=timelist[1], seconds=timelist[2]) #convert to UTC time thedate = clockmod.convertLOCtoUTC_datetime(thedateloc) if len(argument) > 0: print "date ", thedate, " callbackname ", callbackname, " Pump line ", argument[ 0] else: print "date ", thedate, " callbackname ", callbackname try: #print argument job = SchedulerMod.sched.add_job(callback, 'date', run_date=thedate, args=argument, misfire_grace_time=120, name=jobname) except ValueError as e: iserror = True print 'Error: ', e return iserror
def setschedulercallback(calltype,timelist,argument,callbackname,jobname): # jobname is used as unique identifier of the job iserror=False callback=schedulercallback[callbackname] if calltype=="periodic": theintervalminutes=timelist[1] theintervalhours=timelist[0] startdelaysec=timelist[2] if (theintervalminutes+theintervalhours==0): # the time interval is too short, no action iserror=True logger.warning('The scheduler interval for the input %s is Zero, no log record of this input will be taken',jobname) return iserror try: print("add job ", jobname) thedateloc=datetime.now()+timedelta(seconds=startdelaysec) mastertimelist=hardwaremod.separatetimestringint(MASTERSCHEDULERTIME) date1=datetime.now()+timedelta(days=1) date2=date1.replace(hour=mastertimelist[0], minute=mastertimelist[1], second=mastertimelist[2]) enddateloc=date2-timedelta(minutes=10) # stop 10 minutes before the start of new masterscheduler #enddateloc=thedateloc.replace(hour=23, minute=59, second=59) #convert to UTC time thedate=clockmod.convertLOCtoUTC_datetime(thedateloc) #define end date for trigger enddate=clockmod.convertLOCtoUTC_datetime(enddateloc) try: if not FASTSCHEDULER: SchedulerMod.sched.add_job(callback, 'interval', hours=theintervalhours, minutes=theintervalminutes, start_date=thedate, end_date=enddate ,args=argument, misfire_grace_time=5, name=jobname) else: SchedulerMod.sched.add_job(callback, 'interval', seconds=theintervalminutes, start_date=thedate, end_date=enddate ,args=argument, misfire_grace_time=5, name=jobname) except ValueError: iserror=True print('Date value for job scheduler not valid') except ValueError as e: iserror=True print('Error: ', e) else: # one shot type tday = date.today() todaydate = datetime(tday.year, tday.month, tday.day, 0, 0, 0) thedateloc=todaydate+timedelta(hours=timelist[0],minutes=timelist[1],seconds=timelist[2]) #convert to UTC time thedate=clockmod.convertLOCtoUTC_datetime(thedateloc) if len(argument)>0: print("date ", thedate , " callbackname " , callbackname , " Pump line ", argument[0]) else: print("date ", thedate , " callbackname " , callbackname) try: #print argument job = SchedulerMod.sched.add_job(callback, 'date', run_date=thedate, args=argument, misfire_grace_time=120, name=jobname) except ValueError as e: iserror=True print('Error: ', e) return iserror
def setmastercallback(): logger.info('Master Scheduler - Setup daily jobs') #set daily call for mastercallback at midnight thedateloc = datetime.now() + timedelta(days=1) timelist = hardwaremod.separatetimestringint(MASTERSCHEDULERTIME) starttimeloc = thedateloc.replace(hour=timelist[0], minute=timelist[1], second=timelist[2]) print(timelist) #convert to UTC time starttime = clockmod.convertLOCtoUTC_datetime(starttimeloc) print("setup master job") argument = [True] try: SchedulerMod.sched.add_job(mastercallback, 'interval', days=1, start_date=starttime, args=argument, misfire_grace_time=120, name="master") logger.info('Master Scheduler - Started without errors') except ValueError: print('Date value for job scheduler not valid') logger.warning( 'Heartbeat check , Master Scheduler not Started properly') mastercallback() return True
def setschedulercallback(calltype,timelist,argument,callbackname,jobname): # jobname is used as unique identifier of the job iserror=False callback=schedulercallback[callbackname] if calltype=="periodic": try: theinterval=timelist[1] randomsecond=timelist[2] thedateloc=datetime.now()+timedelta(seconds=randomsecond) enddateloc=thedateloc.replace(hour=23, minute=59, second=59) #convert to UTC time thedate=clockmod.convertLOCtoUTC_datetime(thedateloc) #define end date for trigger enddate=clockmod.convertLOCtoUTC_datetime(enddateloc) try: if not FASTSCHEDULER: SchedulerMod.sched.add_job(callback, 'interval', minutes=theinterval, start_date=thedate, end_date=enddate ,args=argument, misfire_grace_time=120, name=jobname) else: SchedulerMod.sched.add_job(callback, 'interval', seconds=theinterval, start_date=thedate, end_date=enddate ,args=argument, misfire_grace_time=120, name=jobname) except ValueError: iserror=True print 'Date value for job scheduler not valid' except ValueError as e: iserror=True print 'Error: ', e else: # one shot type tday = date.today() todaydate = datetime(tday.year, tday.month, tday.day, 0, 0, 0) thedateloc=todaydate+timedelta(hours=timelist[0],minutes=timelist[1],seconds=timelist[2]) #convert to UTC time thedate=clockmod.convertLOCtoUTC_datetime(thedateloc) if len(argument)>0: print "date ", thedate , " callbackname " , callbackname , " Pump line ", argument[0] else: print "date ", thedate , " callbackname " , callbackname try: #print argument job = SchedulerMod.sched.add_job(callback, 'date', run_date=thedate, args=argument, misfire_grace_time=120, name=jobname) except ValueError as e: iserror=True print 'Error: ', e return iserror
def setmastercallback(): logger.info('Master Scheduler - Setup daily jobs') #set daily call for mastercallback at midnight thedateloc=datetime.now()+timedelta(days=1) starttimeloc=thedateloc.replace(hour=0, minute=5, second=0) #convert to UTC time starttime=clockmod.convertLOCtoUTC_datetime(starttimeloc) print "setup master job" try: SchedulerMod.sched.add_job(mastercallback, 'interval', days=1, start_date=starttime, misfire_grace_time=120, name="master") logger.info('Master Scheduler - Started without errors') except ValueError: print 'Date value for job scheduler not valid' logger.warning('Heartbeat check , Master Scheduler not Started properly') mastercallback() return True
def setmastercallback(): logger.info('Master Scheduler - Setup daily jobs') #set daily call for mastercallback at midnight starttime = datetime(datetime.now().year, datetime.now().month, datetime.now().day, 0, 0, 0) starttimeloc = starttime + timedelta(seconds=1) #convert to UTC time starttime = clockmod.convertLOCtoUTC_datetime(starttimeloc) print "setup master job" try: SchedulerMod.sched.add_job(mastercallback, 'interval', days=1, start_date=starttime, misfire_grace_time=120, name="master") logger.info('Master Scheduler - Started without errors') except ValueError: print 'Date value for job scheduler not valid' logger.warning( 'Heartbeat check , Master Scheduler not Started properly') mastercallback()
def setschedulercallback(calltype, timelist, argument, callbackname, jobname): # jobname is used as unique identifier of the job iserror = False callback = schedulercallback[callbackname] if calltype == "periodic": theinterval = timelist[1] randomsecond = timelist[2] if theinterval < 1: # the time interval is too short, no action iserror = True logger.warning( 'The scheduler for the input %s is not less than 1 minute, no log record of this input will be taken', jobname) return iserror try: thedateloc = datetime.now() + timedelta(seconds=randomsecond) enddateloc = thedateloc.replace(hour=23, minute=59, second=59) #convert to UTC time thedate = clockmod.convertLOCtoUTC_datetime(thedateloc) #define end date for trigger enddate = clockmod.convertLOCtoUTC_datetime(enddateloc) try: if not FASTSCHEDULER: SchedulerMod.sched.add_job(callback, 'interval', minutes=theinterval, start_date=thedate, end_date=enddate, args=argument, misfire_grace_time=120, name=jobname) else: SchedulerMod.sched.add_job(callback, 'interval', seconds=theinterval, start_date=thedate, end_date=enddate, args=argument, misfire_grace_time=120, name=jobname) except ValueError: iserror = True print 'Date value for job scheduler not valid' except ValueError as e: iserror = True print 'Error: ', e else: # one shot type tday = date.today() todaydate = datetime(tday.year, tday.month, tday.day, 0, 0, 0) thedateloc = todaydate + timedelta( hours=timelist[0], minutes=timelist[1], seconds=timelist[2]) #convert to UTC time thedate = clockmod.convertLOCtoUTC_datetime(thedateloc) if len(argument) > 0: print "date ", thedate, " callbackname ", callbackname, " Pump line ", argument[ 0] else: print "date ", thedate, " callbackname ", callbackname try: #print argument job = SchedulerMod.sched.add_job(callback, 'date', run_date=thedate, args=argument, misfire_grace_time=120, name=jobname) except ValueError as e: iserror = True print 'Error: ', e return iserror