本文整理汇总了Python中backend.Backend.exec_schedule方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.exec_schedule方法的具体用法?Python Backend.exec_schedule怎么用?Python Backend.exec_schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.exec_schedule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sch
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import exec_schedule [as 别名]
def sch(request, pi_id):
print("In sched")
sch_id = request.POST['sch_id']
print repr(request.POST)
action = request.POST['action']
schedule = Schedule.objects.get(pk=sch_id)
print "Before action '%s'" % action
be = Backend()
print "Backend stat size: %s" % len(be.schedDict)
if action == "stop":
status = Const.STATUS_STOPPED
# cancel currently running schedule and start new
schedule_current = Schedule.objects.filter(Q(status=Const.STATUS_RUNNING) | Q(status=Const.STATUS_PLANNED))
if len(schedule_current) > 0:
print "Got running schedule '%s'" % schedule_current[0]
schedule_current[0].status = Const.STATUS_STOPPED
schedule_current[0].save()
print "Forcing stop scheduler"
be.stop_schedule(schedule_current[0])
elif action == "start":
status = Const.STATUS_RUNNING
be.exec_schedule(schedule)
print "Status switched to: %s" % status % ", action: %s" % action
schedule.status = status
schedule.save()
print("Saved")
message = "Schedule(" + sch_id + ") is %s" % ( "started" if status == Const.STATUS_RUNNING else "stopped")
print("Message:" + message)
return HttpResponse(message)
示例2: start_schedule
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import exec_schedule [as 别名]
def start_schedule(request, pi_id):
be = Backend()
messsage = {"Error"}
try:
sch_id = request.POST['sch_id']
# schedule = change_schedule_status(sch_id, STATUS_PLANNED)
schedule = get_object_or_404(Schedule, id=sch_id)
# Defense against idiot - do not allow to plan schedule multiple times if now, so process only active schedules
if schedule.status is not Const.STATUS_RUNNING or schedule.status is not Const.STATUS_PLANNED:
be.exec_schedule(schedule)
messsage = {Const.STATUS_PLANNED}
else:
messsage = {"Nothing"}
except Schedule.DoesNotExist:
raise Http404
return HttpResponse(messsage)