[yum-cvs] 3 commits - yum-updatesd yum-updatesd-helper
Jeremy Katz
katzj at linux.duke.edu
Wed Sep 5 23:30:48 UTC 2007
yum-updatesd | 49 +++++++++++++++++++++++++++++++++----------------
yum-updatesd-helper | 6 ++++++
2 files changed, 39 insertions(+), 16 deletions(-)
New commits:
commit ef8d5404ee030241e8ba9257e9ee4e2754f8750b
Author: Jeremy Katz <katzj at redhat.com>
Date: Wed Sep 5 19:27:30 2007 -0400
stop polling gamin
diff --git a/yum-updatesd b/yum-updatesd
index 3cbcc81..100c405 100755
--- a/yum-updatesd
+++ b/yum-updatesd
@@ -212,13 +212,10 @@ def invalidate_cache(*args):
return
updateInfo = []
updateInfoDone = False
-def check_files(mon):
- mon.handle_events()
- return True
def setup_watcher():
"""Sets up gamin-based file watches on things we care about and makes
it so they get checked every 15 seconds."""
- # add some watches on directories. check them every 15 seconds
+ # add some watches on directories.
mon = gamin.WatchMonitor()
mon.watch_directory("/var/lib/rpm", invalidate_cache)
mon.watch_directory("/var/cache/yum", invalidate_cache)
@@ -226,7 +223,9 @@ def setup_watcher():
invalidate_cache),
os.listdir("/var/cache/yum"))
mon.handle_events()
- gobject.timeout_add(15 * 1000, check_files, mon)
+ fd = mon.get_fd()
+ gobject.io_add_watch(fd, gobject.IO_IN|gobject.IO_PRI,
+ lambda x, y: mon.handle_events())
def network_state_change(newstate, opts):
if int(newstate) == NM_ONLINE:
commit 166e9f4b0257ccc91df06e7a39fa12a8b765984a
Author: Jeremy Katz <katzj at redhat.com>
Date: Wed Sep 5 19:18:05 2007 -0400
watch for NetworkManager state changes and do an update check when the
network becomes available
diff --git a/yum-updatesd b/yum-updatesd
index ab2db5c..3cbcc81 100755
--- a/yum-updatesd
+++ b/yum-updatesd
@@ -45,6 +45,7 @@ updateInfoDone = False
updateInfo = []
helperProcess = None
+NM_ONLINE = 3
class UDConfig(BaseConfig):
"""Config format for the daemon"""
@@ -147,7 +148,7 @@ def checkUpdates(opts, wait = False):
bus = dbus.SystemBus()
try:
o = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
- if o.state() != 3:
+ if o.state() != NM_ONLINE:
args.append("--network-fail")
except dbus.DBusException:
pass
@@ -226,7 +227,10 @@ def setup_watcher():
os.listdir("/var/cache/yum"))
mon.handle_events()
gobject.timeout_add(15 * 1000, check_files, mon)
-
+
+def network_state_change(newstate, opts):
+ if int(newstate) == NM_ONLINE:
+ checkUpdates(opts)
def main(options = None):
if options is None:
@@ -258,15 +262,26 @@ def main(options = None):
checkUpdates(opts, wait = True)
sys.exit(0)
- if opts.dbus_listener:
+ try:
bus = dbus.SystemBus()
+ except dbus.DBusException, e:
+ bus = None
+ if opts.dbus_listener and bus is not None:
name = dbus.service.BusName("edu.duke.linux.yum", bus=bus)
YumDbusListener(name, allowshutdown = options.remoteshutdown,
config = opts)
bus.add_signal_receiver(add_update, "UpdateInfoSignal", dbus_interface="edu.duke.linux.yum")
bus.add_signal_receiver(updates_done, "UpdatesAvailableSignal", dbus_interface="edu.duke.linux.yum")
- bus.add_signal_receiver(updates_applied, "UpdatesAppliedSignal", dbus_interface="edu.duke.linux.yum")
+ bus.add_signal_receiver(updates_applied, "UpdatesAppliedSignal", dbus_interface="edu.duke.linux.yum")
+
+ try:
+ if bus is not None:
+ bus.add_signal_receiver(lambda x: network_state_change(x, opts),
+ "StateChange",
+ "org.freedesktop.NetworkManager")
+ except Exception, e:
+ pass
run_interval_ms = opts.run_interval * 1000 # needs to be in ms
gobject.timeout_add(run_interval_ms, checkUpdates, opts)
commit c49b1db6a8f9f04f4b0d67fa4731eb93447e5266
Author: Jeremy Katz <katzj at redhat.com>
Date: Wed Sep 5 18:49:11 2007 -0400
fix NetworkManager state checking. emit a proper failure when the network
isn't up
diff --git a/yum-updatesd b/yum-updatesd
index 77dfa4f..ab2db5c 100755
--- a/yum-updatesd
+++ b/yum-updatesd
@@ -138,17 +138,20 @@ def checkUpdates(opts, wait = False):
print >> sys.stderr, "Helper process already running"
return True
- bus = dbus.SystemBus()
- o = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
- if o.state != 3:
- print >> sys.stderr, "Not online; can't check for updates"
- return True
-
if os.path.exists("./yum-updatesd-helper") and opts.debug:
args = ["./yum-updatesd-helper", "--check"]
else:
args = ["/usr/libexec/yum-updatesd-helper", "--check"]
+
+ bus = dbus.SystemBus()
+ try:
+ o = bus.get_object("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager")
+ if o.state() != 3:
+ args.append("--network-fail")
+ except dbus.DBusException:
+ pass
+
# arguments for what to do
if opts.do_download:
args.append("--download")
@@ -171,12 +174,12 @@ def checkUpdates(opts, wait = False):
if opts.debug:
args.append("--debug")
- print "Going to exec: %s" %(args,)
+ print >> sys.stderr, "Going to exec: %s" %(args,)
helperProcess = subprocess.Popen(args, close_fds = True)
if not wait:
- gobject.timeout_add(4 * 1000, checkHelperStatus)
+ gobject.timeout_add(1 * 1000, checkHelperStatus)
return True
return helperProcess.wait()
diff --git a/yum-updatesd-helper b/yum-updatesd-helper
index 3b15eea..73f2f56 100755
--- a/yum-updatesd-helper
+++ b/yum-updatesd-helper
@@ -508,6 +508,7 @@ def main(options = None):
parser.add_option("-d", "--download", action="store_true", default=False, dest="download")
parser.add_option("", "--deps", action="store_true", default=False, dest="finddeps")
parser.add_option("-a", "--apply", action="store_true", default=False, dest="apply")
+ parser.add_option("", "--network-fail", action="store_true", default=False, dest="netfail")
# debugging, different configs
parser.add_option("", "--debug", action="store_true", default=False, dest="debug")
parser.add_option("", "--config", type="string", default="/etc/yum.conf", dest="config")
@@ -533,6 +534,11 @@ def main(options = None):
syslog.openlog("yum-updatesd-helper", 0, syslog.LOG_DAEMON)
updd = UpdatesDaemon(options)
+
+ if options.netfail:
+ updd.emitCheckFailed("No network available")
+ sys.exit(1)
+
updd.doSetup()
if not updd.refreshMetadata():
sys.exit(1)
More information about the Yum-cvs-commits
mailing list