예제 #1
0
    def __init__(self, lines):
        """"""
        ## Basic application setup.
        self.app = wx.PySimpleApp()
        self.app.frame = wx.Frame(None, title="Hvergelmir")
        self.app.frame.SetSize(wx.Size(1200, 900))
        self.app.frame.CreateStatusBar(1)
        self.frameSizer = wx.BoxSizer(wx.VERTICAL)
        self.frameContents = wx.SplitterWindow(self.app.frame)

        ## Parse Valgrind log file.
        parser = ErrorParser()
        errors, unknowns, pid = parser.parse(lines)
        if errors is None:
            print("Could not read any errors.")
            sys.exit(1)

        self.errorTreeFromBottom = SharedStackError(errors, 0, Stack.FROM_BOTTOM)
        self.errorTreeFromTop = SharedStackError(errors, 0, Stack.FROM_TOP)

        if unknowns is not None:
            print("The parser didn't recognize the following error types:")
            for unknown in unknowns:
                print("  " + unknown)

        ## Create GUI.
        self.treePanel = TreePanel(self.frameContents, self.errorTreeFromBottom, self.errorTreeFromTop)
        self.errorPanel = ErrorPanel(self.frameContents)
        self.frameContents.SplitVertically(self.treePanel, self.errorPanel)
        self.frameSizer.Add(self.frameContents, 1, flag=wx.EXPAND)
        self.app.frame.SetSizer(self.frameSizer)
        self.app.frame.Center()
        self.app.frame.Show()

        ## Define GUI callbacks.
        self.treePanel.setItemSelectedCallback(self.treeItemSelected)

        self.errorPanel.sourceCode.setSourceCode(["Select an error from the list."], None)

        self.app.MainLoop()
예제 #2
0
class Hvergelmir(object):
    """"""

    def __init__(self, lines):
        """"""
        ## Basic application setup.
        self.app = wx.PySimpleApp()
        self.app.frame = wx.Frame(None, title="Hvergelmir")
        self.app.frame.SetSize(wx.Size(1200, 900))
        self.app.frame.CreateStatusBar(1)
        self.frameSizer = wx.BoxSizer(wx.VERTICAL)
        self.frameContents = wx.SplitterWindow(self.app.frame)

        ## Parse Valgrind log file.
        parser = ErrorParser()
        errors, unknowns, pid = parser.parse(lines)
        if errors is None:
            print("Could not read any errors.")
            sys.exit(1)

        self.errorTreeFromBottom = SharedStackError(errors, 0, Stack.FROM_BOTTOM)
        self.errorTreeFromTop = SharedStackError(errors, 0, Stack.FROM_TOP)

        if unknowns is not None:
            print("The parser didn't recognize the following error types:")
            for unknown in unknowns:
                print("  " + unknown)

        ## Create GUI.
        self.treePanel = TreePanel(self.frameContents, self.errorTreeFromBottom, self.errorTreeFromTop)
        self.errorPanel = ErrorPanel(self.frameContents)
        self.frameContents.SplitVertically(self.treePanel, self.errorPanel)
        self.frameSizer.Add(self.frameContents, 1, flag=wx.EXPAND)
        self.app.frame.SetSizer(self.frameSizer)
        self.app.frame.Center()
        self.app.frame.Show()

        ## Define GUI callbacks.
        self.treePanel.setItemSelectedCallback(self.treeItemSelected)

        self.errorPanel.sourceCode.setSourceCode(["Select an error from the list."], None)

        self.app.MainLoop()



    def treeItemSelected(self, data):
        """ Called by the TreePanel when an item is selected. The argument is the
        data that was stored in the selected item. Usually a


        :param data: TreeItemData
        """
        self.errorPanel.errorInfo.clear()

        nearestSourceStackFrame = data.nearestSourceStackFrame
        error = data.parsedError  # ParsedError instance, or None.

        if error is not None:
            self.errorPanel.errorInfo.display(error)

        sourceFilePath = nearestSourceStackFrame.fileName
        if sourceFilePath is None:
            errorMessage = "Unknown file location: " + str(nearestSourceStackFrame.fileName);
            self.setStatusText(errorMessage)
            self.errorPanel.sourceCode.setSourceCode([errorMessage], None)
            return

        lines = fileReader.readFile(sourceFilePath)
        if lines is None:
            errorMessage = "Could not read source code from '" + sourceFilePath + "'.";
            self.setStatusText(errorMessage)
            self.errorPanel.sourceCode.setSourceCode([
                errorMessage,
                "Use the --path command line argument to add additional search directories."],
                None)
            return

        self.errorPanel.sourceCode.setSourceCode(lines, int(nearestSourceStackFrame.lineNumber))

        self.setStatusText(sourceFilePath)


    def setStatusText(self, text):
        if self.app.frame.GetStatusBar().GetStatusText(0) != text:
            self.app.frame.SetStatusText(text, 0)