[yum-cvs] yum yum-updatesd.py,1.4,1.5
Seth Vidal
skvidal at linux.duke.edu
Sun May 7 22:54:44 UTC 2006
Update of /home/groups/yum/cvs/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv4717
Modified Files:
yum-updatesd.py
Log Message:
updatesd changes:
- works as a daemon and uses a gobject mainloop dtrt
- exports a dbus system bus method to allow for triggering to check for
updates - uses name = edu.duke.linux.yum.Updatesd, object=/Updatesd, with the method "CheckNow"
- emits a dbus system bus signal if updates are available: membername is
UpdatesAvailableSignal - the string tells how many are available.
- emits a dbus system bus signal if updates are NOT available membername
is: NoUpdatesAvailableSignal
Index: yum-updatesd.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum-updatesd.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- yum-updatesd.py 7 May 2006 20:46:23 -0000 1.4
+++ yum-updatesd.py 7 May 2006 22:54:42 -0000 1.5
@@ -17,9 +17,8 @@
#TODO:
# add logs and errorlogs below a certain number to send out to syslog
-# maybe provide for configurable emit mechanisms:
-# - email
-#
+# fix email notifications so it does _something_ :)
+
import os
import sys
@@ -27,7 +26,7 @@
import dbus
import dbus.service
import dbus.glib
-
+import gobject
import yum
import yum.Errors
@@ -36,6 +35,7 @@
IncludingConfigParser
from yum.constants import *
YUM_PID_FILE = '/var/run/yum.pid'
+config_file = '/etc/yum/yum-updatesd.conf'
@@ -51,11 +51,6 @@
def NoUpdatesAvailableSignal(self, message):
pass
- @dbus.service.method("edu.duke.linux.Yum")
- def CheckNow(self):
-
- pass
-
class UDConfig(yum.config.BaseConfig):
@@ -78,6 +73,7 @@
self.doSetup()
self.updatesCheck()
self.doShutdown()
+
def log(self, num, msg):
#TODO - this should probably syslog
pass
@@ -168,13 +164,47 @@
msg = "No Updates Available"
yum_dbus.NoUpdatesAvailableSignal(msg)
+ del yum_dbus
+ del name
+ del my_bus
+
+class YumDbusListener(dbus.service.Object):
+ def __init__(self, bus_name, object_path='/Updatesd'):
+ dbus.service.Object.__init__(self, bus_name, object_path)
+
+ @dbus.service.method("edu.duke.linux.yum.Updatesd")
+ def CheckNow(self):
+ run_update_check()
+ return "check completed"
+
+
+
+def run_update_check(opts=None):
+
+ if not opts:
+ confparser = IncludingConfigParser()
+ opts = UDConfig()
+
+ if os.path.exists(config_file):
+ confparser.read(config_file)
+
+ opts.populate(confparser, 'main')
+
+ try:
+ my = UpdatesDaemon(opts)
+ except yum.Errors.YumBaseError, e:
+ print >> sys.stderr, 'Error: %s' % e
+ else:
+ del my
+
+ return True # has to be true or gobject will stop running it afaict
+
+
def main():
if os.fork():
sys.exit()
-
- # do our config file
- config_file = '/etc/yum/yum-updatesd.conf'
+
confparser = IncludingConfigParser()
opts = UDConfig()
@@ -182,18 +212,18 @@
confparser.read(config_file)
opts.populate(confparser, 'main')
+
+ bus = dbus.SystemBus()
+ name = dbus.service.BusName("edu.duke.linux.yum.Updatesd", bus=bus)
+ object = YumDbusListener(name)
+
+ run_interval_ms = opts.run_interval * 1000 # get it into milliseconds for gobject
+
+ gobject.timeout_add(run_interval_ms, run_update_check)
- while True:
- try:
- my = UpdatesDaemon(opts)
- except yum.Errors.YumBaseError, e:
- print >> sys.stderr, 'Error: %s' % e
- else:
- del my
+ mainloop = gobject.MainLoop()
+ mainloop.run()
- time.sleep(opts.run_interval)
-
-
if __name__ == "__main__":
main()
More information about the Yum-cvs-commits
mailing list