Source

txMysql / bin / repl

#!/usr/bin/env python
# -*- mode: python -*-
"""
"""

from twisted.internet import defer, stdio, protocol, reactor
from twisted.protocols import basic

from twisted.internet import reactor
from twisted.web import server, resource
from twisted.cred import portal, checkers
from twisted.conch import manhole, manhole_ssh

from txmysql import adbapi
from txmysql import settings

def run(_):
    print "Started!"

pool = adbapi.ConnectionPool(settings.HOSTNAME, settings.PORT,
                   settings.USERNAME, settings.PASSWORD,
                   size=2)
dl = pool.start()
dl.addCallback(run)


def getManholeFactory(namespace, **passwords):
    realm = manhole_ssh.TerminalRealm()
    def getManhole(_):
        return manhole.Manhole(namespace)
    realm.chainedProtocolFactory.protocolFactory = getManhole
    p = portal.Portal(realm)
    p.registerChecker(
        checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords))
    f = manhole_ssh.ConchFactory(p)
    return f


if __name__ == "__main__":
    reactor.listenTCP(2222, getManholeFactory(globals(), admin='password'))
    reactor.run()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.