Exemplo n.º 1
0
 def __init__(self):
     InteractiveConsole.__init__(self,
         locals={'exit': ExitWrapper(), 'help': HelpWrapper()})
     self.stdout = sys.stdout
     self.stderr = sys.stderr
     self._cache = Cache()
     self.output = ''
Exemplo n.º 2
0
    def __init__(self, main):
        # Redirect stdout and stderr to our own write() function
        main.app.PythonConsole.write = main.app.PythonConsole.stream
        sys.stdout = main.app.PythonConsole
        sys.stderr = main.app.PythonConsole
        
        locals = {
            "__name__":   "__console__",
            "__doc__":    None,
            "main":       main,
            "PicoGUI":    PicoGUI,
            "sys":        sys,
            }
        InteractiveConsole.__init__(self,locals)

        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "

        self.main = main
        self.prompt = sys.ps1
        main.app.PythonPrompt.text = self.prompt
        main.app.link(self.enterLine, main.app.PythonCommand, 'activate')

        print "Python %s on %s\n(Widget Foundry shell, See main.__dict__ for useful variables)\n" %\
              (sys.version, sys.platform)
Exemplo n.º 3
0
 def __init__(self):
     self.stdout = sys.stdout
     self.stderr = sys.stderr
     self.stdout_cacher = FileCacher()
     self.stderr_cacher = FileCacher()
     InteractiveConsole.__init__(self)
     return
Exemplo n.º 4
0
    def __init__(self, host, client_port, server, exec_queue):
        BaseInterpreterInterface.__init__(self, server, exec_queue)
        self.client_port = client_port
        self.host = host
        try:
            import pydevd  # @UnresolvedImport
            if pydevd.GetGlobalDebugger() is None:
                raise RuntimeError()  # Work as if the debugger does not exist as it's not connected.
        except:
            ns = globals()
        else:
            # Adapted from the code in pydevd
            # patch provided by: Scott Schlesier - when script is run, it does not
            # pretend pydevconsole is not the main module, and
            # convince the file to be debugged that it was loaded as main
            sys.modules['pydevconsole'] = sys.modules['__main__']
            sys.modules['pydevconsole'].__name__ = 'pydevconsole'

            from imp import new_module
            m = new_module('__main__')
            sys.modules['__main__'] = m
            ns = m.__dict__
            try:
                ns['__builtins__'] = __builtins__
            except NameError:
                pass  # Not there on Jython...
        InteractiveConsole.__init__(self, ns)
        self._input_error_printed = False
Exemplo n.º 5
0
    def __init__(self, commands_module=None):
        import readline
        InteractiveConsole.__init__(self, globals())
        self.public_methods = ('pyex', 'quit', 'exit', 'help', 'menu') 
        self.hidden_actions = filter(lambda m: not m in self.public_methods, 
                                     dir(self) )
        self.hidden_actions.extend(dir(InteractiveConsole()))# DO NOT CHANGE THIS LINE!
        self.prompt = 'kusp>'
        self.banner = \
"""
================================================
KUSP Abstract Interactive Console

Type `help' for commands or `help <command>' 
for extended help about particular commands.
================================================
"""
        if commands_module is None:
            return

        from types import MethodType, FunctionType
        __import__(commands_module) 
        extra_commands = sys.modules[commands_module]
        c_filter = lambda name: not name.startswith("_") and \
                                type(getattr(extra_commands, name)) is FunctionType
 
        console_actions = filter( c_filter, dir(extra_commands))

        for action in console_actions:
            console_method = MethodType(getattr(extra_commands, action), self, self.__class__)
            setattr(self, action, console_method)
Exemplo n.º 6
0
    def __init__(self, config):

        self.config = config

        try:
            import readline
        except ImportError as e:
            print(e)
        else:
            import rlcompleter

        startupfile = os.environ.get("PYTHONSTARTUP")
        if startupfile:
            execfile(startupfile, {}, {})

        proj_meta = config.project_metadata
        if proj_meta:
            package = proj_meta.get("package", None)

            sys.ps1 = "[%s]>>> " % package
            sys.ps2 = "[%s]... " % package

            self.prompt = package

        InteractiveConsole.__init__(self, locals=self.get_locals())
Exemplo n.º 7
0
    def __init__(self, locals=None, filename="<console>"):
        InteractiveConsole.__init__(self, locals, filename)

        # history consists of list of pairs [(FLAG, record), ...]
        # flag is IN_FLAG or OUT_FLAG
        # record a string containing history line
        self.history = []
Exemplo n.º 8
0
 def __init__(self, engine):
     self.engine = engine
     self._stdout = sys.stdout
     self._ibuffer = [] #Parts of a statement
     self._obuffer = [] #Lines of output
     self.user_tracker = {}
     InteractiveConsole.__init__(self, {'engine': self.engine})
Exemplo n.º 9
0
 def __init__(self, stream):
     InteractiveConsole.__init__(self)
     self._stream = stream
     self.ps1 = getattr(sys, 'ps1', '>>> ')
     self.ps2 = getattr(sys, 'ps2', '... ')
     # Write banner
     self.write('Python %s on %s (%s)\n' % (sys.version, sys.platform, self.__class__.__name__))
     self.write(self.ps1)
Exemplo n.º 10
0
 def __init__(self, *args, **kwds):
     # interactive console is an old-style class
     InteractiveConsole.__init__(self, *args, **kwds)
     import sys
     sys.ps1 = 'cython> '
     sys.ps2 = '.   ... '
     self._pyxbuild_dir = kwds.get('pyxbuild_dir', None)
     self.py_compile = self.compile
Exemplo n.º 11
0
 def __init__(self, package):
     package = import_package(package)
     transforms = dict(dir=dir)
     for name, mod in package.__dict__.iteritems():
         if getattr(mod, 'dotransform', ''):
             transforms[name] = ShellCommand(mod)
     InteractiveConsole.__init__(self, locals=transforms)
     self.init_history(os.path.expanduser('~/.mtgsh_history'))
Exemplo n.º 12
0
  def __init__(self, locals = __builtin__.globals()):
    InteractiveConsole.__init__(self, locals)

    self.stdout = sys.stdout
    self.stderr = sys.stderr
    
    self.pipe = Pipe()
    self.completer = Completer(locals)
 def __init__(self):
     self.stdout = sys.stdout
     self.stderr= sys.stderr
     self.cache = FileCacher()
     self.errcache = FileCacher()
     InteractiveConsole.__init__(self)
     self.output = ''
     self.error = ''
     return
Exemplo n.º 14
0
 def __init__(self):
     self.stdout = sys.stdout
     self.cache = FileCacher()
     libs = globals()
     libs['time'] = time
     libs['math'] = math
     libs['random'] = random
     InteractiveConsole.__init__(self, libs)
     return
Exemplo n.º 15
0
 def __init__(self, logger, client, locals=None):
     InteractiveConsole.__init__(self, locals, "<console>")
     self.logger = logger
     filename = expanduser("~/.happyboom_history")
     self._locals = locals
     self.completer = rlcompleter.Completer(locals)
     self.charset = getTerminalCharset()
     self.init_history(filename)
     self.client = client
    def __init__(self, conn, addr, locals=None, filename='<console>'): 
        InteractiveConsole.__init__(self, locals, filename) 

        self.conn = conn 
        self.addr = addr 

        self.delimiter = '\n' 
        self.MAX_LENGTH = 16384 
        self.recv_buffer = '' 
Exemplo n.º 17
0
 def __init__(self, defs = {}):
     self.stdout = sys.stdout
     self.cache = FileCacher()
     
     #merging envrironments
     env = {k : v for k, v in chain(globals().iteritems(), defs.iteritems())}
     
     InteractiveConsole.__init__(self, env)
     return
Exemplo n.º 18
0
 def __init__(self, actions_object, *args, **kwargs):
     InteractiveConsole.__init__(self, *args, **kwargs)
     self.last_line = None
     self.actions = actions_object
     commands = ShellCommands(actions_object)
     command_map = commands.as_map()
     keys = sorted(command_map, key=len, reverse=True)
     self.command_regex = '^(?P<cmd>%s)(\s+(?P<args>.*))?$' % '|'.join(keys)
     self.commands = commands
     self.command_map = command_map
Exemplo n.º 19
0
 def __init__(self, intr_widget):
     '''
     Constructor
     
     Parameters:
         intr_widget - interpreter widget
     '''
     self.intr_widget = intr_widget
     
     InteractiveConsole.__init__(self)
Exemplo n.º 20
0
 def __init__(self, locals=None, filename="<console>", args=None, logger=None):
     InteractiveConsole.__init__(self, locals=locals, filename=filename)
     self.args = args
     self.locals = locals
     self.env = dustbowl.env.Environment(args.config,
                                       'dustbowl.modules',
                                       args.plugins,
                                       logger,
                                       self.locals)
     self.locals['__env__'] = self.env
Exemplo n.º 21
0
 def __init__(self, irc, channel, locals=None, filename="<console>",
              histfile=os.path.expanduser("~/.console-history")):
     self.histfile = histfile
     self.stdout = sys.stdout
     self.cache = FileCacher()
     InteractiveConsole.__init__(self, locals, filename)
     self.init_history()
     self.irc = irc
     self.channel = channel
     return
Exemplo n.º 22
0
    def __init__(self, locals=None, prompt=None, stdin=None, stderr=None):
        """Closely emulate the behavior of the interactive Python interpreter.

        This class builds on InteractiveConsole and ignores sys.ps1
        and sys.ps2 to use some slime friendly values.

        """
        InteractiveConsole.__init__(self, locals=locals, filename="<console>");
        self.prompt = prompt or "Python> "
        self.stdin = stdin or sys.stdin
        self.stderr = stderr or sys.stderr
Exemplo n.º 23
0
Arquivo: console.py Projeto: zain/pyr
    def __init__(self, locals=None, filename="<console>", histfile=None, pygments_style=None):
        InteractiveConsole.__init__(self, locals, filename)

        if not histfile:
            histfile = os.path.expanduser("~/.pyr_history")

        self.init_history(histfile)
        self.init_syntax_highlighting(pygments_style)
        self.init_pretty_printer()

        self.compile = PyrCompiler()
Exemplo n.º 24
0
 def __init__( self, localsEnv=globals() ):
   InteractiveConsole.__init__( self, localsEnv )
   print "customConsoleClass", localsEnv
   self.consoleLocals = localsEnv
   
   # catch the output of the interactive interpreter
   self.stdout = sys.stdout
   self.stderr = sys.stderr
   self.cache = FileCacher()
   
   self.help()
Exemplo n.º 25
0
    def __init__(self, loc=None, filename="<console>", histfile=None):
        InteractiveConsole.__init__(self, loc, filename)
        try:
            import readline
	    import rlcompleter
	    readline.set_completer(rlcompleter.Completer(loc).complete)
            readline.parse_and_bind("tab: complete")
        except ImportError:
	    print "error importando readline"
            pass

        self.interact()
Exemplo n.º 26
0
 def __init__(self, args, locals=None, filename="<console>"):
     InteractiveConsole.__init__(self, locals, filename)
     # Standard Cheshire3 initialization code
     init_code_lines = [
        'from cheshire3.session import Session',
        'from cheshire3.server import SimpleServer',
        'session = Session()',
        'server = SimpleServer(session, "{0}")'.format(args.serverconfig),
     ]
     # Seed console with standard initialization code
     for line in init_code_lines:
         self.push(line)
Exemplo n.º 27
0
 def __init__(self, file, inv=None):
     InteractiveConsole.__init__(self)
     self.file = sys.stdout = file
     self.cmds = inv
     self.ps1 = ">>> "
     self.ps2 = "... "
     self.banner = ("---------------------------------------------\n" +
                    "RhiPyL - The Rhino-Python-Loop for Rhino OS X\n" +
                    "---------------------------------------------\n\n" +
                    "     [ Python %s on %s ]\n\n" %
                    (sys.version, sys.platform))
     self.resetbuffer()
Exemplo n.º 28
0
    def __init__(self, viewer, locals):
        self.viewer = viewer
        self.lines = []
        self.prompt = ">>> "
        self.last_line = ""
        self.stdout = self.stderr = self
        self.active = False
        InteractiveConsole.__init__(self, locals=locals)

        self.on_resize(*getattr(viewer, 'screen_size', (1024, 1024)))

        self.prev_stdout = sys.stdout
        sys.stdout = self
Exemplo n.º 29
0
    def __init__(self, commands=None, *args, **kwargs):
        InteractiveConsole.__init__(self, *args, **kwargs)
        self.last_line = None
        if commands is None:
            commands = ShellCommands()

        # Keep a references to the shell on the commands.
        commands.shell = self
        command_map = commands.as_map()
        keys = sorted(command_map, key=len, reverse=True)
        self.command_regex = '^(?P<cmd>%s)(\s+(?P<args>.*))?$' % '|'.join(keys)
        self.commands = commands
        self.command_map = command_map
        self.logger = logbook.Logger(self.ps1 or 'logger')
Exemplo n.º 30
0
    def __init__(self, queue_pack, *args, **kwargs):
        InteractiveConsole.__init__(self, *args, **kwargs)

        (self.input_queue,
         self.output_queue,
         self.runcode_finished_queue,
         self.runsource_return_queue) = queue_pack

        self.readfunc = self.input_queue.get
        self.writefunc = self.output_queue.put

        self.stdin = PseudoFileIn(self.readfunc)
        self.stdout = PseudoFileOut(self.writefunc)
        self.stderr = PseudoFileErr(self.writefunc)
 def __init__(self, ui, locals=None):
     _InteractiveConsole.__init__(self, locals)
     self.ui = ui
Exemplo n.º 32
0
 def __init__(self, locals=None, filename="<console>", histfile=None):
     if histfile is None:
         histfile = os.path.expanduser("~/.sqlalchemy-shell-history")
     InteractiveConsole.__init__(self, locals, filename)
     self.init_history(histfile)
     self.init_completer()
Exemplo n.º 33
0
 def __init__(self):
     InteractiveConsole.__init__(self)
Exemplo n.º 34
0
 def __init__(self, echo=False, escaped_input=True):
     self.cache = FileCacher()
     self.echo = echo
     self.escaped_input = escaped_input
     InteractiveConsole.__init__(self)
     return
 def __init__(self, file, *args, **kwargs):
     self.file = sys.stdout = file
     InteractiveConsole.__init__(self, *args, **kwargs)
     return
Exemplo n.º 36
0
 def __init__(self, *args, **kwargs):
     InteractiveConsole.__init__(self, *args, **kwargs)
     self._dummyStdOut = DummyStdOut(self.write)
Exemplo n.º 37
0
 def __init__(self, context):
     InteractiveConsole.__init__(
         self, locals={"context": context.getApplicationContext()})
Exemplo n.º 38
0
 def __init__(*args):
     InteractiveConsole.__init__(*args)
 def __init__(self):
     self.l = {}
     InteractiveConsole.__init__(self, self.l)
Exemplo n.º 40
0
 def __init__(self, app, cmds):
     namespace = dict(c=cmds, context=app)
     namespace.update({name: CommandWrapper(cmds, name) for name in all_commands})
     namespace.update(help=Help())
     InteractiveConsole.__init__(self, locals=namespace)
Exemplo n.º 41
0
 def __init__(self, password, **kwargs):
     self.fl = True
     self.client = MsfRpcConsole(MsfRpcClient(password, **kwargs), cb=self.callback)
     InteractiveConsole.__init__(self, {'rpc': self.client})
     self.init_history(path.expanduser('~/.msfconsole_history'))
Exemplo n.º 42
0
 def __init__(self, *args, **kwargs):
     self.last_buffer = []  # This holds the last executed statement
     InteractiveConsole.__init__(self, *args, **kwargs)
Exemplo n.º 43
0
 def __init__(self):
     locals = {"__name__": "__console__",
               "__doc__": None,
               "type": type_par}
     InteractiveConsole.__init__(self, locals)
Exemplo n.º 44
0
 def __init__(self, socket, locals=None):
     self.socket = socket
     self.handle = socket.makefile('rw')
     InteractiveConsole.__init__(self, locals=locals)
     self.handle.write(doc)
Exemplo n.º 45
0
 def __init__(
     self, locals=None, filename="<console>", raise_expections=False
 ):
     InteractiveConsole.__init__(self, locals=locals, filename=filename)
     self.raise_expections = raise_expections
Exemplo n.º 46
0
 def __init__(self):
     self.runResult = ''
     InteractiveConsole.__init__(self)
Exemplo n.º 47
0
 def __init__(self):
     InteractiveConsole.__init__(self)
     self.stdout = sys.stdout
     self.stderr = sys.stderr
     self._cache = Cache()
     self.output = ''
Exemplo n.º 48
0
 def __init__(self, *args, **kwargs):
     InteractiveConsole.__init__(self, *args, **kwargs)
     self.locals['__interpreter__'] = self
Exemplo n.º 49
0
 def __init__(self, commands=None, speed=1, *args, **kwargs):
     self.commands = commands or []
     self.speed = speed
     InteractiveConsole.__init__(self, *args, **kwargs)
Exemplo n.º 50
0
 def __init__(self, request):
     self.request = request
     InteractiveConsole.__init__(self, _locals)
Exemplo n.º 51
0
 def __init__(self, *args, **kwargs):
     self.commands = []
     InteractiveConsole.__init__(self, *args, **kwargs)
Exemplo n.º 52
0
 def __init__(self, password, **kwargs):
     self.client = MsfRpcClient(password, **kwargs)
     InteractiveConsole.__init__(self, {'rpc' : self.client}, '<console>')
     self.init_history(path.expanduser('~/.msfrpc_history'))