Exemplo n.º 1
0
    def __init__(self, window_agents):
        Thread.__init__(self)
        # Make sure this thread is a daemon not to prevent program exit.
        self.daemon = True
        realm = manhole_ssh.TerminalRealm()
        namespace = {
            'Gtk': Gtk,
            'walk': walk,
            'widgets': lambda: walk(iter(window_agents).next()),
            'window_agents': window_agents,
            'window': lambda: iter(window_agents).next()
        }
        realm.chainedProtocolFactory.protocolFactory = \
            lambda _: manhole.Manhole(namespace)
        p = portal.Portal(realm)
        p.registerChecker(
            checkers.InMemoryUsernamePasswordDatabaseDontUse(nemo='nemo'))
        reactor.listenTCP(2222, manhole_ssh.ConchFactory(p))

        # Starting the thread is not enough because the Python interpreter
        # is no running all the time and therefore the thread will not run
        # too. Workaround this by using a timer to run the interpreter
        # periodically.
        def timer():
            time.sleep(0.001)  # Yield to other threads.
            return True

        GObject.timeout_add(10, timer)
Exemplo n.º 2
0
def getManholeFactory(namespace, **passwords):
    realm = manhole_ssh.TerminalRealm()
    realm.chainedProtocolFactory.protocolFactory = (
        lambda _: manhole.Manhole(namespace)
    )

    p = portal.Portal(realm)
    p.registerChecker(
        checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords)
    )

    f = manhole_ssh.ConchFactory(p)

    return f
Exemplo n.º 3
0
 def getManhole(_):
     return manhole.Manhole(namespace)
Exemplo n.º 4
0
       def getManhole(_): return manhole.Manhole(namespace) 
 realm.chainedProtocolFactory.protocolFactory = getManhole
Exemplo n.º 5
0
 def create_remote_protocol(_):
     return manhole.Manhole(namespace)
Exemplo n.º 6
0
 def getManhole(serverProtocol):
     startingNamespace = {
         'config': configuration,
         'services': services,
     }
     return manhole.Manhole(util.getNamespace(startingNamespace))