示例#1
0
    def add_request_old(self):
        url = xutils.get_argument("url")
        # interval = xutils.get_argument("interval", 10, type=int)
        repeat_type = xutils.get_argument("repeat_type", "day")
        pattern = xutils.get_argument("pattern")

        if repeat_type == "interval":
            interval = int(pattern)
        else:
            interval = -1
            if pattern.count(":") == 1:
                # 如果是分钟默认加上秒
                pattern = pattern + ":00"

        db = xtables.get_schedule_table()
        rows = db.select(where="url=$url", vars=dict(url=url))
        result = rows.first()
        if result is None:
            db.insert(url=url,
                      interval=interval,
                      pattern=pattern,
                      ctime=xutils.format_time(),
                      mtime=xutils.format_time(),
                      repeat_type=repeat_type)
        else:
            db.update(where=dict(url=url),
                      interval=interval,
                      pattern=pattern,
                      mtime=xutils.format_time(),
                      repeat_type=repeat_type)

        xmanager.instance().load_tasks()
        raise web.seeother("/system/crontab")
示例#2
0
    def POST(self):
        script_url = xutils.get_argument("script_url")
        url = xutils.get_argument("url")
        # url = xutils.quote_unicode(url)
        tm_wday = xutils.get_argument("tm_wday")
        tm_hour = xutils.get_argument("tm_hour")
        tm_min = xutils.get_argument("tm_min")
        format = xutils.get_argument("_format")

        if script_url != "" and script_url != None:
            url = script_url

        if url == "":
            raise web.seeother("/system/crontab")

        sched_id = add_cron_task(url=url,
                                 ctime=xutils.format_time(),
                                 mtime=xutils.format_time(),
                                 tm_wday=tm_wday,
                                 tm_hour=tm_hour,
                                 tm_min=tm_min)
        xmanager.instance().load_tasks()

        if format == "json":
            return dict(code="success", data=dict(id=sched_id))
        raise web.seeother("/system/crontab")
示例#3
0
    def POST(self):
        script_url = xutils.get_argument("script_url")
        url = xutils.get_argument("url")
        # url = xutils.quote_unicode(url)
        tm_wday = xutils.get_argument("tm_wday")
        tm_hour = xutils.get_argument("tm_hour")
        tm_min = xutils.get_argument("tm_min")

        if script_url != "" and script_url != None:
            url = script_url

        if url == "":
            raise web.seeother("/system/crontab")

        db = xtables.get_schedule_table()
        db.insert(url=url,
                  ctime=xutils.format_time(),
                  mtime=xutils.format_time(),
                  tm_wday=tm_wday,
                  tm_hour=tm_hour,
                  tm_min=tm_min)
        xmanager.instance().load_tasks()
        raise web.seeother("/system/crontab")