Ejemplo n.º 1
0
        def __init__(self, *args, **kwargs):

            IPShellEmbed.__init__(self, *args, **kwargs)

            # now self.IP exisits

            old_interact = self.IP.interact  # save the real method

            def new_interact(self, *args):
                """ wrapper method which checks the user namespace
                """

                self.IP.user_ns.update({'_ips_exit': False})

                old_interact(*args)  # call the real interact method

                # now look if the user wants to stop
                if self.IP.user_ns['_ips_exit']:

                    def do_nothing(*args, **kwargs):
                        pass

                    # harakiri
                    # the calling method replaces itself with a the dummy
                    self.IP.interact = do_nothing

            # replace the original interact method with the wrapper
            self.IP.interact = new.instancemethod(new_interact, self,
                                                  type(self))
Ejemplo n.º 2
0
 def __init__(self, kwargs):
     argv = [
              '-prompt_in1','\C_Blue\#) \C_Greenrestcli\$ ',
            ]
     IPShellEmbed.__init__(self,argv,banner='restkit shell %s' % __version__,
                           exit_msg=None,rc_override=None,
                           user_ns=kwargs)
Ejemplo n.º 3
0
        def __init__(self, *args, **kwargs):
            
            IPShellEmbed.__init__(self, *args, **kwargs)
            
            # now self.IP exisits

            
            old_interact = self.IP.interact # save the real method
            
            def new_interact(self, *args):
                """ wrapper method which checks the user namespace
                """
                
                self.IP.user_ns.update({'_ips_exit':False})

                old_interact(*args) # call the real interact method
                
                # now look if the user wants to stop
                if self.IP.user_ns['_ips_exit']:
                    def do_nothing(*args, **kwargs):
                        pass
                    
                    # harakiri
                    # the calling method replaces itself with a the dummy
                    self.IP.interact = do_nothing 
                
                
            # replace the original interact method with the wrapper 
            self.IP.interact = new.instancemethod(new_interact, self,
                                                                  type(self))
Ejemplo n.º 4
0
 def __init__(self, kwargs):
     argv = [
              '-prompt_in1','\C_Blue\#) \C_Greenrestcli\$ ',
            ]
     IPShellEmbed.__init__(self,argv,banner='restkit shell %s' % __version__,
                           exit_msg=None,rc_override=None,
                           user_ns=kwargs)
Ejemplo n.º 5
0
 def __init__(self, section=''):
     argv = [
         '-prompt_in1',
         '\C_Blue\#) \C_Greenldap/%s\$ ' % section,
     ]
     IPShellEmbed.__init__(self,
                           argv,
                           banner='',
                           exit_msg=None,
                           rc_override=None,
                           user_ns=None)
Ejemplo n.º 6
0
 def __init__(self, banner=None, locals=None):
     IPShellEmbed.__init__(self, argv=[], banner=banner,
                           user_ns=locals)
Ejemplo n.º 7
0
 def __init__(self, banner=None, locals=None):
     IPShellEmbed.__init__(self, argv=[], banner=banner, user_ns=locals)