From 1ada2eaeb0c31e49c8442c83c48199c4975aa8a7 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 4 May 2011 22:10:55 +0200 Subject: [PATCH] Added periodic package cache refresh command execution (pkcon refresh) --- src/mambatray | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/mambatray b/src/mambatray index 6da0541..9b9ea04 100755 --- a/src/mambatray +++ b/src/mambatray @@ -17,6 +17,13 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): QtGui.QSystemTrayIcon.__init__(self, icon, parent) menu = QtGui.QMenu(parent) + # refresh packages cache timer + global refreshPackagesTimer, refreshPackagesCacheProcess + refreshPackagesTimer = QtCore.QTimer(self) + refreshPackagesCacheProcess = QtCore.QProcess(self) + self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache) + self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer) + # software menu global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess softwareManagerProcess = QtCore.QProcess(self) @@ -62,7 +69,10 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): self.setContextMenu(menu) self.setToolTip(_("openmamba control center")) self.activated.connect(self.iconActivated) - + + # the first time refresh packages cache after 5 minutes + refreshPackagesTimer.start( 5 * 60000 ) + def iconActivated(self, reason): if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): menu.popup(self.geometry().center()) @@ -77,7 +87,15 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): softwareManagerProcess.execute("/opt/kde/bin/kpackagekit") def softwareCheckUpgrades(self): - softwareCheckUpgradesProcess.execute("/opt/kde/bin/kpackagekit", QtCore.QStringList(list(set(['--updates'])))) + softwareCheckUpgradesProcess.start("/opt/kde/bin/kpackagekit", ['--updates']) + + def refreshPackagesCache(self): + refreshPackagesTimer.stop() + refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh']) + + def restartRefreshPackagesTimer(self,status): + # check every 4 hours and 31 minutes */ + refreshPackagesTimer.start( (4 * 60 + 31) * 60000) def softwareBaseInstalls(self): dcopServerProcess.startDetached("/opt/kde3/bin/dcopserver")