def stop(self): """ Stop the thread and cleanup. """ log.info('stop mainloop') set_mainloop_running(False) main.wakeup() main.stop()
def _twisted_stopped_callback(self): """ Callback when Twisted wants to stop. """ if not main.is_mainthread(): return MainThreadCallback(self._twisted_stopped_callback)() self._twisted_stopped = True # shut down kaa mainloop in case the reactor was shut down and # not kaa.main main.stop()
def load_commands(): "load commands" # exit command command_list.update({'quit': lambda x: main.stop()}) command_list.update({'exit': lambda x: main.stop()}) command_list.update({'help': lambda x: help()}) # load custom commands custom_commands = cf.config["Command"]["custom_commands"] for k in custom_commands.items(): call = lambda x, y=k[1]: y add_user_command("/" + k[0], call) add_user_command("/help", user_help)
def tearDownClass(cls): stop()
# 请勿使用该模块及范例对任何YouTube主播/VTuber进行骚扰!!!!! # 如果查实滥用该模块及范例的行为 将会取得受害人的同意后发起舆论上的声讨 情节严重的将考虑予以起诉 # 注意 这是一个模块引用范例 目的是帮助你更好的理解如何使用该模块 # 作者John Stonty QQ:1844063767 遇到问题欢迎联系 import main #引用模块 当然也可以使用as简化 main.init("vrwSrCr9J4s") #初始化模块 (启动监听服务及浏览器) # 上行括号->引号内的内容为YouTube直播间ID # 比如原直播的youtube链接为 www.youtube.com/watch?v=vrwSrCr9J4s 或是 youtu.be/vrwSrCr9J4s # 那么直播间ID即为vrwSrCr9J4s # 范例引用的直播间是Yuna Channel(桜美ゆな)的 # 因为24小时配信所以便于调试 请勿滥用!!! main.sendMessages("こんにちは:)") #在目标直播间发送指定文本 # 注意: Youtube 的实时聊天仅支持单行文本 # 如果要发送多条消息可以重复调用该过程 main.stop() #关闭监听服务及浏览器 # 记得结束时一定要调用该过程!!! # 否则headless chrome不会自动关闭 这样反复下来会占用过多资源
#Author:John Stonty import main main.init("Room ID") main.sendMessages("Message") main.stop()
obstacles = {"control": [], "2000mlane0": [{"lane": 0, "x": 2000}]} start = time.time() for key, obstacleObj in obstacles.items(): if not path.exists("/".join(["data", key])): makedirs("/".join(["data", key])) for variable, values in simulations.items(): print("Starting simulations for", variable) data = {} reload(gV) gV.obstacles = obstacleObj for val in values: if isinstance(val, dict): name = val['name'] val = val['data'] else: name = val print(key, variable, val, "started") gV.__dict__[variable] = val data[name] = sim.runSim(display=False, maxSimTime=60 * 60, seed=randint(0, 100000)) with open("/".join(["data", key, variable + ".json"]), "w") as outfile: json.dump(data, outfile, sort_keys=True, indent=4) print("Done in", str(time.time() - start), "seconds") sim.stop()
"Handle command" import threading import main import config as cf import re command_list = {'stop': lambda x: main.stop()} user_command_list = {} class Command(threading.Thread): "Handle command" def __init__(self): threading.Thread.__init__(self) self.running = True def run(self): "run" print("Start Command System") # wait for handle commands while self.running: if not self.running: return str1 = input("> ") command = str1.split() if not command: continue
import main import modelo import vista import controlador modelo1 = modelo.Modelo() controlador1 = controlador.Controlador(modelo1) vista1 = vista.Vista("simple.glade", 'window') vista2 = vista.Vista("simple.glade", 'window') controlador1.registrar_vista(vista1) controlador1.registrar_vista(vista2) main = main.Main() main.start() modelo1.nuevo(True) modelo1.nuevo(False) main.stop()