Added a way to update SRPMS

This commit is contained in:
Filippo Bedendo Bordon 2011-06-30 06:25:36 +02:00
parent 5e2bf460e5
commit dbfb774546
2 changed files with 64 additions and 3 deletions

View File

@ -1 +1,2 @@
Silvan Calarco <silvan.calarco@mambasoft.it>
michiamophil <michiamophil@libero.it>

View File

@ -1,6 +1,7 @@
#!/usr/bin/python
# mambatray2
# Copyright (C) 2011 by Silvan Calarco
# Copyright (C) 2011 by michiamophil
# Distributed under the terms of the GPL version 3 FLOSS License
#
import sys
@ -12,18 +13,26 @@ from PyQt4 import QtCore
class SystemTrayIcon(QtGui.QSystemTrayIcon):
def __init__(self, icon, parent=None):
global w, menu
global w, menu, contatore, srpm, lista, NetsrpmsArg, nOre
nOre = 2
srpm = ["skype", "flashplugin", "win32codecs"]
NetsrpmsArg = "-c"
lista = []
contatore = 0
w = parent
QtGui.QSystemTrayIcon.__init__(self, icon, parent)
menu = QtGui.QMenu(parent)
# refresh packages cache timer
global refreshPackagesTimer, refreshPackagesCacheProcess
global refreshPackagesTimer, refreshPackagesCacheProcess, checkSRPMSUpdatesTimer, SRPMUpdateProcess
refreshPackagesTimer = QtCore.QTimer(self)
checkSRPMSUpdatesTimer = QtCore.QTimer(self)
refreshPackagesCacheProcess = QtCore.QProcess(self)
SRPMUpdateProcess = 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)
# software menu
global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess
softwareManagerProcess = QtCore.QProcess(self)
@ -60,6 +69,8 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
self.connect(networkFirewallConfigureAction, SIGNAL("triggered()"), self.networkFirewallConfigure)
networkProxyAction = networkMenu.addAction(QtGui.QIcon.fromTheme("network-server"),_("Proxy..."))
self.connect(networkProxyAction, SIGNAL("triggered()"), self.networkProxy)
self.connect(SRPMUpdateProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.SRPMSCheckUpgrade)
# about box
aboutAction = menu.addSeparator()
@ -72,6 +83,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
# the first time refresh packages cache after 5 minutes
refreshPackagesTimer.start( 5 * 60000 )
checkSRPMSUpdatesTimer.start( 6000 )
def iconActivated(self, reason):
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
@ -127,6 +139,54 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
networkProxyProcess.execute("/opt/kde/bin/kcmshell4",
QtCore.QStringList(list(set(['proxy']))))
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)
#viene eseguita per ogni SRPM al termine del processo SRPMUpdateProcess
def SRPMSCheckUpgrade(self, status):
global contatore, lista
if status == 1:
lista.append(srpm[contatore])
contatore += 1
self.SRPMSCheckUpgradeList()
#viene eseguita una volta terminata la fase di controllo degli aggiornamenti
def SRPMSAskAndInstall(self):
global NetsrpmsArg, lista
if not lista == []:
Lista = self.Lista()
msg = QtGui.QMessageBox.question(menu, ("Updates"), (_("I seguenti pacchetti saranno aggiornati: ") + Lista + ".\n" + _("Sei d'accordo?")), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes)
if msg == QtGui.QMessageBox.Yes:
NetsrpmsArg = '-u'
self.SRPMSCheckUpgradeList()
else:
lista = []
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
else:
checkSRPMSUpdatesTimer.start((nOre * 60) * 60000)
#partendo dalla lista lista (scusate il gioco di parole :) ) restituisce la lista in modo 'leggibile'
def Lista(self):
testo = ''
for a in lista:
testo = testo + a + ', '
return testo[0:len(testo)-2]
def main():
app = QtGui.QApplication(sys.argv)
if (app.isSessionRestored()):