コード例 #1
0
    def getList(self, D):
        """ Return list to populate de virtualList
		"""

        tempdir = tempfile.gettempdir()

        L = []
        if D:
            for k, v in D.items():

                path = ""
                line = ""

                if tempdir in os.path.dirname(k.python_path):
                    ### append infos
                    L.append((k.label, _("Temporary python file!"), "", "",
                              k.python_path))
                elif v:
                    typ, val, tb = v
                    list = format_exception(typ, val, tb)
                    ### reverse because we want the last error of the traceback
                    list.reverse()
                    ### find the line containing the 'line' word
                    for s in list:
                        if 'line ' in s:
                            path, line = s.split(',')[0:2]
                            break

                    ### erase whitespace and clear the Line word and the File word
                    python_path = str(path.split(' ')[-1].strip())[1:-1]
                    line_number = line.split(' ')[-1].strip()

                    ### find mail from doc of module
                    module = Components.BlockFactory.GetModule(python_path)
                    doc = module.__doc__ or ""
                    mails = GetMails(doc) if inspect.ismodule(module) else []

                    ### append the error information
                    L.append(
                        (k.label, str(val), line_number, mails, python_path))

        return VirtualList(self, dict(zip(range(len(L)), L))) if L != [] else L
コード例 #2
0
    def __init__(self, parent, D):
        """ Constructor.
		"""
        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          _("DEVS Model Checking"),
                          size=(900, 400),
                          style=wx.DEFAULT_FRAME_STYLE)

        icon = wx.EmptyIcon() if wx.VERSION_STRING < '4.0' else wx.Icon()
        icon.CopyFromBitmap(
            wx.Bitmap(os.path.join(ICON_PATH_16_16, "check_master.png"),
                      wx.BITMAP_TYPE_ANY))
        self.SetIcon(icon)

        #self.CreateStatusBar(1)

        ##############################################" comment for unitest
        ### prepare dictionary
        L = []
        for k, v in D.items():

            path = ""
            line = ""
            if v is None:
                ### find mail from doc of module
                module = Components.BlockFactory.GetModule(k.python_path)
                doc = module.__doc__ or ""
                mails = GetMails(doc) if inspect.ismodule(module) else []

                ### append infos
                L.append((k.label, "", "", mails, k.python_path))
            else:
                typ, val, tb = v
                list = format_exception(typ, val, tb)
                ### reverse because we want the last error of the traceback
                list.reverse()
                ### find the line containing the 'line' word
                for s in list:
                    if 'line ' in s:
                        path, line = s.split(',')[0:2]
                        break

                ### erase whitespace and clear the Line word and the File word
                python_path = str(path.split(' ')[-1].strip())[1:-1]
                line_number = line.split(' ')[-1].strip()

                ### find mail from doc of module
                module = Components.BlockFactory.GetModule(python_path)
                doc = module.__doc__ or ""
                mails = GetMails(doc) if inspect.ismodule(module) else []

                ### append the error information
                L.append((k.label, str(val), line_number, mails, python_path))

        self.list = VirtualList(self, dict(zip(range(len(L)), L)))
        #################################################

        ### decomment for unitest
        #self.list = VirtualList(self,D)

        hsizer = wx.StdDialogButtonSizer()  #wx.BoxSizer(wx.HORIZONTAL)
        vsizer = wx.BoxSizer(wx.VERTICAL)

        close_btn = wx.Button(self, wx.ID_CLOSE)
        ok_btn = wx.Button(self, wx.ID_OK)
        update_btn = wx.Button(self, wx.ID_REFRESH)

        hsizer.Add(close_btn)
        hsizer.Add(update_btn)
        hsizer.Add(ok_btn)
        hsizer.Realize()

        vsizer.Add(self.list, 1, wx.EXPAND, 10)
        vsizer.Add(hsizer, 0, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=10)

        self.SetSizer(vsizer)
        self.Center()

        ### just for windows
        e = wx.SizeEvent(self.GetSize())
        self.ProcessEvent(e)

        self.Bind(wx.EVT_BUTTON, self.OnClose, id=close_btn.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=ok_btn.GetId())
        self.Bind(wx.EVT_BUTTON, self.OnUpdate, id=update_btn.GetId())