def __init__(self, tkconsole):
     self.tkconsole = tkconsole
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
     self.restarting = False
     self.subprocess_arglist = self.build_subprocess_arglist()
Beispiel #2
0
 def __init__(self):
     self.stdout = sys.stdout
     self.stderr = sys.stderr
     self.out_cache = FileCacher()
     self.err_cache = FileCacher()
     InteractiveInterpreter.__init__(self)
     return
Beispiel #3
0
 def command(self, text):
   if not self.hidden:
     self.cscroll = None
     self.command = ''
     self.entry.set('')
     self.entry['focus'] = True
     self.writeOut(self.otext['text'] + ' ' + text + '\n', False)
     if text != '' and (len(self.commands) == 0 or self.commands[-1] != text):
       self.commands.append(text)
     
     # Insert plugins into the local namespace
     locals = __main__.__dict__
     #locals['manager'] = self.manager
     #for plugin in self.manager.named.keys():
     #  locals[plugin] = self.manager.named[plugin]
     locals['panda3d'] = panda3d
     
     # Run it and print the output.
     if not self.initialized:
       InteractiveInterpreter.__init__(self, locals = locals)
       self.initialized = True
     try:
       if self.runsource(self.block + '\n' + text) and text != '':
         self.otext['text'] = '.'
         self.block += '\n' + text
       else:
         self.otext['text'] = ':'
         self.block = ''      
     except Exception: # Not just "except", it will also catch SystemExit
       # Whoops! Print out a traceback.
       self.writeErr(traceback.format_exc())
Beispiel #4
0
    def __init__(self, args):
        global Charm4PyError
        from .charm import Charm4PyError
        # restore original tty stdin and stdout (else readline won't work correctly)
        os.dup2(charm.origStdinFd, 0)
        os.dup2(charm.origStoutFd, 1)
        charm.dynamic_register['future'] = future_
        charm.dynamic_register['self'] = self
        InteractiveInterpreter.__init__(self, locals=charm.dynamic_register)
        self.filename = '<console>'
        self.resetbuffer()
        # regexp to detect when user defines a new chare type
        self.regexpChareDefine = re.compile(
            'class\s*(\S+)\s*\(.*Chare.*\)\s*:')
        # regexps to detect import statements
        self.regexpImport1 = re.compile('\s*from\s*(\S+) import')
        self.regexpImport2 = re.compile('import\s*(\S+)')
        self.options = charm.options.interactive

        try:
            import readline
            import rlcompleter
            readline.parse_and_bind('tab: complete')
        except:
            pass

        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = '>>> '
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = '... '
        self.thisProxy.start()
Beispiel #5
0
 def __init__(self, tkconsole, tkasyc=TkAsyncUpdate()):
     self.tkconsole = tkconsole
     self.tkasyc = tkasyc
     now_locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=now_locals)
     self.subprocess_arglist = None
     self.active_seq = None
Beispiel #6
0
    def __init__(
        self, locals=None, rawin=None, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr, showInterpIntro=True
    ):
        """Create an interactive interpreter object."""
        InteractiveInterpreter.__init__(self, locals=locals)
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr
        if rawin:
            import __builtin__

            __builtin__.raw_input = rawin
            del __builtin__
        if showInterpIntro:
            copyright = 'Type "help", "copyright", "credits" or "license"'
            copyright += " for more information."
            self.introText = "Python %s on %s%s%s" % (sys.version, sys.platform, os.linesep, copyright)
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "
        self.more = 0
        # List of lists to support recursive push().
        self.commandBuffer = []
        self.startupScript = None
Beispiel #7
0
 def __init__(self, tkconsole):
     self.tkconsole = tkconsole
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
     self.restarting = False
     self.subprocess_arglist = self.build_subprocess_arglist()
 def __init__(self, localAndGlobalDict):
     self.stdin = None
     self.buf = ""
     InteractiveInterpreter.__init__(self, localAndGlobalDict)
     sys.ps1 = ""
     sys.ps2 = ""
     self.more = False
Beispiel #9
0
    def command(self, text):
        if self.hidden:
            return

        self.cscroll = None
        self.command = ''
        self.entry.set('')
        self.entry['focus'] = True
        self.write_out(self.otext['text'] + ' ' + text + '\n', False)
        if text != '' and (len(self.commands) == 0
                           or self.commands[-1] != text):
            self.commands.append(text)

        if not self.initialized:
            InteractiveInterpreter.__init__(self)
            self.initialized = True
        try:
            if self.runsource(self.block + '\n' + text) and text != '':
                self.otext['text'] = '.'
                self.block += '\n' + text
            else:
                self.otext['text'] = ':'
                self.block = ''
        except Exception:
            self.write_err(traceback.format_exc())
Beispiel #10
0
 def __init__(self, locals=None, rawin=None, \
              stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
     """Create an interactive interpreter object."""
     InteractiveInterpreter.__init__(self, locals=locals)
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
     if rawin:
         import __builtin__
         __builtin__.raw_input = rawin
         del __builtin__
     copyright = \
         'Type "copyright", "credits" or "license" for more information.'
     self.introText = 'Python %s on %s%s%s' % \
                      (sys.version, sys.platform, os.linesep, copyright)
     try:
         sys.ps1
     except AttributeError:
         sys.ps1 = '>>> '
     try:
         sys.ps2
     except AttributeError:
         sys.ps2 = '... '
     self.more = 0
     # List of lists to support recursive push().
     self.commandBuffer = []
     self.startupScript = os.environ.get('PYTHONSTARTUP')
Beispiel #11
0
    def __init__(self, locals=None, rawin=None, 
                 stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
                 showInterpIntro=True):
        """Create an interactive interpreter object."""
        if not locals:
            locals = {}
        locals['connect'] = self.connect
        InteractiveInterpreter.__init__(self, locals=locals)
        self.lua_locals = {}
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr
        if rawin:
            import __builtin__
            __builtin__.raw_input = rawin
            del __builtin__
        if showInterpIntro:
            self.introText = 'Inspect the ejoy2dx client'
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = '>>> '
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = '... '
        self.more = 0
        # List of lists to support recursive push().
        self.commandBuffer = []
        self.startupScript = None

        self.socket = None
Beispiel #12
0
 def __init__(self, localAndGlobalDict):
     self.stdin = None
     self.buf = ""
     InteractiveInterpreter.__init__(self, localAndGlobalDict)
     sys.ps1 = ""
     sys.ps2 = ""
     self.more = False
Beispiel #13
0
 def __init__(self, locals=None, rawin=None, \
              stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
     """Create an interactive interpreter object."""
     InteractiveInterpreter.__init__(self, locals=locals)
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
     if rawin:
         import __builtin__
         __builtin__.raw_input = rawin
         del __builtin__
     self.introText = 'SunShell %s %s\n' % (VERSION, COPYRIGHT)
     self.introText += 'Use "it.connect()" to establish a connection.\n'
     try:
         sys.ps1
     except AttributeError:
         sys.ps1 = '>>> '
     try:
         sys.ps2
     except AttributeError:
         sys.ps2 = '... '
     self.more = 0
     # List of lists to support recursive push().
     self.commandBuffer = []
     self.startupScript = os.environ.get('PYTHONSTARTUP')
Beispiel #14
0
 def __init__(self,
              locals=None,
              rawin=None,
              stdin=sys.stdin,
              stdout=sys.stdout,
              stderr=sys.stderr):
     """Create an interactive interpreter object."""
     InteractiveInterpreter.__init__(self, locals=locals)
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
     if rawin:
         import __builtin__
         __builtin__.raw_input = rawin
         del __builtin__
     #seb copyright = 'Type "help", "copyright", "credits" or "license"'
     #seb copyright += ' for more information.'
     #seb self.introText = 'Python %s on %s%s%s' % \
     #seb                  (sys.version, sys.platform, os.linesep, copyright)
     try:
         sys.ps1
     except AttributeError:
         sys.ps1 = '>>> '
     try:
         sys.ps2
     except AttributeError:
         sys.ps2 = '... '
     self.more = 0
     # List of lists to support recursive push().
     self.commandBuffer = []
     self.startupScript = os.environ.get('PYTHONSTARTUP')
Beispiel #15
0
    def __init__(self, parent, ID, pos=wx.DefaultPosition,
                 size=wx.DefaultSize, style=0,
                 locals=None, properties=None, banner=None):
        stc.StyledTextCtrl.__init__(self, parent, ID, pos, size, style)
        InteractiveInterpreter.__init__(self, locals)

        self.lastPromptPos = 0

        # the line cache is used to cycle through previous commands
        self.lines = []
        self.lastUsedLine = self.curLine = 0

        # set defaults and then deal with any user defined properties
        self.props = {}
        self.props.update(_default_properties)
        if properties:
            self.props.update(properties)
        self.UpdateProperties()

        # copyright/banner message
        if banner is None:
            self.write("Python %s on %s\n" % #%s\n(%s)\n" %
                       (sys.version, sys.platform,
                        #sys.copyright, self.__class__.__name__
                        ))
        else:
            self.write("%s\n" % banner)

        # write the initial prompt
        self.Prompt()

        # Event handlers
        self.Bind(wx.EVT_KEY_DOWN, self.OnKey)
        self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI, id=ID)
Beispiel #16
0
    def command(self, text):
        if not self.hidden:
            self.cscroll = None
            self.command = ''
            self.entry.set('')
            self.entry['focus'] = True
            self.writeOut(self.otext['text'] + ' ' + text + '\n', False)
            if text != '' and (len(self.commands) == 0
                               or self.commands[-1] != text):
                self.commands.append(text)

            # Insert plugins into the local namespace
            locals = __main__.__dict__
            locals['manager'] = self.manager
            for plugin in self.manager.named.keys():
                locals[plugin] = self.manager.named[plugin]
            locals['panda3d'] = panda3d

            # Run it and print the output.
            if not self.initialized:
                InteractiveInterpreter.__init__(self, locals=locals)
                self.initialized = True
            try:
                if self.runsource(self.block + '\n' + text) and text != '':
                    self.otext['text'] = '.'
                    self.block += '\n' + text
                else:
                    self.otext['text'] = ':'
                    self.block = ''
            except Exception:  # Not just "except", it will also catch SystemExit
                # Whoops! Print out a traceback.
                self.writeErr(traceback.format_exc())
Beispiel #17
0
 def __init__(self, locals=None, rawin=None,
              stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
              showInterpIntro=True):
     """Create an interactive interpreter object."""
     InteractiveInterpreter.__init__(self, locals=locals)
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
     if rawin:
         from six.moves import builtins
         builtins.raw_input = rawin
         del builtins
     if showInterpIntro:
         copyright = 'Type "help", "copyright", "credits" or "license"'
         copyright += ' for more information.'
         self.introText = 'Python %s on %s%s%s' % \
                          (sys.version, sys.platform, os.linesep, copyright)
     try:
         sys.ps1
     except AttributeError:
         sys.ps1 = '>>> '
     try:
         sys.ps2
     except AttributeError:
         sys.ps2 = '... '
     self.more = 0
     # List of lists to support recursive push().
     self.commandBuffer = []
     self.startupScript = None
 def __init__(self, tkconsole):
     self.tkconsole = tkconsole
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
     self.restarting = False
     self.subprocess_arglist = None
     self.original_compiler_flags = self.compile.compiler.flags
Beispiel #19
0
 def __init__(self, stdin, stdout, locals=None):
     QObject.__init__(self)
     InteractiveInterpreter.__init__(self, locals)
     self.locals['exit'] = Exit()
     self.stdin = stdin
     self.stdout = stdout
     self._executing = False
     self.compile = partial(compile_multi, self.compile)
    def __init__(self, app):
        InteractiveInterpreter.__init__(
            self,
            vdict({
                "app": app,
                "plot": plot.plot
            },
                  setitem=self.setitem,
                  delitem=self.delitem))

        self.frame = tk.Frame(app,
                              padx=16,
                              pady=8,
                              background=Color.DARK_BLACK)

        Text.__init__(self,
                      self.frame,
                      readonly=True,
                      background=Color.DARK_BLACK,
                      font=FONT,
                      padx=0,
                      pady=0,
                      wrap="word",
                      cursor="arrow",
                      insertbackground=Color.DARK_BLACK)

        sys.displayhook = self.write
        sys.excepthook = self.showtraceback
        __builtins__["print"] = self.write
        __builtins__["help"] = Help(app)
        __builtins__["clear"] = Clear(self)
        __builtins__[
            "copyright"] = "Copyright (c) 2018-2021 Matt Calhoun.\nAll Rights Reserved."
        __builtins__[
            "credits"] = "Created by Matt Calhoun.\nSee https://mathinspector.com for more information."
        __builtins__["license"] = License()

        self.app = app
        self.prompt = Prompt(self, self.frame)
        self.parse = CodeParser(app)
        self.buffer = []
        self.prevent_module_import = False

        self.bind("<Key>", self._on_key_log)
        self.bind("<Configure>", self.prompt.on_configure_log)
        self.bind("<ButtonRelease-1>", self.on_click_log)
        self.pack(fill="both", expand=True)

        for i in ["error_file"]:
            self.tag_bind(i,
                          "<Motion>",
                          lambda event, key=i: self._motion(event, key))
            self.tag_bind(i,
                          "<Leave>",
                          lambda event, key=i: self._leave(event, key))
            self.tag_bind(i,
                          "<Button-1>",
                          lambda event, key=i: self._click(event, key))
Beispiel #21
0
    def __init__(self, element):
        InteractiveInterpreter.__init__(self)
        self.element = element
        self.buffer = ''
        self.stream = DOMInterpreter.Stream(self)
        self.source = []

        self.write('pyglet interpreter\n')
        self.write('>>> ')
Beispiel #22
0
 def __init__(self, tkconsole):
     self.tkconsole = tkconsole
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
     self.restarting = False
     self.subprocess_arglist = None
     self.port = PORT
     self.original_compiler_flags = self.compile.compiler.flags
Beispiel #23
0
 def __init__(self, queue, local={}):
     if '__name__' not in local:
         local['__name__'] = '__console__'
     if '__doc__' not in local:
         local['__doc__'] = None
     self.out_queue = queue
     sys.stdout = DummyFile('stdout', queue)
     sys.stderr = DummyFile('sdterr', queue)
     InteractiveInterpreter.__init__(self, locals=local)
Beispiel #24
0
    def __init__(self, element):
        InteractiveInterpreter.__init__(self)
        self.element = element
        self.buffer = ''
        self.stream = DOMInterpreter.Stream(self)
        self.source = []

        self.write('pyglet interpreter\n')
        self.write('>>> ')
Beispiel #25
0
    def __init__(self, namespace=None):
        if namespace is not None:
            namespace = namespace()

        InteractiveInterpreter.__init__(self, namespace)
        self.output_trap = OutputTrap()
        self.completer = Completer(self.locals)
        self.input_count = 0
        self.interrupted = False
Beispiel #26
0
 def __init__(self, queue, local={}):
     if '__name__' not in local:
         local['__name__'] = '__console__'
     if '__doc__' not in local:
         local['__doc__'] = None
     self.out_queue = queue
     sys.stdout = DummyFile('stdout', queue)
     sys.stderr = DummyFile('sdterr', queue)
     InteractiveInterpreter.__init__(self, locals=local)
Beispiel #27
0
    def __init__(self, namespace=None):
        if namespace is not None:
            namespace = namespace()

        InteractiveInterpreter.__init__(self, namespace)
        self.output_trap = OutputTrap()
        self.completer = Completer(self.locals)
        self.input_count = 0
        self.interrupted = False
Beispiel #28
0
 def __init__(self, local={}):
     self.stdout = sys.stdout
     self.stdout_cache = FileCacher()
     self.stderr = sys.stderr
     self.stderr_cache = FileCacher()
     
     # Define minimum local variables to sub shell.
     if '__name__' not in local: local['__name__'] = '__kaap__'
     if '__doc__' not in local: local['__doc__'] = None
     
     InteractiveInterpreter.__init__(self, local)
     return
Beispiel #29
0
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
        InteractiveInterpreter.__init__(self, None)
        self.setupUi(self)
        self.name = self.windowTitle()
        self.log = log or ''
        self.__canwrite = True

        if parent is None:
            self.eofKey = Qt.Key_D
        else:
            self.eofKey = None

        self.line = QString()
        self.lines = []
        self.point = 0
        self.more = 0
        self.reading = 0
        self.history = []
        self.pointer = 0
        self.cursor_pos = 0
        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")
        self.strcolor = QColor("red")

        self.redirect = RedirectIO()
        self.sig = "IIputtext(QString)"
        self.connect(self, SIGNAL(self.sig),
                     self.sputtext)  #, Qt.QueuedConnection)
        self.connect(self, SIGNAL("Iputtext(QString)"), self.puttext)
        self.redirect.addparent(
            self,
            ["dff.ui.gui.widget.interpreter", "code", "__console__", "pydoc"])

        self.ps1 = ">>> "
        self.ps2 = "... "
        self.writePrompt()
        api_imports = [
            "from dff.api.types.libtypes import Variant, VList, VMap, DateTime, typeId, Argument, Parameter, ConfigManager, Constant, Config, Path",
            "from dff.api.vfs.vfs import vfs",
            "from dff.api.vfs.libvfs import VFS, FileMapping, ABSOLUTE_ATTR_NAME, RELATIVE_ATTR_NAME",
            "from dff.api.filters.libfilters import Filter",
            "from dff.api.search.libsearch import Search",
            "from dff.api.events.libevents import EventHandler, event",
            "from dff.api.datatype.libdatatype import DataTypeManager, DataTypeHandler",
            "from dff.api.loader.loader import loader",
            "from dff.api.module.module import Module, Script",
            "from dff.api.taskmanager.taskmanager import TaskManager"
        ]
        for api_import in api_imports:
            self.more = self.runsource(api_import)
Beispiel #30
0
	def __init__(self, console_widget, locals = {}):
	
		self.__console_widget = console_widget
			
		self.__ps1 = ">>> " 
		self.__ps2 = "... "
		self.__ps = self.__ps1
		self.__partial_source = ""
		
		# se encarga de ejecutar los comandos
		self.__command_procesor = ItemProcesorPipeline(1)
		
		self.__locals = self.__init_locals(locals)
		InteractiveInterpreter.__init__(self, locals)
Beispiel #31
0
 def __init__(self, **kwargs):
     self.service = client.connect(**kwargs)
     self.delete = self.service.delete
     self.get = self.service.get
     self.post = self.service.post
     locals = {
         'service': self.service,
         'connect': client.connect,
         'delete': self.delete,
         'get': self.get,
         'post': self.post,
         'load': self.load,
     }
     InteractiveInterpreter.__init__(self, locals)
Beispiel #32
0
 def __init__(self, tkconsole):
 
     self.tkconsole = tkconsole # Required by later rpc registrations.
     
     self.active_seq = None
     self.port = 8833
     self.rpcclt = None
     self.rpcpid = None
     
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
     self.restarting = False
 
     self.subprocess_arglist = self.build_subprocess_arglist()
Beispiel #33
0
	def __init__(self, locals=None, banner=None):
		InteractiveInterpreter.__init__(self, locals)

		sys.stdout = FauxFile(self, _stdout_style)
		sys.stderr = FauxFile(self, _stderr_style)

		# copyright/banner message
		if banner is None:
			pass
		#	self.write("Python %s on %s\n" % #%s\n(%s)\n" %
		#			   (sys.version, sys.platform,
		#				#sys.copyright, self.__class__.__name__
		#				))
		else:
			self.write("%s\n" % banner)
Beispiel #34
0
    def __init__(self, parent=None, log=""):
        QTextEdit.__init__(self, parent)
        InteractiveInterpreter.__init__(self, None)
        self.setupUi(self)
        self.name = self.windowTitle()
        self.log = log or ""
        self.__canwrite = True

        if parent is None:
            self.eofKey = Qt.Key_D
        else:
            self.eofKey = None

        self.line = QString()
        self.lines = []
        self.point = 0
        self.more = 0
        self.reading = 0
        self.history = []
        self.pointer = 0
        self.cursor_pos = 0
        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")
        self.strcolor = QColor("red")

        self.redirect = RedirectIO()
        self.sig = "Iputtext"
        self.connect(self, SIGNAL(self.sig), self.puttext)
        self.redirect.addparent(self, ["ui.gui.widget.interpreter", "code", "__console__", "pydoc"])

        self.ps1 = ">>> "
        self.ps2 = "... "
        self.writePrompt()
        api_imports = [
            "from api.types.libtypes import Variant, VList, VMap, vtime, typeId, Argument, Parameter, ConfigManager, Constant, Config, Path",
            "from api.vfs.vfs import vfs",
            "from api.vfs.libvfs import VFS, FileMapping, ABSOLUTE_ATTR_NAME, RELATIVE_ATTR_NAME",
            "from api.filters.libfilters import Filter",
            "from api.search.libsearch import Search",
            "from api.events.libevents import EventHandler, event",
            "from api.datatype.libdatatype import DataTypeManager, DataTypeHandler",
            "from api.loader.loader import loader",
            "from api.module.module import Module, Script",
            "from api.magic.libmagichandler import MagicType, MimeType",
            "from api.taskmanager.taskmanager import TaskManager",
        ]
        for api_import in api_imports:
            self.more = self.runsource(api_import)
Beispiel #35
0
	def __init__(self, parent=None):
		QtGui.QTextEdit.__init__(self, parent)
		InteractiveInterpreter.__init__(self, locals=None)

		self.stdout = OutputCatcher()

		self.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
		self.setAcceptDrops(False)
		self.setMinimumSize(30, 30)
		self.setUndoRedoEnabled(False)
		self.setAcceptRichText(False)
		monofont = QtGui.QFont("Monospace")
		monofont.setStyleHint(QtGui.QFont.TypeWriter)
		self.setFont(monofont)

		self.buffer = []

		self.displayPrompt(False)

		self.history = QtCore.QStringList()
		self.historyIndex = 0
Beispiel #36
0
    def __init__(self, owner=None, locals=None, rawin=None, 
                 stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
        """Create an interactive interpreter object."""

        self.bt = BTcomm()
        
        InteractiveInterpreter.__init__(self, locals=locals)
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr
        if rawin:
            import __builtin__
            __builtin__.raw_input = rawin
            del __builtin__
        copyright = 'Type "help", "copyright", "credits" or "license"'
        copyright += ' for more information.'
        self.introText = 'Python %s on %s%s%s' % \
                         (sys.version, sys.platform, os.linesep, copyright)
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = '>>> '
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = '... '
        self.more = 0
        # List of lists to support recursive push().
        self.commandBuffer = []
        self.startupScript = None
        #self.first = True

        # the class that instantiates this, here phoneshell
        self.owner = owner
        # create a frame for snapshot images
        self.snapshot = SnapFrame( owner )

        # make sure we'll get a fresh interpreter at the phone end
        self.bt.send( 'reset' )
Beispiel #37
0
    def __init__(self, evScheduler_, locals_=None, filename="<console>"):
        """Constructor.

        The optional locals argument will be passed to the
        InteractiveInterpreter base class.

        The optional filename argument should specify the (file)name
        of the input stream; it will show up in tracebacks.
        """
        InteractiveInterpreter.__init__(self, locals_)
        self.filename = filename
        self.buffer = []

        if not hasattr(sys, 'ps1'):
            sys.ps1 = ">>> "
        if not hasattr(sys, 'ps2'):
            sys.ps2 = "... "

        self.more = 0
        self.loop = False
        self.evScheduler = evScheduler_
        self.postThread = PostThread()
Beispiel #38
0
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
	InteractiveInterpreter.__init__(self, None)
        self.log = log or ''

        if parent is None:
            self.eofKey = Qt.Key_D
        else:
            self.eofKey = None
       
        self.line    = QString()
        self.lines   = []
        self.point   = 0
        self.more    = 0
        self.reading = 0
        self.history = []
        self.pointer = 0
        self.cursor_pos   = 0
        self.bgcolor = QColor("black")
        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")
        self.strcolor = QColor("red")
        pal = QPalette()
        pal.setColor(pal.Base, self.bgcolor)
        pal.setColor(pal.Text, self.fgcolor)
        self.setPalette(pal)

	self.redirect = RedirectIO()
	self.sig = "Iputtext"
	self.connect(self, SIGNAL(self.sig), self.puttext)
	self.redirect.addparent(self, ["ui.gui.widget.interpreter", "code", "__console__", "pydoc"])

        self.ps1 = ">>> "
        self.ps2 = "... "
        self.write('Python Interpreter\n')
        self.write(self.ps1)
        self.more = self.runsource("from api.vfs import *; v = vfs.vfs()")
    def command(self, text):
        if not self.hidden:
            self.cscroll = None
            self.command = ''
            self.entry.set('')
            self.entry['focus'] = True
            self.writeOut(self.otext['text'] + ' ' + text + '\n', False)
            if text != '' and (len(self.commands) == 0 or self.commands[-1] != text):
                self.commands.append(text)

            # Insert plugins into the local namespace
            locals = __main__.__dict__
            for plugin in manager.getNamed().keys():
                locals[plugin] = manager.getNamed()[plugin]
            locals['panda3d'] = panda3d

            #register custom commands
            locals['reload'] = manager.reload
            locals['load'] = manager.transition
            locals['wireframe'] = base.toggleWireframe
            locals['trigger'] = events.triggerEvent

            # Run it and print the output.
            if not self.initialized:
                InteractiveInterpreter.__init__(self, locals=locals)
                self.initialized = True
            try:
                if self.runsource(self.block + '\n' + text) and text != '':
                    self.otext['text'] = '.'
                    self.block += '\n' + text
                else:
                    self.otext['text'] = ':'
                    self.block = ''
            except Exception:  # Not just "except", it will also catch SystemExit
                # Whoops! Print out a traceback.
                self.writeErr(traceback.format_exc())
    def __init__(self,
                 locals=None,
                 rawin=None,
                 stdin=sys.stdin,
                 stdout=sys.stdout,
                 stderr=sys.stderr,
                 showInterpIntro=True):
        """Create an interactive interpreter object."""
        if not locals:
            locals = {}
        locals['connect'] = self.connect
        InteractiveInterpreter.__init__(self, locals=locals)
        self.lua_locals = {}
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr
        if rawin:
            import __builtin__
            __builtin__.raw_input = rawin
            del __builtin__
        if showInterpIntro:
            self.introText = 'Inspect the ejoy2dx client'
        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = '>>> '
        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = '... '
        self.more = 0
        # List of lists to support recursive push().
        self.commandBuffer = []
        self.startupScript = None

        self.socket = None
Beispiel #41
0
 def __init__(self, tkconsole):
     self.tkconsole = tkconsole
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)
     self.save_warnings_filters = None
Beispiel #42
0
 def __init__(self, read_fd, sock):
     InteractiveInterpreter.__init__(self)
     self._rfd = os.fdopen(read_fd, 'r')
     self._sock = sock
     gobject.io_add_watch(read_fd, GDK_INPUT_READ, self.input_func)
Beispiel #43
0
Datei: bd.py Projekt: lwzm/bb
 def __init__(self):
     InteractiveInterpreter.__init__(self)
     self.buf = []
Beispiel #44
0
 def __init__(self, locals=None):
     InteractiveInterpreter.__init__(self, locals)
     self._outputBrush = None
 def __init__(self, locals=None):
     InteractiveInterpreter.__init__(self, locals)
Beispiel #46
0
 def __init__(self, output_method=None):
     InteractiveInterpreter.__init__(self, sys.modules['__main__'].__dict__)
     if output_method:
         self.output = output_method
     else:
         self.output = self.default_output
Beispiel #47
0
 def __init__(self, read_fd, sock):
     InteractiveInterpreter.__init__(self)
     self._rfd = os.fdopen(read_fd, 'r')
     self._sock = sock
     gobject.io_add_watch(read_fd, GDK_INPUT_READ, self.input_func)
Beispiel #48
0
 def __init__(self, stdout, stderr, interpreter_locals):
     InteractiveInterpreter.__init__(self, interpreter_locals)
     self.stdout = stdout
     self.stderr = stderr
 def __init__(self):
     locals = {"__name__": "__console__", "__doc__": None, "type": typePar}
     InteractiveInterpreter.__init__(self, locals)
Beispiel #50
0
 def __init__(self):
     locals = {"__name__": "__console__",
               "__doc__": None,
               "type": typePar}
     InteractiveInterpreter.__init__(self, locals)
Beispiel #51
0
 def __init__(self, write_cb, local):
     self.write_cb = write_cb
     self.evaluator = Evaluator()
     InteractiveInterpreter.__init__(self)
Beispiel #52
0
 def __init__(self, console, locals):
     InteractiveInterpreter.__init__(self, locals)
     self.console = console
Beispiel #53
0
 def __init__(self, widget, locals = None):
     InteractiveInterpreter.__init__(self,locals)
     self._widget = widget
     self._outputBrush = None
Beispiel #54
0
 def __init__(self, console, locals):
     InteractiveInterpreter.__init__(self, locals)
     self.console = console
 def __init__(self, locals=None):
     InteractiveInterpreter.__init__(self, locals)
Beispiel #56
0
 def __init__(self):
     locals = sys.modules['__main__'].__dict__
     InteractiveInterpreter.__init__(self, locals=locals)