Esempio n. 1
0
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")
Esempio n. 2
0
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()
    subenv = dict(os.environ)
    mod = __import__(options.modulename, fromlist = ["name", "host", "port", "configure", "encoding",
                                                     "gmcp_handshakes", "gui_configure",
                                                     "use_blocks"])

    realm = Connector(mod)

    if options.gui == 'gtk':
        if hasattr(mod, 'gui_configure'):
            mod.gui_configure(realm)
        
        from pymudclient.gui.gtkgui import configure
    
    realm.processor_exec = options.processor
    realm.module_name = options.modulename
    
    configure(realm)

    

    #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

    if hasattr(mod, "configure"):
        mod.configure(realm)

    realm.client = ClientProtocol(realm)
    from twisted.internet import reactor
    realm.reactor = reactor
    sp = reactor.callWhenRunning(spawnProcessHelper.spawnProcess, realm.client, realm.processor_exec, options.modulename)
    if not options.profile:
        reactor.run()
    else:
        import cProfile
        cProfile.runctx("reactor.run()", globals(), locals(),
                        filename = "pymudclient.prof")