# Path: bl/console.py
# EXPERIMENTAL = False
# def toMeter(s, tempo):
#     def parseArgs(self, audiodev=defaultAudioDev):
#     def __init__(self, *p, **kw):
#     def connectionMade(self):
#     def _readHistoryFile(self):
#     def connectionLost(self, reason):
#     def handle_RETURN(self):
#     def handle_UP(self):
#     def _resetAndDeliverBuffer(self, buffer):
#     def handle_TAB(self):
#     def _matchAttributes(self, current):
#     def _matchLocals(self, current):
#     def writeHelp(self, text):
#     def prompt(self, message):
#     def _answerPrompt(self, line):
#     def connectConsole(console, user=None, host='127.0.0.1', port=9000):
#         def eb(reason):
#         def verifyHostKey(transport, host, pubKey, fingerprint):
#         def __init__(self, console):
#         def serviceStarted(self):
#         def channelOpen(self, ignore):
#             def connectionLost(reason):
#         def dataReceived(self, data):
#         def closeReceived(self):
#         def closed(self):
#         def sendEOF(self):
#         def _windowResized(self, *args):
# def runWithProtocol(klass, audioDev, channels, bpm, tpb, meter):
# def main(argv=None, reactor=None):
# class Options(usage.Options):
# class FriendlyConsoleManhole(ConsoleManhole):
#     class SSHConnection(connection.SSHConnection):
#     class SSHSession(channel.SSHChannel):


import binascii
import base64
from zope.interface import implements
from twisted.application import service, strports
from twisted.cred import checkers, portal
from twisted.conch import telnet
    from twisted.conch import manhole_ssh, checkers as conchc
    from warnings import warn
from twisted.conch.insults import insults
from twisted.internet import protocol
from bl.console import consoleNamespace, FriendlyConsoleManhole
            return 0


class _BaseManhole(service.MultiService):

    def __init__(self, port, checker, using_ssh=True):
        service.MultiService.__init__(self)
        if type(port) is int:
            port = 'tcp:%d' % port
        self.port = port
        self.checker = checker

        def makeNamespace():
            namespace = dict(consoleNamespace)
            return namespace

        def makeProtocol():
            namespace = makeNamespace()
            p = insults.ServerProtocol(FriendlyManhole, namespace)
            return p

        if using_ssh:
            r = manhole_ssh.TerminalRealm()
            r.chainedProtocolFactory = makeProtocol
            p = portal.Portal(r, [self.checker])
            f = manhole_ssh.ConchFactory(p)
        else:
            r = _TelnetRealm(makeNamespace)
            p = portal.Portal(r, [self.checker])
            f = protocol.ServerFactory()

# Path: bl/console.py
# EXPERIMENTAL = False
# def toMeter(s, tempo):
#     def parseArgs(self, audiodev=defaultAudioDev):
#     def __init__(self, *p, **kw):
#     def connectionMade(self):
#     def _readHistoryFile(self):
#     def connectionLost(self, reason):
#     def handle_RETURN(self):
#     def handle_UP(self):
#     def _resetAndDeliverBuffer(self, buffer):
#     def handle_TAB(self):
#     def _matchAttributes(self, current):
#     def _matchLocals(self, current):
#     def writeHelp(self, text):
#     def prompt(self, message):
#     def _answerPrompt(self, line):
#     def connectConsole(console, user=None, host='127.0.0.1', port=9000):
#         def eb(reason):
#         def verifyHostKey(transport, host, pubKey, fingerprint):
#         def __init__(self, console):
#         def serviceStarted(self):
#         def channelOpen(self, ignore):
#             def connectionLost(reason):
#         def dataReceived(self, data):
#         def closeReceived(self):
#         def closed(self):
#         def sendEOF(self):
#         def _windowResized(self, *args):
# def runWithProtocol(klass, audioDev, channels, bpm, tpb, meter):
# def main(argv=None, reactor=None):
# class Options(usage.Options):
# class FriendlyConsoleManhole(ConsoleManhole):
#     class SSHConnection(connection.SSHConnection):
#     class SSHSession(channel.SSHChannel):


# Path: bl/manhole.py
import binascii
import base64
from zope.interface import implements
from twisted.application import service, strports
from twisted.cred import checkers, portal
from twisted.conch import telnet
    from twisted.conch import manhole_ssh, checkers as conchc
    from warnings import warn
from twisted.conch.insults import insults
from twisted.internet import protocol
from bl.console import consoleNamespace, FriendlyConsoleManhole

            return 0


class _BaseManhole(service.MultiService):

    def __init__(self, port, checker, using_ssh=True):
        service.MultiService.__init__(self)
        if type(port) is int:
            port = 'tcp:%d' % port
        self.port = port
        self.checker = checker

        def makeNamespace():
            namespace = dict(consoleNamespace)
            return namespace

        def makeProtocol():
            namespace = makeNamespace()
            p = insults.ServerProtocol(FriendlyManhole, namespace)
            return p

        if using_ssh:
            r = manhole_ssh.TerminalRealm()
            r.chainedProtocolFactory = makeProtocol
            p = portal.Portal(r, [self.checker])
            f = manhole_ssh.ConchFactory(p)
        else:
            r = _TelnetRealm(makeNamespace)
            p = portal.Portal(r, [self.checker])
            f = protocol.ServerFactory()

            f.protocol = makeTelnetProtocol(p)