[Frugalware-darcs] updatemgr: updatemonitor: initial import

AlexExtreme alex at alex-smith.me.uk
Thu Oct 5 21:25:09 CEST 2006


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=updatemgr;a=darcs_commitdiff;h=20061005192620-46e39-a50802880d8517dedda3b93d57ab0acdfc755fc6.gz;

[updatemonitor: initial import
AlexExtreme <alex at alex-smith.me.uk>**20061005192620] {
hunk ./updatemgrd/updatemgrd.py 32
-import sys, os, time, alpm, gobject, dbus, dbus.service, dbus.glib
+import sys, os, alpm, gobject, dbus, dbus.service, dbus.glib
hunk ./updatemgrd/updatemgrd.py 54
+	
+	@dbus.service.method('org.frugalware.UpdateMgrIFace')
+	def checkUpdates(self):
+		self.MyUpdateMgr.debug("Checking for updates...")
+		return 1
+	
+	@dbus.service.method('org.frugalware.UpdateMgrIFace')
+	def getLogFile(self):
+		self.MyUpdateMgr.debug("Client requested logfile name; Giving it...")
+		return self.MyUpdateMgr.logfile
addfile ./updatemonitor/updatemonitor
hunk ./updatemonitor/updatemonitor 1
+#!/usr/bin/env python
+
+"""
+Frugalware Update Monitor
+Copyright (C) 2006 Alex Smith.
+This program is licenced under the terms of the GNU GPL.
+"""
+
+__author__ = "Alex Smith"
+__email__ = "alex at alex-smith.me.uk"
+__license__ = """
+Frugalware Update Monitor
+Copyright (C) 2006 Alex Smith <alex at alex-smith.me.uk>
+
+This file is part of UpdateMgr.
+
+UpdateMgr is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+UpdateMgr is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with UpdateMgr; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+"""
+
+from updatemonitor import UpdateMonitor
+
+if __name__ == "__main__":
+	updatemon = UpdateMonitor()
+	updatemon.main()
addfile ./updatemonitor/updatemonitor.py
hunk ./updatemonitor/updatemonitor.py 1
+#!/usr/bin/env python
+
+"""
+Frugalware Update Monitor
+Copyright (C) 2006 Alex Smith.
+This program is licenced under the terms of the GNU GPL.
+"""
+
+__author__ = "Alex Smith"
+__email__ = "alex at alex-smith.me.uk"
+__license__ = """
+Frugalware Update Monitor
+Copyright (C) 2006 Alex Smith <alex at alex-smith.me.uk>
+
+This file is part of UpdateMgr.
+
+UpdateMgr is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+UpdateMgr is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with UpdateMgr; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+"""
+
+import sys, os, time, dbus, dbus.glib, pynotify
+from optparse import OptionParser
+from ConfigParser import ConfigParser
+
+VERSION = '0.1'
+
+class UpdateMonitor:
+	def notRunningBubble(self):
+		notify = pynotify.Notification("Warning", "The update manager daemon is not running!", None, None)
+		notify.set_urgency(pynotify.URGENCY_CRITICAL)
+		notify.show()
+		notify = None
+	
+	def dbUpdateFailedBubble(self):
+		logfile = self.iface.getLogFile()
+		notify = pynotify.Notification("Warning", "The update manager daemon failed to update the package database! Check %s for more information" % (logfile), None, None)
+		notify.set_urgency(pynotify.URGENCY_CRITICAL)
+		notify.show()
+		notify = None
+	
+	def updateBubble(self):
+		print "not implemented"
+	
+	def doCheck(self):
+		updates = 0
+		dbupdate = 1
+		
+		# First update the package database
+		try:
+			dbupdate = self.iface.updatePackageDatabase()
+		except:
+			self.notRunningBubble()
+			return 1
+		
+		if dbupdate == 1:
+			self.dbUpdateFailedBubble()
+			return 1
+		
+		# Now see if updates were available
+		try:
+			updates = self.iface.checkUpdates()
+		except:
+			self.notRunningBubble()
+			return 1
+		
+		if updates == 1:
+			self.updateBubble()
+	
+	def main(self):
+		# Start DBUS interface
+		self.bus = dbus.SystemBus()
+		self.proxy_obj = self.bus.get_object('org.frugalware.UpdateMgr', '/org/frugalware/UpdateMgrObject')
+		self.iface = dbus.Interface(self.proxy_obj, 'org.frugalware.UpdateMgrIFace')
+		
+		# Wait for the rest of the system to come up
+		time.sleep(60)
+		
+		# Main loop
+		while 1:
+			self.doCheck()
+			time.sleep(3600)
+			
}


More information about the Frugalware-darcs mailing list