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


Python schedule.every方法代码示例

本文整理汇总了Python中schedule.every方法的典型用法代码示例。如果您正苦于以下问题:Python schedule.every方法的具体用法?Python schedule.every怎么用?Python schedule.every使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在schedule的用法示例。


在下文中一共展示了schedule.every方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: schedule_with_delay

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def schedule_with_delay(self):
        for task in self.tasks:
            interval = task.get('interval')
            schedule.every(interval).minutes.do(self.schedule_task_with_lock, task)
        while True:
            schedule.run_pending()
            time.sleep(1) 
开发者ID:SpiderClub,项目名称:haipproxy,代码行数:9,代码来源:scheduler.py

示例2: prepare_jobs

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def prepare_jobs(self, jobs):
        suffixed_names = {
            'week': 'weekly',
            'day': 'daily',
            'hour': 'hourly',
            'minute': 'minutes',
            'second': 'seconds',
        }
        for job in jobs:
            if not job.enabled:
                continue

            interval_name = job.time_unit.lower()
            if job.interval > 0: # There can't be a job less than 0 (0 minutes? 0 seconds?)
                plural_interval_name = interval_name + 's'
                d = getattr(schedule.every(job.interval), plural_interval_name)
                d.do(self.run_job, job)
                Log.info("  Loading %s job: %s.", suffixed_names[interval_name], job.name)
            elif interval_name == 'day':
                schedule.every().day.at(job.at_time).do(self.run_job, job)
                Log.info("  Loading time-based job: " + job.name)
            else:
                d = getattr(schedule.every(), interval_name)
                d.do(self.run_job, job)
                Log.info("  Loading %s job: %s", interval_name, job.name) 
开发者ID:mayaculpa,项目名称:hapi,代码行数:27,代码来源:smart_module.py

示例3: _run

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def _run(self):
        if self.args.run_mode == 'job':
            schedule.every().day.at('00:00').do(self._build_report)
            while True:
                schedule.run_pending()
                time.sleep(1)
        else:
            self._build_report(self.args.date) 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:10,代码来源:daily_report.py

示例4: go_click

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def go_click(self):
        self.save_settings()

        schedule.clear()
        if config['schedule']['schedule_time']:
            schedule.every().day.at(config['schedule']['schedule_time']).do(self.start_click, sched_task=True)
        else:
            schedule.every().day.at("08:00").do(self.start_click)

        try:
            self.task_monitor.isAlive()
        except AttributeError:
            self.task_monitor = threading.Thread(target=self.run_monitor)
        else:
            if not self.task_monitor.isAlive():
                self.task_monitor = threading.Thread(target=self.run_monitor)
        finally:
            if not self.task_monitor.isAlive():
                self.task_monitor.setDaemon(True)
                self.task_monitor.start()

        app.log('当前账号: %s' % config['dingtalk']['username'])
        app.log('等待下次学习时间: %s' % schedule.next_run()) 
开发者ID:zodiac182,项目名称:autoxuexi,代码行数:25,代码来源:xuexi.py

示例5: __init__

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def __init__(self, port="5550"):
        self.__bind_addr = "tcp://*:%s" % port
        app.logger.info("Bind address: " + self.__bind_addr)

        self.__relay_lock = threading.Lock()

        self.__db = GarageDb(app.instance_path, app.resource_path)

        # Get initial reed state and subscribe to events
        GPIO.setup(app.config['REED_PIN'], GPIO.IN)
        GPIO.add_event_detect(app.config['REED_PIN'], GPIO.BOTH, callback=self.door_opened_or_closed)
        self.__door_state = None                            # 1 for open, 0 for closed, None for uninitialized
        self.door_opened_or_closed(app.config['REED_PIN'])  # force update

        # Set up warning timer if there's a setting
        if app.config['DOOR_OPEN_WARNING_TIME']:
            app.logger.info('Starting schedule to check door at {0}...'.format(app.config['DOOR_OPEN_WARNING_TIME']))
            schedule.every().day.at(app.config['DOOR_OPEN_WARNING_TIME']).do(self.check_door_open_for_warning)
            t = Thread(target=self.run_schedule)
            t.start()
        else:
            app.logger.info('No schedule to run.') 
开发者ID:nathanpjones,项目名称:GaragePi,代码行数:24,代码来源:controller.py

示例6: set_schedule

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def set_schedule(time):
    schedule.every().monday.at(time).do(sync_trades)
    schedule.every().tuesday.at(time).do(sync_trades)
    schedule.every().wednesday.at(time).do(sync_trades)
    schedule.every().thursday.at(time).do(sync_trades)
    schedule.every().friday.at(time).do(sync_trades) 
开发者ID:chrism2671,项目名称:PyTrendFollow,代码行数:8,代码来源:scheduler.py

示例7: _clean_single_schedule

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def _clean_single_schedule(cls, check, schedule_dict):
        if not isinstance(schedule_dict, dict):
            raise ConfigurationError(
                'Check {0} has invalid schedule configuration: {1}'
                .format(check['name'], schedule_dict),
            )
        try:
            every = schedule_dict['every']
        except KeyError:
            raise ConfigurationError(
                "Check {0} has invalid schedule format: {1}"
                .format(check['name'], schedule_dict)
            )
        if isinstance(every, six.string_types):
            # "every: day" shortcut
            unit, every = every, 1
        else:
            unit = schedule_dict.get('unit')
        unit = cls._clean_unit(check, unit)
        at = cls._clean_at(check, schedule_dict.get('at'))
        rule = TimelineRule(every, unit, at)
        logger.debug('Parsed schedule "%r" to %r', schedule_dict, rule)
        return rule 
开发者ID:kibitzr,项目名称:kibitzr,代码行数:25,代码来源:timeline.py

示例8: handle

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def handle(self, args):
        logger = IngestLogger()
        logger.info(
            "Starting Baleen v{} ingestion service every hour.".format(baleen.get_version())
        )

        schedule.every().hour.do(partial(self.ingest, args))

        while True:
            try:
                schedule.run_pending()
                time.sleep(1)
            except (KeyboardInterrupt, SystemExit):
                logger.info("Graceful shutdown of Baleen ingestion service.")
                return ""
            except Exception as e:
                logger.critical(str(e))
                return str(e) 
开发者ID:DistrictDataLabs,项目名称:baleen,代码行数:20,代码来源:run.py

示例9: __init__

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def __init__(self):
        md = MalwareFeedDescription(
            module_name="MalShare",
            interval = schedule.every().day.at("04:00"),
            description="Feed from MalShare of Daily files",
            authors=["Silas Cutler"],
            version="0.2"
        )
        MalwareFeed.__init__(self, md)
        self.parse_settings()

        self.url_daily_list = "https://malshare.com/daily/malshare.current.sha256.txt"
        self.url_download = "https://malshare.com/api.php?api_key=%s&action=getfile&hash=%s"
        self.url_sources = "https://malshare.com/api.php?api_key=%s&action=getsources"

        # Settings 
开发者ID:silascutler,项目名称:MalPipe,代码行数:18,代码来源:MalShare.py

示例10: handle

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def handle(self, *args, **kwargs):

        logger.info("%s - starting jobs schedule" % (__name__))
            
        try:
            '''            
            schedule.every().hour.do(job_update_entities)
            schedule.every().hour.do(job_update_clients)
            schedule.every().hour.do(job_update_checks)
            schedule.every().hour.do(job_update_trends)
            #schedule.every(10).minutes.do(job_update_events)
            '''
            
            schedule.every(settings.CACHE_ENTITY_TTL).seconds.do(job_update_entities)
            schedule.every(settings.CACHE_CLIENT_TTL).seconds.do(job_update_clients)
            schedule.every(settings.CACHE_TRENDS_TTL).seconds.do(job_update_trends)
            
            
            while True:
                schedule.run_pending()
                sleep(1)

        except KeyboardInterrupt:
            logger.info("%s - user signal exit!" % (__name__))
            exit(0) 
开发者ID:ilavender,项目名称:sensu_drive,代码行数:27,代码来源:jobs.py

示例11: user_callback

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def user_callback(ch, method, properties, body):
    user_json = body.decode()
    user_dict = json.loads(user_json)

    r.set("User:{}".format(user_dict["email"]), user_json)

    schedule.every(periods[user_dict['period']]).days.at("10:00").do(
        sub_ch.basic_publish, exchange='work',
        routing_key=SCHEDULE_NOTIFIER_QUEUE, body=user_dict["email"])

    for s in user_dict['subscriptions'].keys():
        for g in user_dict['subscriptions'][s]:
            sub_ch.basic_publish(exchange='work', routing_key=funcs[s], body=g)
            schedule.every(periods[user_dict['period']]).days.at("10:00").do(
                sub_ch.basic_publish,
                exchange='work',
                routing_key=funcs[s],
                body=g
            ) 
开发者ID:alirizakeles,项目名称:ab-2018,代码行数:21,代码来源:sched.py

示例12: test_every

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def test_every(dummy_bus: lightbus.path.BusPath, event_loop):
    calls = 0

    @dummy_bus.client.every(seconds=0.001)
    async def test_coroutine():
        nonlocal calls
        while True:
            calls += 1
            if calls == 5:
                raise Exception("Intentional exception: stopping lightbus dummy bus from running")
            await asyncio.sleep(0.001)

    # SystemExit raised because test_coroutine throws an exception
    dummy_bus.client.run_forever()

    assert dummy_bus.client.exit_code

    assert calls == 5 
开发者ID:adamcharnock,项目名称:lightbus,代码行数:20,代码来源:test_bus_client_unit.py

示例13: test_schedule

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def test_schedule(dummy_bus: lightbus.path.BusPath):
    import schedule

    calls = 0

    # TODO: This kind of 'throw exception to stop bus' hackery in the tests can be cleaned up
    @dummy_bus.client.schedule(schedule.every(0.001).seconds)
    async def test_coroutine():
        nonlocal calls
        while True:
            calls += 1
            if calls == 5:
                raise Exception("Intentional exception: stopping lightbus dummy bus from running")
            await asyncio.sleep(0.001)

    dummy_bus.client.run_forever()

    assert dummy_bus.client.exit_code

    assert calls == 5 
开发者ID:adamcharnock,项目名称:lightbus,代码行数:22,代码来源:test_bus_client_unit.py

示例14: test_call_on_schedule_async

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def test_call_on_schedule_async(run_for):
    import schedule

    await_count = 0

    async def cb():
        nonlocal await_count
        await_count += 1

    await run_for(
        coroutine=call_on_schedule(
            callback=cb, schedule=schedule.every(0.1).seconds, also_run_immediately=False
        ),
        seconds=0.25,
    )
    assert await_count == 2 
开发者ID:adamcharnock,项目名称:lightbus,代码行数:18,代码来源:test_async_tools.py

示例15: generate_memory_schedule

# 需要导入模块: import schedule [as 别名]
# 或者: from schedule import every [as 别名]
def generate_memory_schedule(schedulelist, isforupdate=False):

            print "##### Generating Memory Schedule."
            now = datetime.datetime.now()
            now = now.replace(year=1900, month=1, day=1)
            pseudo_cache = pseudo_channel.get_daily_schedule_cache_as_json()
            prev_end_time_to_watch_for = None
            if pseudo_channel.USE_OVERRIDE_CACHE and isforupdate:
                for cached_item in pseudo_cache:
                    prev_start_time = datetime.datetime.strptime(cached_item[8], "%I:%M:%S %p")
                    try:
                        prev_end_time = datetime.datetime.strptime(cached_item[9], '%Y-%m-%d %H:%M:%S.%f')
                    except ValueError:
                        prev_end_time = datetime.datetime.strptime(cached_item[9], '%Y-%m-%d %H:%M:%S')
                    """If update time is in between the prev media start / stop then there is overlap"""
                    if prev_start_time < now and prev_end_time > now:
                        try:
                            print "+++++ It looks like there is update schedule overlap", cached_item[3]
                        except:
                            pass
                        prev_end_time_to_watch_for = prev_end_time
            for item in schedulelist:
                trans_time = datetime.datetime.strptime(item[8], "%I:%M:%S %p").strftime("%H:%M")
                new_start_time = datetime.datetime.strptime(item[8], "%I:%M:%S %p")
                if prev_end_time_to_watch_for == None:
                    schedule.every().day.at(trans_time).do(job_that_executes_once, item, schedulelist).tag('daily-tasks')
                else:
                    """If prev end time is more then the start time of this media, skip it"""
                    if prev_end_time_to_watch_for > new_start_time:
                        try:
                            print "Skipping scheduling item do to cached overlap.", item[3]
                        except:
                            pass
                        continue
                    else:
                        schedule.every().day.at(trans_time).do(job_that_executes_once, item, schedulelist).tag('daily-tasks')
            print "+++++ Done." 
开发者ID:justinemter,项目名称:pseudo-channel,代码行数:39,代码来源:PseudoChannel.py


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