本文整理汇总了Python中scheduler.Scheduler.start方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.start方法的具体用法?Python Scheduler.start怎么用?Python Scheduler.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def main():
auth = Conf("bot.conf").getSection("auth")
if not "login" in auth or not "password" in auth:
print("Configuration not entirely filled.. Try again.")
sys.exit(1)
xmpp = Jarvis(auth["login"], auth["password"], auth["room"])
xmpp.ssl_version = ssl.PROTOCOL_SSLv3
xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0199')
xmpp.register_plugin('xep_0085') # status message
xmpp.register_plugin('xep_0071') # Xhtml
xmpp.register_plugin('xep_0045') # multi user chan
xmpp.register_plugin('xep_0203') # XMPP Delayed messages
xmpp.register_plugin('xep_0249') # XMPP direct MUC invites
e = Events(xmpp)
e.start()
s = Scheduler(xmpp)
s.start()
t = ClientTask(xmpp)
t.start()
if xmpp.connect():
xmpp.process(block=True)
else:
print('Unable to connect')
示例2: nda_loop
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def nda_loop():
ndutil.setTimezone()
ndlCom = NdlCom('nDroid-Executer', '127.0.0.1', 12322)
ndlCom.doCom('Initiating')
ndlCom.doCom('Loading Config')
cnfManager = CnfManager()
cnfManager.load('./nde.cnf')
cnfData = cnfManager.getCnfData()
nsQueue = Queue()
nsLock = threading.Lock()
netManager = NetManager()
netManager.setNdlCom(ndlCom)
netManager.setNsQueue(nsQueue, nsLock)
ndlCom.doCom('Starting Threads')
scheduler = Scheduler([ndlCom, nsQueue, nsLock], 'Scheduler')
scheduler.start()
reactor.listenUDP(cnfData['comPort'], netManager)
ndlCom.doCom('Listening Com Port')
reactor.run()
scheduler.join()
示例3: TestScheduler
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
class TestScheduler(unittest.TestCase):
def setUp(self):
self.scheduler = Scheduler(4)
self.scheduler.start()
self.link_set1 = ["https://google.com", "https://rpi.edu.com", "https://apple.com", "https://rpi.edu", "https://a.com"]
self.link_set2 = ["https://lms.rpi.edu", "https://github.com", "https://linkedin.com", "https://facebook.com", "https://albany.edu"]
def tearDown(self):
self.scheduler.exit = True
def test_hp_good_links(self):
resp = self.scheduler.dump_hp_links(self.link_set2)
print(resp)
self.assertEqual(resp["https://lms.rpi.edu"][1], True)
self.assertEqual(resp["https://github.com"][1], True)
self.assertEqual(resp["https://linkedin.com"][1], True)
self.assertEqual(resp["https://facebook.com"][1], True)
self.assertEqual(resp["https://albany.edu"][1], True)
def test_hp_bad_links(self):
resp = self.scheduler.dump_hp_links(self.link_set1)
print(resp)
self.assertEqual(resp["https://rpi.edu.com"][1], False)
self.assertEqual(resp["https://a.com"][1], False)
self.assertEqual(resp["https://google.com"][1], True)
self.assertEqual(resp["https://apple.com"][1], True)
self.assertEqual(resp["https://rpi.edu"][1], True)
def test_lp_good_links(self):
resp = self.scheduler.dump_lp_links(self.link_set2)
print(resp)
self.assertEqual(resp["https://lms.rpi.edu"][1], True)
self.assertEqual(resp["https://github.com"][1], True)
self.assertEqual(resp["https://linkedin.com"][1], True)
self.assertEqual(resp["https://facebook.com"][1], True)
self.assertEqual(resp["https://albany.edu"][1], True)
def test_lp_bad_links(self):
resp = self.scheduler.dump_lp_links(self.link_set1)
print(resp)
self.assertEqual(resp["https://rpi.edu.com"][1], False)
self.assertEqual(resp["https://a.com"][1], False)
self.assertEqual(resp["https://google.com"][1], True)
self.assertEqual(resp["https://apple.com"][1], True)
self.assertEqual(resp["https://rpi.edu"][1], True)
def test_hp_priority(self):
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
f1 = executor.submit(self.scheduler.dump_lp_links, self.link_set1)
f2 = executor.submit(self.scheduler.dump_hp_links, self.link_set2)
while True:
if not f1.running() or not f2.running():
self.assertEqual(f1.running(), True)
self.assertEqual(f2.running(), False)
break
示例4: run
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def run():
s = Scheduler()
s.start()
try:
templates = "%s/views" % os.path.realpath(os.path.dirname(__file__))
bottle.TEMPLATE_PATH.insert(0, templates)
# bottle.debug(True)
bottle.run(host='', port=6060) #, reloader=True)
except KeyboardInterrupt:
pass
s.stop()
示例5: PortGuardDaemon
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
class PortGuardDaemon(Daemon):
def run(self):
self.sched = Scheduler()
self.server = SimpleXMLRPCServer(("0.0.0.0", 8812),
requestHandler=RequestHandler)
self.server.register_instance(PortGuard(self.sched))
self.sched.start()
try:
self.server.serve_forever()
finally:
self.sched.stop()
示例6: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def main():
tasksq = multiprocessing.Queue()
mgr = multiprocessing.Manager()
e = mgr.Event()
scheduler = Scheduler(e, tasksq) # Reads the probs to be executed and queues in tasksq
dispatcher = Dispatcher(tasksq)
o = Oscillator(e, 1) # TODO: this should be a configuration
o.start()
scheduler.start()
dispatcher.start()
o.join()
scheduler.join()
示例7: main
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def main():
print 'Welcome to WLSF-OS, made in Python by Capy Solutions'
n_cores = int(raw_input('Enter the amount of cores you gonna use: '))
quantum = int(raw_input('Enter the quantum time for the cores(Round-Robin preemptive): '))
n_processes = int(raw_input('Enter the amount of process you wanna create: '))
cores = [Core(quantum) for i in range(n_cores)]
processes = deque(Process() for i in range(n_processes))
scheduler = Scheduler(cores, processes)
scheduler.setup()
scheduler.start()
scheduler.join()
示例8: dispatch
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
def dispatch():
db_session = DBSession
system_option = SystemOption.get(db_session)
inventory_manager = InventoryManager(system_option.inventory_threads, 'Inventory-Manager')
inventory_manager.start()
software_manager = SoftwareManager(system_option.install_threads, 'Software-Manager')
software_manager.start()
download_manager = DownloadManager(system_option.download_threads, 'Download-Manager')
download_manager.start()
generic_job_manager = GenericJobManager(2, 'Generic-Job')
generic_job_manager.start()
scheduler = Scheduler('Scheduler')
scheduler.start()
print('csmdispatcher started')
示例9: Scheduler
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
#coding=utf8
import sys
import os.path
import gevent
from gevent import monkey
monkey.patch_all()
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
from scheduler import Scheduler
if __name__ == '__main__':
sched = Scheduler()
curr_dir = os.path.dirname(__file__)
proj_path = os.path.join(curr_dir, 'projects')
sched.load_projects(proj_path)
sched.start()
gevent.wait()
示例10: update_indoor
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
update_indoor()
update_outdoor()
update_control()
server_connect()
post_server_data()
get_web_command()
init()
scheduler1 = Scheduler(300, update_outdoor)
scheduler2 = Scheduler(300, update_indoor)
# scheduler3 = Scheduler(30, update_control)
server_scheduler = Scheduler(60, server_connect)
post_server_scheduler = Scheduler(60, post_server_data)
get_web_command_scheduler = Scheduler(0.5, get_web_command)
scheduler1.start()
scheduler2.start()
# scheduler3.start()
server_scheduler.start()
post_server_scheduler.start()
get_web_command_scheduler.start()
if __name__ == '__main__':
app.run('0.0.0.0', '8020', threaded=True)
scheduler1.stop()
scheduler2.stop()
server_scheduler.stop()
get_web_command_scheduler.stop()
post_server_scheduler.stop()
# scheduler3.stop()
示例11: Flask
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
from flask import Flask, Response
from scheduler import Scheduler
from proxy_factory.get_proxy import GetProxy
from proxy_factory.get_proxy_list import GetProxyList
app = Flask(__name__)
scheduler = Scheduler()
scheduler.start()
def get_mime(format):
mime = ("text/plain"
if format == "plain"
else "application/json; charset=utf-8")
return mime
@app.route("/")
def hello():
return "Hello world"
@app.route("/get_proxy_list")
@app.route("/get_proxy_list/<format>")
@app.route("/get_proxy_list/<format>/<int:number>")
@app.route("/get_proxy_list/<format>/<int:number>/<protocol>")
def proxy_list(format="plain", number=10, protocol=None):
proxy_factory = GetProxyList()
buff = proxy_factory.get_proxy_list(format, number, protocol)
return Response(buff, mimetype=get_mime(format), status=200)
示例12: ConfigParser
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
if __name__ == "__main__":
if not os.path.isfile(CONFIG_FILE):
print >> sys.stderr, "No config file found, please create " + CONFIG_FILE
sys.exit(23)
cfg = ConfigParser(DEFAULT_CONFIG)
cfg.read([CONFIG_FILE])
level = logging.INFO
if cfg.getboolean(MAIN_CONFIG_SECTION, OPT_DEBUG):
level=logging.DEBUG
logging.basicConfig(level=level, format='%(asctime)s %(name)s %(levelname)s %(message)s')
logging.info("Parsed config file")
default_interval = cfg.getint(MAIN_CONFIG_SECTION, OPT_INTERVAL)
logging.info("Default interval: %d" % default_interval)
for section in cfg.sections():
if MAIN_CONFIG_SECTION != section:
interval = default_interval
if cfg.has_option(section, OPT_INTERVAL):
interval = cfg.getint(section, OPT_INTERVAL)
repo = cfg.get(section, OPT_REPO)
logging.info(("Starting check thread for module %s (%s)," +
"checking for changes every %d minutes") % (section, repo, interval))
s = Scheduler(interval * 60, check_module, args = (cfg, section, repo))
s.start()
示例13: PiperBot
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
class PiperBot(threading.Thread):
def __init__(self):
super(PiperBot, self).__init__(daemon=True)
self.servers = MutableNameSpace({})
self.admins = defaultdict(list)
self.command_char = "#"
self.in_queue = PriorityQueue()
self.apikeys = {}
self.commands = {}
self.aliases = {}
self.plugins = {}
self.pre_dispatch_exts = []
self.pre_command_exts = []
self.post_command_exts = []
self.pre_event_exts = []
self.post_event_exts = []
self.pre_trigger_exts = []
self.post_trigger_exts = []
self.pre_regex_exts = []
self.post_regex_exts = []
self.worker_pool = ThreadPool(processes=4)
self.scheduler = Scheduler()
self.scheduler.start()
self.message_buffer = defaultdict(lambda: defaultdict(lambda: deque(maxlen=50)))
self.buffer_pattern = re.compile(r"(?:(\w+)|(\s)|^)(?:\^(\d+)|(\^+))")
self.buffer_pattern_escape = re.compile(r"\\\^")
self.running = False
def buffer_replace(self, text, servername, channel, offset=0):
buffer = list(self.message_buffer[servername][channel])[offset:]
def buffer_sub(match_object):
if match_object.group(1):
messgages = [x for x in buffer if x.nick == match_object.group(1)]
if not messgages:
raise Exception("user not in memory")
else:
messgages = buffer
if match_object.group(3):
count = int(match_object.group(3))
else:
count = len(match_object.group(4))
if count <= len(messgages):
return (" " if match_object.group(2) else "") + messgages[count - 1].text
else:
raise Exception("line not in memory")
text = self.buffer_pattern.sub(buffer_sub, text)
text = self.buffer_pattern_escape.sub("^", text)
return text
def connect_to(self, servername, network, port, nick, channels=None, admins=None, password=None, username=None,
ircname=None, ssl=False):
self.servers[servername] = ServerConnection(self.in_queue, servername, network, port, nick, password, username,
ircname, channels, ssl)
self.servers[servername].connect()
if admins:
self.admins[servername] += admins
def run(self):
self.running = True
try:
while self.running:
try:
message = self.in_queue.get(timeout=10)
print("<< " + str(message))
self.handle_message(message)
except Empty:
pass
finally:
self.shutdown()
def shutdown(self):
self.running = False
for plugin in self.plugins.values():
for func in plugin._onUnloads:
func()
for server in self.servers.values():
server.disconnect(message="shutting down")
def load_plugin_from_module(self, plugin):
if "." in plugin:
module = "".join(plugin.split(".")[:-1])
plugin_name = plugin.split(".")[-1]
temp = importlib.machinery.SourceFileLoader(module, os.path.dirname(
os.path.abspath(__file__)) + "/plugins/" + module + ".py").load_module()
found = False
for name, Class in inspect.getmembers(temp, lambda x: inspect.isclass(x) and hasattr(x, "_plugin")):
if name == plugin_name:
#.........这里部分代码省略.........
示例14: getInstance
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
class DownUpManager:
gDownUpManager = None
@staticmethod
def getInstance():
if DownUpManager.gDownUpManager is None:
DownUpManager.gDownUpManager = DownUpManager()
return DownUpManager.gDownUpManager
def __init__(self):
self.__scheduler = Scheduler(ServersManager.getInstance())
self.__tasks = {}
self.__running = False
self.__listeners = []
self.ensureRun()
def ensureRun(self):
if self.__running == False:
self.__scheduler.start()
self.__running = True
## Listeners
def registerListener(self, listener):
if listener not in self.__listeners:
self.__listeners.append(listener)
def removeListener(self, listener):
if listener in self.__listeners:
self.__listeners.remove(listener)
## Events
def notifyTaskDone(self, task):
for listener in self.__listeners:
listener.onTaskDone(task)
def notifyTaskProgress(self, task, progress):
for listener in self.__listeners:
listener.onTaskProgress(task, progress)
def notifyTaskCancel(self, task):
for listener in self.__listeners:
listener.onTaskCancel(task)
def notifyTaskSuspended(self, task):
for listener in self.__listeners:
listener.onTaskSuspended(task)
def notifyTaskResumed(self, task):
for listener in self.__listeners:
listener.onTaskResumed(task)
def notifyTaskError(self, task):
for listener in self.__listeners:
listener.onTaskError(task)
## Task management
def queueTask(self, task):
self.__scheduler.queueTask(task)
def __registerTask(self, task):
if task.uuid not in self.__tasks:
self.__tasks[task.uuid] = TaskRef(task)
def upload(self, filename):
t = UpTask(self, filename)
self.__registerTask(t)
return t.uuid
def download(self, url, prefix=''):
t = DownTask(self, url, prefix)
self.__registerTask(t)
return t.uuid
def startTask(self, task):
if task in self.__tasks:
self.__tasks[task].object.process()
def removeTask(self, task):
if task in self.__tasks:
self.__tasks[task].cancel()
del self.__tasks[task]
def suspendTask(self, task):
if task in self.__tasks:
self.__tasks[task].suspend()
def resumeTask(self, task):
if task in self.__tasks:
self.__tasks[task].resume()
def getTaskStatus(self, task):
if task in self.__tasks:
return self.__tasks[task].status
def getTask(self, task):
if task in self.__tasks:
#.........这里部分代码省略.........
示例15: SocketController
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import start [as 别名]
class SocketController(object):
state = {
1: False,
2: False,
3: False,
4: False,
}
action_dict = {
'1': ('1-on', '1-off'),
'2': ('2-on', '2-off'),
'3': ('3-on', '3-off'),
'4': ('4-on', '4-off'),
}
def __init__(self, config):
if getattr(config, 'ICAL_URL', None):
self.scheduler = Scheduler(config.ICAL_URL,
self._switch_by_code,
self.action_dict,
polling_interval=config.POLLING_INTERVAL)
else:
self.scheduler = None
def start(self):
pimote.init()
pimote.switch('all-off')
if self.scheduler:
self.scheduler.start()
def stop(self):
if self.scheduler:
self.scheduler.stop()
pimote.term()
def _switch_by_code(self, code):
getattr(self, 'switch_' + code.replace("-", "_"))()
def switch_1_on(self):
if pimote.switch('1-on'):
self.state[1] = True
def switch_1_off(self):
if pimote.switch('1-off'):
self.state[1] = False
def switch_2_on(self):
if pimote.switch('2-on'):
self.state[2] = True
def switch_2_off(self):
if pimote.switch('2-off'):
self.state[2] = False
def switch_3_on(self):
if pimote.switch('3-on'):
self.state[3] = True
def switch_3_off(self):
if pimote.switch('3-off'):
self.state[3] = False
def switch_4_on(self):
if pimote.switch('4-on'):
self.state[4] = True
def switch_4_off(self):
if pimote.switch('4-off'):
self.state[4] = False
def switch_all_on(self):
if pimote.switch('all-on'):
self.state[1] = True
self.state[2] = True
self.state[3] = True
self.state[4] = True
def switch_all_off(self):
if pimote.switch('all-off'):
self.state[1] = False
self.state[2] = False
self.state[3] = False
self.state[4] = False