コード例 #1
0
    def CompareRevisions(self,
                         path,
                         rev1=None,
                         date1=None,
                         rev2=None,
                         date2=None):
        """
        Compare the playpen path to a specific revision, or compare two
        revisions

        Required Arguments:
        path -- absolute path of file to compare

        Keyword Arguments:
        rev1/date1 -- first file revision/date to compare against
        rev2/date2 -- second file revision/date to compare against

        """
        ed_thread.EdThreadPool().QueueJob(SourceControlTask,
                                          self._parent,
                                          self._parent.Id,
                                          self.Diff,
                                          ppEVT_DIFF_COMPLETE,
                                          args=(path, ),
                                          kwargs=dict(rev1=rev1,
                                                      date1=date1,
                                                      rev2=rev2,
                                                      date2=date2))
コード例 #2
0
    def UpdatePathStatus(self, path):
        """Run an status update job
        @param path: path to check status on

        """
        self.SetCommandRunning(True)
        src_c = self._ctrl.GetSCSystem(path)
        if src_c is not None:
            self._path = path
            ed_thread.EdThreadPool().QueueJob(self._ctrl.StatusWithTimeout,
                                              src_c, None, dict(path=path),
                                              dict(recursive=True))
コード例 #3
0
ファイル: cbrowser.py プロジェクト: nklawi/wxPython
    def OnStartJob(self, evt):
        """Start the tree update job
        
        @param evt: wxTimerEvent

        """
        if self._cpage is None or not isinstance(self._cpage, wx.Window):
            self._cpage = None
            return
        else:
            # Check if its still the current page
            parent = self._cpage.GetParent()
            if self._cpage != parent.GetCurrentPage():
                return

        # Get the generator method
        genfun = TagLoader.GetGenerator(self._cpage.GetLangId())
        self._cjob += 1  # increment job Id

        # Check if we need to do updates
        if genfun is not None and (self._force or self._ShouldUpdate()):
            self._force = False

            # Start progress indicator in pulse mode
            ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW,
                               (self._mw.GetId(), True))
            ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_STATE,
                               (self._mw.GetId(), -1, -1))

            # Create and start the worker thread
            task = TagGenJob(self, self._cjob, genfun,
                             StringIO.StringIO(self._cpage.GetText()))
            ed_thread.EdThreadPool().QueueJob(task.DoTask)
        else:
            self._ClearTree()
            ed_msg.PostMessage(ed_msg.EDMSG_PROGRESS_SHOW,
                               (self._mw.GetId(), False))
            return
コード例 #4
0
ファイル: browser.py プロジェクト: wangdyna/wxPython
    def OnMenu(self, evt):
        """Handle the context menu events for performing
        filesystem operations

        """
        e_id = evt.Id
        path = self._menu.GetUserData('active_node')
        paths = self._menu.GetUserData('selected_nodes')

        def Opener(paths):
            """File opener job
            @param paths: list of paths

            """
            for fname in paths:
                subprocess.call([FILEMAN_CMD, fname])

        if e_id == ID_EDIT:
            self.OpenFiles(paths)
        elif e_id == ID_OPEN:
            ed_thread.EdThreadPool().QueueJob(Opener, paths)
        elif e_id == ID_REVEAL:
            dpaths = [os.path.dirname(fname) for fname in paths]
            dpaths = list(set(dpaths))
            ed_thread.EdThreadPool().QueueJob(Opener, dpaths)
        elif e_id == wx.ID_REFRESH:
            # Refresh the view
            self.RefreshView()
        elif e_id == ID_SEARCH_DIR:
            if len(paths):
                path = paths[0]  # Go off of the first selected item
                if not os.path.isdir(path):
                    path = os.path.dirname(path)
                mdata = dict(mainw=self._mw, lookin=path)
                ed_msg.PostMessage(ed_msg.EDMSG_FIND_SHOW_DLG, mdata)
        elif e_id == ID_GETINFO:
            last = None
            for fname in paths:
                info = ed_mdlg.EdFileInfoDlg(self.TopLevelParent, fname)
                if last is None:
                    info.CenterOnParent()
                else:
                    lpos = last.GetPosition()
                    info.SetPosition((lpos[0] + 14, lpos[1] + 14))
                info.Show()
                last = info
        elif e_id == ID_RENAME:
            item = self._menu.GetUserData('item_id')
            self.EditLabel(item)
        elif e_id == ID_NEW_FOLDER:
            name = wx.GetTextFromUser(_("Enter folder name:"),
                                      _("New Folder"),
                                      parent=self.TopLevelParent)
            if name:
                err, msg = ebmlib.MakeNewFolder(path, name)
                if not err:
                    wx.MessageBox(msg,
                                  _("Failed to create folder"),
                                  style=wx.OK | wx.CENTER | wx.ICON_ERROR)

        elif e_id == ID_NEW_FILE:
            name = wx.GetTextFromUser(_("Enter file name:"),
                                      _("New File"),
                                      parent=self.TopLevelParent)
            if name:
                err, msg = ebmlib.MakeNewFile(path, name)
                if not err:
                    wx.MessageBox(msg,
                                  _("Failed to create file"),
                                  style=wx.OK | wx.CENTER | wx.ICON_ERROR)
        elif e_id == ID_DUPLICATE:
            for fname in paths:
                DuplicatePath(fname)
        elif e_id == ID_ARCHIVE:
            MakeArchive(path)
        elif e_id == ID_DELETE:
            ebmlib.MoveToTrash(paths)
        else:
            evt.Skip()
            return
コード例 #5
0
        self.setDaemon(True)

    def pass_parameter(self, param):
        self.param = param

    def run(self):
        try:
            data = self.fn(*self.args, **self.kwargs)
        except Exception, msg:
            util.Log("[%s][err] %s Failure: %s" % (self.desc, self.desc, msg))
            data = [(u"Error", unicode(msg), -1)]
        if self.target:
            if self.param is not None:
                wx.CallAfter(self.target, data, self.param)
            else:
                wx.CallAfter(self.target, data)


def RunAsyncTask(desc, target, fn, *args, **kwargs):
    """Delegate a long running task to Editra's threadpool"""
    def DoTask():
        try:
            data = fn(*args, **kwargs)
        except Exception, msg:
            util.Log("[%s][err] %s Failure: %s" % (desc, desc, msg))
            data = [(u"Error", unicode(msg), -1)]
        if target:
            wx.CallAfter(target, data)

    ed_thread.EdThreadPool().QueueJob(DoTask)