Beispiel #1
0
 def startSmart(self):
     if self.state != KSmartTray.State.Waiting:
         KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                             "There is a running process.")
     else:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(False)
         self.process.resetAll()
         self.process.setArguments(["kdesu", "-d", "-c", "smart --gui"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                 "Couldn't run 'smart'.")
         else:
             self.state = KSmartTray.State.RunningSmart
             QToolTip.remove(self.sysTray)
             QToolTip.add(self.sysTray, "Running Smart Package Manager...")
 def startSmart(self):
     if self.state != KSmartTray.State.Waiting:
         KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                              "There is a running process.")
     else:
         self.sysTray.checkAction.setEnabled(False)
         self.sysTray.startSmartAction.setEnabled(False)
         self.sysTray.stopAction.setEnabled(False)
         self.process.resetAll()
         self.process.setArguments(["kdesu", "-d", "-c", "smart --gui"])
         if not self.process.start():
             KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                  "Couldn't run 'smart'.")
         else:
             self.state = KSmartTray.State.RunningSmart
             QToolTip.remove(self.sysTray)
             QToolTip.add(self.sysTray, "Running Smart Package Manager...")
Beispiel #3
0
    def processDone(self, process):
        if self.state == KSmartTray.State.Updating:
            if not process.normalExit() or process.exitStatus() != 0:
                self.updateFailed = True
            if self.updateFailed and not self.lastKnownStatus == "":
                self.state = KSmartTray.State.Waiting
            else:
                process.resetAll()
                process.setArguments(["smart", "upgrade", "--check-update"])
                if not process.start():
                    KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                        "Couldn't run 'smart upgrade'.")
                    self.state = KSmartTray.State.Waiting
                    self.lastKnownStatus = ""
                else:
                    QToolTip.remove(self.sysTray)
                    QToolTip.add(self.sysTray,
                                 "Verifying upgradable packages...")
                    self.state = KSmartTray.State.Checking
        elif self.state == KSmartTray.State.Checking:
            self.state = KSmartTray.State.Waiting
            if process.normalExit():
                if process.exitStatus() == 0:
                    self.lastKnownStatus = "There are new upgrades available!"
                    KNotifyClient.event(self.sysTray.winId(),
                                        "found-new-upgrades",
                                        self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNewUpgrades()"), ())
                elif process.exitStatus() == 1:
                    self.lastKnownStatus = "There are pending upgrades!"
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                            "found-old-upgrades",
                                            self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundOldUpgrades()"), ())
                elif process.exitStatus() == 2:
                    self.lastKnownStatus = "No interesting upgrades available."
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                            "found-no-upgrades",
                                            self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNoUpgrades()"), ())
                else:
                    self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.Upgrading:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.RunningSmart:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        else:
            # Error!
            pass

        if self.state == KSmartTray.State.Waiting:
            self.updateFailed = False
            self.sysTray.checkAction.setEnabled(True)
            self.sysTray.startSmartAction.setEnabled(True)
            self.sysTray.stopAction.setEnabled(False)
            if not self.lastKnownStatus == "":
                QToolTip.remove(self.sysTray)
                QToolTip.add(self.sysTray, self.lastKnownStatus)
            else:
                QToolTip.remove(self.sysTray)
    def processDone(self, process):
        if self.state == KSmartTray.State.Updating:
            if not process.normalExit() or process.exitStatus() != 0:
                self.updateFailed = True
            if self.updateFailed and not self.lastKnownStatus == "":
                self.state = KSmartTray.State.Waiting
            else:
                process.resetAll()
                process.setArguments(["smart", "upgrade", "--check-update"])
                if not process.start():
                    KNotifyClient.event(self.sysTray.winId(), "fatalerror",
                                         "Couldn't run 'smart upgrade'.")
                    self.state = KSmartTray.State.Waiting
                    self.lastKnownStatus = ""
                else:
                    QToolTip.remove(self.sysTray)
                    QToolTip.add(self.sysTray,
                                  "Verifying upgradable packages...")
                    self.state = KSmartTray.State.Checking
        elif self.state == KSmartTray.State.Checking:
            self.state = KSmartTray.State.Waiting
            if process.normalExit():
                if process.exitStatus() == 0:
                    self.lastKnownStatus = "There are new upgrades available!"
                    KNotifyClient.event(self.sysTray.winId(), "found-new-upgrades",
                                         self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNewUpgrades()"), ())
                elif process.exitStatus() == 1:
                    self.lastKnownStatus = "There are pending upgrades!"
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                             "found-old-upgrades",
                                             self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundOldUpgrades()"), ())
                elif process.exitStatus() == 2:
                    self.lastKnownStatus = "No interesting upgrades available."
                    if not self.updateFailed:
                        KNotifyClient.event(self.sysTray.winId(),
                                             "found-no-upgrades",
                                             self.lastKnownStatus)
                    self.emit(PYSIGNAL("foundNoUpgrades()"), ())
                else:
                    self.lastKnownStatus = ""
        elif self.state == KSmartTray.State.Upgrading:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        elif self.state ==  KSmartTray.State.RunningSmart:
            self.state = KSmartTray.State.Waiting
            self.lastKnownStatus = ""
        else:
            # Error!
            pass

        if self.state == KSmartTray.State.Waiting:
            self.updateFailed = False
            self.sysTray.checkAction.setEnabled(True)
            self.sysTray.startSmartAction.setEnabled(True)
            self.sysTray.stopAction.setEnabled(False)
            if not self.lastKnownStatus == "":
                QToolTip.remove(self.sysTray)
                QToolTip.add(self.sysTray, self.lastKnownStatus)
            else:
                QToolTip.remove(self.sysTray)