本文整理匯總了Python中schedule.Schedule.makeschedule方法的典型用法代碼示例。如果您正苦於以下問題:Python Schedule.makeschedule方法的具體用法?Python Schedule.makeschedule怎麽用?Python Schedule.makeschedule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類schedule.Schedule
的用法示例。
在下文中一共展示了Schedule.makeschedule方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: theLoop
# 需要導入模塊: from schedule import Schedule [as 別名]
# 或者: from schedule.Schedule import makeschedule [as 別名]
def theLoop(adapters,log):
log.debug("starting scheduler class")
sch=Schedule(log)
while 1:
log.debug("starting loop")
log.debug("updating schedule")
sch.makeschedule()
row=sch.getnextschedule()
now=int(time.time())
left=3600
togo=3600
if len(row):
togo=row["start"] - now
log.debug("next recording: %s in %s" % (row["title"],timeformat(togo)))
else:
log.debug("no recordings scheduled")
rrows=sch.getcurrentrecordings()
cn=len(rrows)
if cn:
log.debug("%d programmes currently being recorded" % cn)
nextend=rrows[0]["end"]
left=nextend - now
log.debug("%s finishes in %s" % (rrows[0]["title"],timeformat(left)))
else:
log.debug("nothing currently recording")
if togo<left:
timeleft=togo
else:
timeleft=left
log.debug("sleeping for %s" % timeformat(timeleft))
signal.alarm(left)
signal.pause()
log.debug("ending loop")
示例2:
# 需要導入模塊: from schedule import Schedule [as 別名]
# 或者: from schedule.Schedule import makeschedule [as 別名]
from schedule import Schedule
log=logging.getLogger("cristel")
if __name__ == '__main__':
left=3600
togo=3600
log.setLevel(logging.DEBUG)
handler=logging.handlers.SysLogHandler(address = '/dev/log', facility=logging.handlers.SysLogHandler.LOG_DAEMON)
log.addHandler(handler)
prog=os.path.basename(__file__)
log.debug("starting scheduler class")
sch=Schedule(log)
log.debug("updating schedule")
sch.makeschedule()
row=sch.getnextschedule()
if row != None:
now=int(time.time())
togo=row["start"] - now
log.info("next recording: %s in %d seconds" % (row["title"],togo))
else:
log.info("no recordings scheduled")
rrows=sch.getcurrentrecordings()
cn=len(rrows)
if cn:
log.debug("%d programmes currently being recorded" % cn)
nextend=rrows[0]["end"]
left=nextend - now
log.debug("%s finishes in %d seconds" % (rrows[0]["title"],left))