# Path: sshproxy/registry.py
# class Registry(object):
#     _registry = {}
#     _singletons = {}
#     _singleton = False
#     _class_base = object
# 
# 
#     @classmethod
#     def register(cls):
#         """
#         Register an object class.
#         """
# 
#         #print '%s.register(%s)' % (cls.__name__, cls._class_id)
#         Registry._registry[cls._class_id] = cls
# 
# 
#     def __new__(cls, *args, **kw):
#         """
#         Return an instance of the previously registered class.
# 
#         If the class is a singleton, and was already instanciated,
#         ignore arguments supplied and return singleton instance.
# 
#         """
# 
#         obj_class = Registry._registry[cls._class_id]
#         if cls._singleton:
#             theone = Registry._singletons.get(cls._class_id)
#             if theone is None:
#                 theone = cls._class_base.__new__(obj_class)
#                 Registry._singletons[cls._class_id] = theone
#                 theone.__reginit__(*args, **kw)
#             return theone
#             
#         else:
#             obj = cls._class_base.__new__(obj_class)
#             obj.__reginit__(*args, **kw)
#             return obj
# 
#     def __reginit__(self, *args, **kw):
#         raise NotImplementedError("__reginit__ has not been implemented in %s" % self.__class__.__name__)
#         pass
# 
# Path: sshproxy/util.py
# def utf8(s):
#     return convert(s, 'utf8')


import cmd, os, socket
        import getpass
            import sys, termios
            import log
from sshproxy.registry import Registry
from sshproxy.util import utf8
        from getpass import getpass
    def default(self, line):
        try:
            cmd, args = line.split(' ', 1)
        except ValueError:
            cmd, args = line, ''
        response = self.ipc.call(cmd, args)
        if response is not None:
            print response

    def _set_password(self, line, prompt1=None, prompt2=None):
        prompt1 = prompt1 or "Enter the password: "
        prompt2 = prompt2 or "Confirm the password: "
        item = line.strip()
        if not item:
            print "This command accept at least 1 argument"
            return

        pass1, pass2 = "1", "2"
        while not pass1.strip() or pass1 != pass2:
            try:
                pass1 = getpass(prompt1)
            except EOFError:
                print
            if prompt2 == -1:
                pass2 = pass1
                continue
            try:
                pass2 = getpass(prompt2)
            except EOFError:
                print

# Path: sshproxy/registry.py
# class Registry(object):
#     _registry = {}
#     _singletons = {}
#     _singleton = False
#     _class_base = object
# 
# 
#     @classmethod
#     def register(cls):
#         """
#         Register an object class.
#         """
# 
#         #print '%s.register(%s)' % (cls.__name__, cls._class_id)
#         Registry._registry[cls._class_id] = cls
# 
# 
#     def __new__(cls, *args, **kw):
#         """
#         Return an instance of the previously registered class.
# 
#         If the class is a singleton, and was already instanciated,
#         ignore arguments supplied and return singleton instance.
# 
#         """
# 
#         obj_class = Registry._registry[cls._class_id]
#         if cls._singleton:
#             theone = Registry._singletons.get(cls._class_id)
#             if theone is None:
#                 theone = cls._class_base.__new__(obj_class)
#                 Registry._singletons[cls._class_id] = theone
#                 theone.__reginit__(*args, **kw)
#             return theone
#             
#         else:
#             obj = cls._class_base.__new__(obj_class)
#             obj.__reginit__(*args, **kw)
#             return obj
# 
#     def __reginit__(self, *args, **kw):
#         raise NotImplementedError("__reginit__ has not been implemented in %s" % self.__class__.__name__)
#         pass
# 
# Path: sshproxy/util.py
# def utf8(s):
#     return convert(s, 'utf8')


# Path: sshproxy/console.py
import cmd, os, socket
        import getpass
            import sys, termios
            import log
from sshproxy.registry import Registry
from sshproxy.util import utf8
        from getpass import getpass

    def default(self, line):
        try:
            cmd, args = line.split(' ', 1)
        except ValueError:
            cmd, args = line, ''
        response = self.ipc.call(cmd, args)
        if response is not None:
            print response

    def _set_password(self, line, prompt1=None, prompt2=None):
        prompt1 = prompt1 or "Enter the password: "
        prompt2 = prompt2 or "Confirm the password: "
        item = line.strip()
        if not item:
            print "This command accept at least 1 argument"
            return

        pass1, pass2 = "1", "2"
        while not pass1.strip() or pass1 != pass2:
            try:
                pass1 = getpass(prompt1)
            except EOFError:
                print
            if prompt2 == -1:
                pass2 = pass1
                continue
            try:
                pass2 = getpass(prompt2)
            except EOFError:
                print

        return item, utf8(pass1)