def reload_main_module(self): """Clear ourselves into a pristine state and load the main module again. """ self.clear_modules() cls = load_file(self.factory.main_module_name) self.load_module(cls)
def add_module(self,match,realm): modname=match.group(1) realm.write("Adding module %s" % modname) realm.send_to_mud=False cls=load_file(modname) realm.write(cls) if cls!=None: realm.write('Got a class') realm.root.load_module(cls)
def main(): options = parser.parse_args() #if options.module_directory != "": # directory = options.module_directory # import sys # sys.path.append(directory) from twisted.internet import reactor #modclass = load_file(options.modulename) modclass = load_file(options.modulename) processor = MudProcessor() processor.reactor = reactor modinstance = processor.load_module(modclass) stdio.StandardIO(processor) reactor.run()
def main(): """Launch the client. This is the main entry point. This will first initialise the GUI, then load the main module specified on the command line. """ options = parser.parse_args() if options.module_directory != "": directory = options.module_directory import sys sys.path.append(directory) if options.gui == 'gtk': from twisted.internet import gtk2reactor gtk2reactor.install() from twisted.internet import reactor modclass = load_file(options.modulename) factory = TelnetClientFactory(modclass.name, modclass.encoding, options.modulename, reactor) if options.gui == 'gtk': from pymudclient.gui.gtkgui import configure factory.realm.gui = ImperianGui(factory.realm) configure(factory) factory.realm.module_settings_dir=options.settings_directory modinstance = factory.realm.load_module(modclass) factory.realm.gmcp_handler = modinstance.gmcp_handler modinstance.is_main(factory.realm) from twisted.internet import reactor #pylint kicks up a major fuss about these lines, but that's because #Twisted does some hackery with the reactor namespace. #pylint: disable-msg=E1101 reactor.connectTCP(modclass.host, modclass.port, factory) if not options.profile: reactor.run() else: import cProfile cProfile.runctx("reactor.run()", globals(), locals(), filename = "pymudclient.prof")
def test_load_file_loads_script(): m = load_file("foobar") assert m == sentinel.Module