Check that network is online before checking and asking the user about network SRPMS updates

This commit is contained in:
Silvan Calarco 2013-05-14 15:42:02 +02:00
parent c60d78329a
commit 3a42a59ee9

View File

@ -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,6 +203,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
def SRPMSCheckUpgradeList(self):
checkSRPMSUpdatesTimer.stop()
global contatore, lista, NetsrpmsArg
if (self.networkOnline() == 0):
try:
SRPMUpdateProcess.start("/usr/bin/openmamba-netsrpms",[NetsrpmsArg,srpm[contatore]])
except: #supera il limite dell'indice nella lista