开始做定时器
This commit is contained in:
25
util/global_config.py
Normal file
25
util/global_config.py
Normal file
@@ -0,0 +1,25 @@
|
||||
class GlobalConfig:
|
||||
def __init__(self):
|
||||
""" 初始化 """
|
||||
global global_dict
|
||||
global_dict = {}
|
||||
|
||||
def set_globalconfig(self, name, value):
|
||||
"""
|
||||
设置全局变量
|
||||
:param name: 全局变量名称
|
||||
:param value: 全局变量值
|
||||
"""
|
||||
global_dict[name] = value
|
||||
|
||||
def get_globalconfig(self, name, defaultvalue=None):
|
||||
"""
|
||||
获取全局变量
|
||||
:param name: 全局变量名称
|
||||
:param defaultvalue: 默认值,在无设置值时返回
|
||||
:return: 返回请求的全局变量值
|
||||
"""
|
||||
try:
|
||||
return global_dict[name]
|
||||
except:
|
||||
return defaultvalue
|
||||
14
util/schedule.py
Normal file
14
util/schedule.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import datetime
|
||||
import re
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
|
||||
def add_interval_schedule(type='interval', **kwargs):
|
||||
|
||||
if (type == 'interval'):
|
||||
params = {}
|
||||
for k, v in kwargs.items():
|
||||
if k not in ('year', 'month', 'day', 'week', 'day_of_week', 'hour', 'minute', 'second', 'start_date', 'end_date'):
|
||||
pass
|
||||
else:
|
||||
params[k] = v
|
||||
print(params)
|
||||
Reference in New Issue
Block a user