Added a way to update SRPMS
This commit is contained in:
parent
5e2bf460e5
commit
dbfb774546
1
AUTHORS
1
AUTHORS
@ -1 +1,2 @@
|
|||||||
Silvan Calarco <silvan.calarco@mambasoft.it>
|
Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||||
|
michiamophil <michiamophil@libero.it>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# mambatray2
|
# mambatray2
|
||||||
# Copyright (C) 2011 by Silvan Calarco
|
# Copyright (C) 2011 by Silvan Calarco
|
||||||
|
# Copyright (C) 2011 by michiamophil
|
||||||
# Distributed under the terms of the GPL version 3 FLOSS License
|
# Distributed under the terms of the GPL version 3 FLOSS License
|
||||||
#
|
#
|
||||||
import sys
|
import sys
|
||||||
@ -12,17 +13,25 @@ from PyQt4 import QtCore
|
|||||||
class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
||||||
|
|
||||||
def __init__(self, icon, parent=None):
|
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
|
w = parent
|
||||||
QtGui.QSystemTrayIcon.__init__(self, icon, parent)
|
QtGui.QSystemTrayIcon.__init__(self, icon, parent)
|
||||||
menu = QtGui.QMenu(parent)
|
menu = QtGui.QMenu(parent)
|
||||||
|
|
||||||
# refresh packages cache timer
|
# refresh packages cache timer
|
||||||
global refreshPackagesTimer, refreshPackagesCacheProcess
|
global refreshPackagesTimer, refreshPackagesCacheProcess, checkSRPMSUpdatesTimer, SRPMUpdateProcess
|
||||||
refreshPackagesTimer = QtCore.QTimer(self)
|
refreshPackagesTimer = QtCore.QTimer(self)
|
||||||
|
checkSRPMSUpdatesTimer = QtCore.QTimer(self)
|
||||||
refreshPackagesCacheProcess = QtCore.QProcess(self)
|
refreshPackagesCacheProcess = QtCore.QProcess(self)
|
||||||
|
SRPMUpdateProcess = QtCore.QProcess(self)
|
||||||
self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache)
|
self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache)
|
||||||
self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer)
|
self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer)
|
||||||
|
self.connect(checkSRPMSUpdatesTimer, SIGNAL("timeout()"), self.SRPMSCheckUpgradeList)
|
||||||
|
|
||||||
# software menu
|
# software menu
|
||||||
global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess
|
global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess
|
||||||
@ -60,6 +69,8 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
self.connect(networkFirewallConfigureAction, SIGNAL("triggered()"), self.networkFirewallConfigure)
|
self.connect(networkFirewallConfigureAction, SIGNAL("triggered()"), self.networkFirewallConfigure)
|
||||||
networkProxyAction = networkMenu.addAction(QtGui.QIcon.fromTheme("network-server"),_("Proxy..."))
|
networkProxyAction = networkMenu.addAction(QtGui.QIcon.fromTheme("network-server"),_("Proxy..."))
|
||||||
self.connect(networkProxyAction, SIGNAL("triggered()"), self.networkProxy)
|
self.connect(networkProxyAction, SIGNAL("triggered()"), self.networkProxy)
|
||||||
|
self.connect(SRPMUpdateProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.SRPMSCheckUpgrade)
|
||||||
|
|
||||||
|
|
||||||
# about box
|
# about box
|
||||||
aboutAction = menu.addSeparator()
|
aboutAction = menu.addSeparator()
|
||||||
@ -72,6 +83,7 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
|
|
||||||
# the first time refresh packages cache after 5 minutes
|
# the first time refresh packages cache after 5 minutes
|
||||||
refreshPackagesTimer.start( 5 * 60000 )
|
refreshPackagesTimer.start( 5 * 60000 )
|
||||||
|
checkSRPMSUpdatesTimer.start( 6000 )
|
||||||
|
|
||||||
def iconActivated(self, reason):
|
def iconActivated(self, reason):
|
||||||
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
|
if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
|
||||||
@ -127,6 +139,54 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
|||||||
networkProxyProcess.execute("/opt/kde/bin/kcmshell4",
|
networkProxyProcess.execute("/opt/kde/bin/kcmshell4",
|
||||||
QtCore.QStringList(list(set(['proxy']))))
|
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():
|
def main():
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
if (app.isSessionRestored()):
|
if (app.isSessionRestored()):
|
||||||
|
Loading…
Reference in New Issue
Block a user