本文整理汇总了Python中apscheduler.schedulers.background.BlockingScheduler.configure方法的典型用法代码示例。如果您正苦于以下问题:Python BlockingScheduler.configure方法的具体用法?Python BlockingScheduler.configure怎么用?Python BlockingScheduler.configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apscheduler.schedulers.background.BlockingScheduler
的用法示例。
在下文中一共展示了BlockingScheduler.configure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_theme_colors
# 需要导入模块: from apscheduler.schedulers.background import BlockingScheduler [as 别名]
# 或者: from apscheduler.schedulers.background.BlockingScheduler import configure [as 别名]
def get_theme_colors(theme_name):
with open(theme_name, "r") as f:
t = json.load(f)
return t['colors']
if __name__ == "__main__":
settings = parse_settings()
theme = Theme(settings['theme'])
colors = theme.colors
# create the bar
bar = barhandler(theme)
#Configure scheduler
scheduler = BlockingScheduler()
scheduler.configure(timezone='Europe/Stockholm')
#Schedule jobs
scheduler.add_job(get_time, 'interval', seconds=30, next_run_time=datetime.now(), args=[colors])
scheduler.add_job(get_battery, 'interval', seconds=1, next_run_time=datetime.now(), args=[colors])
scheduler.add_job(get_cpu, 'interval', seconds=5, next_run_time=datetime.now(), args=[colors])
scheduler.add_job(get_mpd, 'interval', seconds=1, next_run_time=datetime.now(), args=[colors])
scheduler.add_job(get_volume, 'interval', seconds=1, next_run_time=datetime.now(), args=[colors])
scheduler.add_job(get_wifi, 'interval', seconds=1, next_run_time=datetime.now(), args=[colors])
#Start continious jobs
bspccontrol = BspcControl(bar)
Thread(target=bspccontrol.inputhandler, args=(colors,)).start()
#Start scheduler
scheduler.start()
示例2: runnable
# 需要导入模块: from apscheduler.schedulers.background import BlockingScheduler [as 别名]
# 或者: from apscheduler.schedulers.background.BlockingScheduler import configure [as 别名]
def runnable(file_path):
"""
:return:
"""
# run a job
print("JOB now starting. FIle path %s" % (file_path))
print("JOB .....")
print("JOB now finished")
scheduler = BlockingScheduler()
# .. do something else here, maybe add jobs etc.
the_date = datetime.datetime.now() + datetime.timedelta(seconds=2)
d_trigger = DateTrigger(the_date)
l = lambda: runnable('/tmtmtmtmtmtmt')
scheduler.add_job(func=runnable, trigger=d_trigger, args=['tick\n'])
the_date = datetime.datetime.now() + datetime.timedelta(seconds=2)
d_trigger = DateTrigger(the_date)
scheduler.add_job(func=runnable, trigger=d_trigger, args=['tick1\n'])
scheduler.configure(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
scheduler.start()
示例3: DisseminationPlayer
# 需要导入模块: from apscheduler.schedulers.background import BlockingScheduler [as 别名]
# 或者: from apscheduler.schedulers.background.BlockingScheduler import configure [as 别名]
class DisseminationPlayer(object):
MIDNIGHT = datetime.time(0,0,0)
def __init__(self, top_data_dir, index_file, dir_files_to_parse, files_to_parse, job_func, destination):
"""
:return:
"""
self._parser = eumetsat.dmon.parsers.xferlog_parser.XferlogParser(no_gems_header = True)
self._dir_files = dir_files_to_parse
self._files = files_to_parse
self._job_func = job_func
self._scheduler = BlockingScheduler()
res = []
t = ftimer(Indexer.load_index, [top_data_dir, index_file], {}, res)
print("Read index in %d seconds." % (t))
self._index = res[0]
#can now set reference time
#ref time = now time plus one minute
self._defer_time = 5
self._reference_date = datetime.datetime.now() + datetime.timedelta(seconds=self._defer_time)
#destination info (depends on the type of job)
self._destination = destination
def add_jobs(self):
"""
Create the jobs from the reference time
:return:
"""
for a_file in self._files:
f_path = "%s/%s" % (self._dir_files, a_file)
print("Parsing xferlog file %s" % f_path )
fd = open(f_path)
self._parser.set_lines_to_parse(fd)
for elem in self._parser:
#print("time = %s, filename = %s\n" % (elem['time'], elem['file']))
#find file in index
filepath = self._index.get(elem['file'], None)
if filepath:
#get time difference
midnight_date = utc.localize(datetime.datetime.combine(elem['time'].date(), self.MIDNIGHT))
#print("midnight date = %s ///// elem[time] = %s" % (midnight_date, elem['time']))
time_diff = elem['time'] - midnight_date
scheduled_date = self._reference_date + time_diff
#create job and schedule it with the time difference added to the starting reference time
d_trigger = DateTrigger(scheduled_date)
self._scheduler.add_job(self._job_func, d_trigger, args=[filepath, self._destination])
else:
print("Could not find %s\n in Index" % (elem['file']))
print("Player. %d jobs scheduled.\n" % (len(self._scheduler.get_jobs())))
def start(self):
"""
:return:
"""
self._scheduler.configure(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
print("Start Scheduler. Jobs will start to be played in %d sec." % self._defer_time)
self._scheduler.start()
示例4: getip
# 需要导入模块: from apscheduler.schedulers.background import BlockingScheduler [as 别名]
# 或者: from apscheduler.schedulers.background.BlockingScheduler import configure [as 别名]
output = subprocess.check_output(('acpi')).decode('ascii')
if 'Battery' in output:
percentage = output.split(' ')[3].replace("%", "").replace(",", "").strip()
bar.battery = percentage
def getip():
cmd = subprocess.check_output(('ip', 'route')).decode('ascii')
match = re.search("src ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", cmd)
if match:
bar.ip = match.group(1)
else:
bar.ip = "None"
#Configure scheduler
scheduler = BlockingScheduler()
scheduler.configure(timezone='Europe/Amsterdam')
#Schedule jobs
scheduler.add_job(getmemory, 'interval', seconds=2, next_run_time=datetime.now())
scheduler.add_job(getcurrenttime, 'interval', seconds=1, next_run_time=datetime.now())
scheduler.add_job(getbattery, 'interval', seconds=10, next_run_time=datetime.now())
scheduler.add_job(getip, 'interval', seconds=10, next_run_time=datetime.now())
scheduler.add_job(getwindowtitle, 'interval', seconds=.1, next_run_time=datetime.now())
#Start continious jobs
bspccontrol = BspcControl(bar)
Thread(target=bspccontrol.inputhandler).start()
#Start scheduler
scheduler.start()