本文整理汇总了Python中schedule.Schedule.getnextschedule方法的典型用法代码示例。如果您正苦于以下问题:Python Schedule.getnextschedule方法的具体用法?Python Schedule.getnextschedule怎么用?Python Schedule.getnextschedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类schedule.Schedule
的用法示例。
在下文中一共展示了Schedule.getnextschedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: theLoop
# 需要导入模块: from schedule import Schedule [as 别名]
# 或者: from schedule.Schedule import getnextschedule [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 getnextschedule [as 别名]
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))
else: