From 3a42a59ee923fa971c5e4aeead277273cca617bd Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Tue, 14 May 2013 15:42:02 +0200 Subject: [PATCH] Check that network is online before checking and asking the user about network SRPMS updates --- src/mambatray | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/mambatray b/src/mambatray index 7ab3c57..d5efe5a 100755 --- a/src/mambatray +++ b/src/mambatray @@ -32,11 +32,12 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): desktop_session = QtCore.QString('kde') # refresh packages cache timer - global refreshPackagesTimer, refreshPackagesCacheProcess, checkSRPMSUpdatesTimer, SRPMUpdateProcess + global refreshPackagesTimer, refreshPackagesCacheProcess, checkSRPMSUpdatesTimer, SRPMUpdateProcess, networkOnlineProcess refreshPackagesTimer = QtCore.QTimer(self) checkSRPMSUpdatesTimer = QtCore.QTimer(self) refreshPackagesCacheProcess = QtCore.QProcess(self) SRPMUpdateProcess = QtCore.QProcess(self) + networkOnlineProcess = QtCore.QProcess(self) self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache) self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer) self.connect(checkSRPMSUpdatesTimer, SIGNAL("timeout()"), self.SRPMSCheckUpgradeList) @@ -138,6 +139,9 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): result.append(v[ v.find("for")+4 : v.find("(") ]) return result + def networkOnline(self): + return networkOnlineProcess.execute("/usr/bin/nm-online",['-q','-x']) + def softwareManager(self): self.setProxyForSmart() if desktop_session == 'kde': @@ -199,17 +203,18 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): def SRPMSCheckUpgradeList(self): checkSRPMSUpdatesTimer.stop() global contatore, lista, NetsrpmsArg - try: - SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]]) - except: #supera il limite dell'indice nella lista - contatore = 0 - if NetsrpmsArg == '-c': - self.SRPMSAskAndInstall() - else: - lista = [] - NetsrpmsArg = '-c' - checkSRPMSUpdatesTimer.start((nOre * 60) * 60000) - + if (self.networkOnline() == 0): + try: + SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]]) + except: #supera il limite dell'indice nella lista + contatore = 0 + if NetsrpmsArg == '-c': + self.SRPMSAskAndInstall() + else: + lista = [] + NetsrpmsArg = '-c' + checkSRPMSUpdatesTimer.start((nOre * 60) * 60000) + #viene eseguita per ogni SRPM al termine del processo SRPMUpdateProcess def SRPMSCheckUpgrade(self, status): global contatore, lista