当前位置: 首页>>代码示例>>Python>>正文


Python Backend.exec_schedule方法代码示例

本文整理汇总了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)
开发者ID:serebatos,项目名称:smart_h,代码行数:34,代码来源:views.py

示例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)
开发者ID:serebatos,项目名称:smart_h,代码行数:18,代码来源:views.py


注:本文中的backend.Backend.exec_schedule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。