Exemplo n.º 1
0
Arquivo: shell.py Projeto: vertrex/DFF
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
        self.setupUi(self)
        self.name = self.windowTitle()
        self.hookTermSize()
        Console.__init__(self, sigstp=False)
        self.completion = completion.Completion(self)
        taskmanager = TaskManager()
        self.vfs = vfs.vfs()
        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.pointer = 0
        self.cursor_pos   = 0

        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")

        self.preloop()
        self.redirect = RedirectIO()
        self.sig = "SSputtext(QString)"
        self.connect(self, SIGNAL(self.sig), self.puttext)
        self.connect(self, SIGNAL("Sputtext(QString)"), self.puttext)
        self.redirect.addparent(self, ["dff.ui.gui.widget.shell", "dff.ui.console.console", "dff.ui.console.completion", "dff.ui.console.line_to_arguments", "dff.api.taskmanager.taskmanager", "dff.api.taskmanager.scheduler", "dff.api.taskmanager.processus"], True)
        self.writePrompt()
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
        Console.__init__(self, sigstp=False)
        self.setupUi(self)
        self.name = self.windowTitle()
	self.completion = completion.Completion(self)
        self.hookTermSize()
	taskmanager = TaskManager()
        self.vfs = vfs.vfs()
        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.pointer = 0
        self.cursor_pos   = 0

        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")

        self.preloop()
	self.redirect = RedirectIO()
	self.sig = "Sputtext"
	self.connect(self, SIGNAL(self.sig), self.puttext)
	self.redirect.addparent(self, ["dff.ui.gui.widget.shell", "dff.ui.console.console", "dff.ui.console.completion", "dff.ui.console.line_to_arguments", "dff.api.taskmanager.taskmanager", "dff.api.taskmanager.scheduler", "dff.api.taskmanager.processus"], True)
        self.writePrompt()
Exemplo n.º 4
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, ["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, vtime, 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)
Exemplo n.º 5
0
 def __init__(self, arguments):
     self.arguments = arguments
     if self.arguments:
         self.debug = self.arguments.debug
         self.verbosity = self.arguments.verbosity
     else:
         self.debug = False
         self.verbosity = 0
     RedirectIO(None, self.debug)
     # When UI is initialized from main, arguments are provided
     # When UI is initialized from shell widget, there are no arguments
     if CrashHandlerEnabled and self.arguments and not self.arguments.no_exception_handler:
         self.handler = CrashHandler()
         self.handler.setVersion(VERSION)
         if self.arguments.silent_report:
             self.handler.setSilentReport(True)
         self.handler.setHandler()
     self.loader = loader()
Exemplo n.º 6
0
Arquivo: ui.py Projeto: kzwkt/dff
 def __init__(self, debug=False, verbosity=0):
     self.debug = debug
     self.verbosity = verbosity
     RedirectIO(None, self.debug)
     self.loader = loader()
Exemplo n.º 7
0
class InterpreterView(QTextEdit, InteractiveInterpreter, Ui_Interpreter):
    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,
            ["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, vtime, 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)

    def writePrompt(self):
        self.write('\n')
        self.write(self.ps1)

    def write(self, str):
        self.redirect.write(str)

    def puttext(self, text):
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.End)
        pos1 = cursor.position()
        cursor.insertText(text)
        self.cursor_pos = cursor.position()
        self.setTextCursor(cursor)
        self.ensureCursorVisible()
        cursor.setPosition(pos1, QTextCursor.KeepAnchor)
        format = cursor.charFormat()
        format.setForeground(QBrush(self.fgcolor))
        cursor.setCharFormat(format)

    def get_interpreter(self):
        """ Return the interpreter object """
        return self

    def moveCursor(self, operation, mode=QTextCursor.MoveAnchor):
        """
        Convenience function to move the cursor
        This function will be present in PyQT4.2
        """
        cursor = self.textCursor()
        cursor.movePosition(operation, mode)
        self.setTextCursor(cursor)

    def flush(self):
        pass

    def isatty(self):
        return 1

    def clear(self):
        """ Clear """

    def readline(self):
        self.reading = 1
        self.__clearLine()
        self.moveCursor(QTextCursor.End)
        while self.reading:
            QtGui.qApp.processEvents()
        if self.line.length() == 0:
            return '\n'
        else:
            return str(self.line)

    def writelines(self, text):
        """
        Simulate stdin, stdout, and stderr.
        """
        map(self.write, text)

    def fakeUser(self, lines):
        """
        Simulate a user: lines is a sequence of strings, (Python statements).
        """
        for line in lines:
            self.line = QString(line.rstrip())
            self.write(self.line)
            self.write('\n')
            self.run()

    def runsource_callback(self, source):
        self.__canwrite = False
        self.more = self.runsource(source)
        if self.more:
            self.write(self.ps2)
        else:
            self.write(self.ps1)
            self.lines = []
        self.__clearLine()
        self.__canwrite = True

    def run(self):
        self.pointer = 0
        self.history.append(QString(self.line))
        try:
            self.lines.append(str(self.line))
        except Exception, e:
            print e
        source = '\n'.join(self.lines)
        thread = threading.Thread(target=self.runsource_callback,
                                  args=(source, ))
        thread.start()
Exemplo n.º 8
0
class InterpreterView(QTextEdit, InteractiveInterpreter, Ui_Interpreter):
    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, ["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, vtime, 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)

    def writePrompt(self):
        self.write('\n')
        self.write(self.ps1)
        
    def write(self, str):
	self.redirect.write(str)

    def puttext(self, text):
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.End)
        pos1 = cursor.position()
        cursor.insertText(text)
        self.cursor_pos = cursor.position()
        self.setTextCursor(cursor)
        self.ensureCursorVisible()
        cursor.setPosition(pos1, QTextCursor.KeepAnchor)
        format = cursor.charFormat()
        format.setForeground(QBrush(self.fgcolor))
        cursor.setCharFormat(format)


    def get_interpreter(self):
        """ Return the interpreter object """
	return self

    def moveCursor(self, operation, mode=QTextCursor.MoveAnchor):
        """
        Convenience function to move the cursor
        This function will be present in PyQT4.2
        """
        cursor = self.textCursor()
        cursor.movePosition(operation, mode)
        self.setTextCursor(cursor)

    def flush(self):
        pass

    def isatty(self):
        return 1

    def clear(self):
        """ Clear """

    def readline(self):
        self.reading = 1
        self.__clearLine()
        self.moveCursor(QTextCursor.End)
        while self.reading:
            QtGui.qApp.processEvents()
        if self.line.length() == 0:
            return '\n'
        else:
            return str(self.line) 
    

    def writelines(self, text):
        """
        Simulate stdin, stdout, and stderr.
        """
        map(self.write, text)


    def fakeUser(self, lines):
        """
        Simulate a user: lines is a sequence of strings, (Python statements).
        """
        for line in lines:
            self.line = QString(line.rstrip())
            self.write(self.line)
            self.write('\n')
            self.run()

    def runsource_callback(self, source):
        self.__canwrite = False
        self.more = self.runsource(source)
        if self.more:
            self.write(self.ps2)
        else:
            self.write(self.ps1)
            self.lines = []
        self.__clearLine()
        self.__canwrite = True


    def run(self):
        self.pointer = 0
        self.history.append(QString(self.line))
        try:
            self.lines.append(str(self.line))
        except Exception,e:
            print e
	source = '\n'.join(self.lines)
        thread = threading.Thread(target=self.runsource_callback, args=(source, ))
        thread.start()
Exemplo n.º 9
0
Arquivo: shell.py Projeto: vertrex/DFF
class ShellView(QTextEdit, Console, Ui_Shell):
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
        self.setupUi(self)
        self.name = self.windowTitle()
        self.hookTermSize()
        Console.__init__(self, sigstp=False)
        self.completion = completion.Completion(self)
        taskmanager = TaskManager()
        self.vfs = vfs.vfs()
        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.pointer = 0
        self.cursor_pos   = 0

        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")

        self.preloop()
        self.redirect = RedirectIO()
        self.sig = "SSputtext(QString)"
        self.connect(self, SIGNAL(self.sig), self.puttext)
        self.connect(self, SIGNAL("Sputtext(QString)"), self.puttext)
        self.redirect.addparent(self, ["dff.ui.gui.widget.shell", "dff.ui.console.console", "dff.ui.console.completion", "dff.ui.console.line_to_arguments", "dff.api.taskmanager.taskmanager", "dff.api.taskmanager.scheduler", "dff.api.taskmanager.processus"], True)
        self.writePrompt()


    def hookTermSize(self):
        ca = getattr(sys.modules['dff.ui.console.utils'], "ConsoleAttributes")
        nt = getattr(ca, "_ConsoleAttributes__nt")
        posix = getattr(ca, "_ConsoleAttributes__posix")
        setattr(nt, "terminalSize", self.get_term_size)
        setattr(posix, "terminalSize", self.get_term_size)


    def writePrompt(self):
        self.cwd = self.vfs.getcwd()
        self.ps1 = self.cwd.absolute() + " > "
        self.write('\n')
        self.write(self.ps1)

    def write(self, str):
      self.redirect.write(str)

    def sputtext(self, text):
      self.emit(SIGNAL("Sputext(QString)"), text)

    def puttext(self, text):
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.End)
        pos1 = cursor.position()
        cursor.insertText(text)
        self.cursor_pos = cursor.position()
        self.setTextCursor(cursor)
        self.ensureCursorVisible()
        cursor.setPosition(pos1, QTextCursor.KeepAnchor)
        format = cursor.charFormat()
        format.setForeground(QBrush(self.fgcolor))
        cursor.setCharFormat(format)


    def get_interpreter(self):
        return self.interpreter

    def moveCursor(self, operation, mode=QTextCursor.MoveAnchor):
        cursor = self.textCursor()
        cursor.movePosition(operation, mode)
        self.setTextCursor(cursor)

    def flush(self):
        pass

    def isatty(self):
        return 1

    def clear(self):
      pass

    def readline(self):
        self.reading = 1
        self.__clearLine()
        self.moveCursor(QTextCursor.End)
        while self.reading:
            QtGui.qApp.processEvents()
        if self.line.length() == 0:
            return '\n'
        else:
            return str(self.line) 
    
    def writelines(self, text):
        map(self.write, text)

    def fakeUser(self, lines):
        for line in lines:
            self.line = QString(line.rstrip())
            self.write(self.line)
            self.write('\n')
            self.run()

    def run(self):
        self.pointer = 0
        try:
            self.lines.append(str(self.line))
        except Exception,e:
            print e
        line = '\n'.join(self.lines)
        line = self.precmd(line)
        stop = self.onecmd(line, True)
        stop = self.postcmd(stop, line)
        self.cwd = self.vfs.getcwd()
        self.ps1 = self.cwd.absolute() + " > "
        if self.more:
            self.write(self.ps2)
        else:
            self.write(self.ps1)
            self.lines = []
        self.__clearLine()
Exemplo n.º 10
0
class ShellView(QTextEdit, Console, Ui_Shell):
    def __init__(self, parent=None, log=''):
        QTextEdit.__init__(self, parent)
        Console.__init__(self, sigstp=False)
        self.setupUi(self)
        self.name = self.windowTitle()
	self.completion = completion.Completion(self)
        self.hookTermSize()
	taskmanager = TaskManager()
        self.vfs = vfs.vfs()
        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.pointer = 0
        self.cursor_pos   = 0

        self.fgcolor = QColor("white")
        self.selcolor = QColor("green")

        self.preloop()
	self.redirect = RedirectIO()
	self.sig = "Sputtext"
	self.connect(self, SIGNAL(self.sig), self.puttext)
	self.redirect.addparent(self, ["dff.ui.gui.widget.shell", "dff.ui.console.console", "dff.ui.console.completion", "dff.ui.console.line_to_arguments", "dff.api.taskmanager.taskmanager", "dff.api.taskmanager.scheduler", "dff.api.taskmanager.processus"], True)
        self.writePrompt()


    def hookTermSize(self):
        ca = getattr(sys.modules['dff.ui.console.utils'], "ConsoleAttributes")
        nt = getattr(ca, "_ConsoleAttributes__nt")
        posix = getattr(ca, "_ConsoleAttributes__posix")
        setattr(nt, "terminalSize", self.get_term_size)
        setattr(posix, "terminalSize", self.get_term_size)


    def writePrompt(self):
        self.cwd = self.vfs.getcwd()
        self.ps1 = self.cwd.absolute() + " > "
        self.write('\n')
        self.write(self.ps1)

    def write(self, str):
	self.redirect.write(str)

    def puttext(self, text):
        cursor = self.textCursor()
        cursor.movePosition(QTextCursor.End)
        pos1 = cursor.position()
        cursor.insertText(text)
        self.cursor_pos = cursor.position()
        self.setTextCursor(cursor)
        self.ensureCursorVisible()
        cursor.setPosition(pos1, QTextCursor.KeepAnchor)
        format = cursor.charFormat()
        format.setForeground(QBrush(self.fgcolor))
        cursor.setCharFormat(format)


    def get_interpreter(self):
        return self.interpreter

    def moveCursor(self, operation, mode=QTextCursor.MoveAnchor):
        cursor = self.textCursor()
        cursor.movePosition(operation, mode)
        self.setTextCursor(cursor)

    def flush(self):
        pass

    def isatty(self):
        return 1

    def clear(self):
	pass

    def readline(self):
        self.reading = 1
        self.__clearLine()
        self.moveCursor(QTextCursor.End)
        while self.reading:
            QtGui.qApp.processEvents()
        if self.line.length() == 0:
            return '\n'
        else:
            return str(self.line) 
    
    def writelines(self, text):
        map(self.write, text)

    def fakeUser(self, lines):
        for line in lines:
            self.line = QString(line.rstrip())
            self.write(self.line)
            self.write('\n')
            self.run()

    def run(self):
        self.pointer = 0
        try:
            self.lines.append(str(self.line))
        except Exception,e:
            print e
        line = '\n'.join(self.lines)
	line = self.precmd(line)
	stop = self.onecmd(line, True)
        stop = self.postcmd(stop, line)
	self.cwd = self.vfs.getcwd()
	self.ps1 = self.cwd.absolute() + " > "
        if self.more:
            self.write(self.ps2)
        else:
            self.write(self.ps1)
            self.lines = []
        self.__clearLine()