[yum-cvs] 2 commits - yum-updatesd yum-updatesd-helper
Jeremy Katz
katzj at linux.duke.edu
Tue Nov 20 16:26:31 UTC 2007
yum-updatesd | 4 +-
yum-updatesd-helper | 89 +++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 77 insertions(+), 16 deletions(-)
New commits:
commit e51d6a108d3fc6a96b3822464b38ae53f27620af
Author: Jeremy Katz <katzj at redhat.com>
Date: Tue Nov 20 10:27:27 2007 -0500
workaround gamin stupidly waking up a lot if told to watch not a directory (#391571)
diff --git a/yum-updatesd b/yum-updatesd
index 26e118d..edbe217 100755
--- a/yum-updatesd
+++ b/yum-updatesd
@@ -221,8 +221,8 @@ def setup_watcher():
mon = gamin.WatchMonitor()
mon.watch_directory("/var/lib/rpm", invalidate_cache)
mon.watch_directory("/var/cache/yum", invalidate_cache)
- map(lambda x: mon.watch_directory("/var/cache/yum/%s" %(x,),
- invalidate_cache),
+ map(lambda x: os.path.isdir("/var/cache/yum/%s" %(x,)) and
+ mon.watch_directory("/var/cache/yum/%s" %(x,), invalidate_cache),
os.listdir("/var/cache/yum"))
mon.handle_events()
fd = mon.get_fd()
commit dd2596cd252fb0ecf18419d61b5ec3c89b225d5e
Author: Pierre Ossman <drzeus-bugzilla at drzeus.cx>
Date: Mon Nov 19 11:08:18 2007 -0500
Improve mail output (rh#387181)
diff --git a/yum-updatesd-helper b/yum-updatesd-helper
index 720563f..ad97c28 100755
--- a/yum-updatesd-helper
+++ b/yum-updatesd-helper
@@ -24,6 +24,8 @@ import dbus.glib
import smtplib
from optparse import OptionParser
from email.MIMEText import MIMEText
+import socket
+import rfc822
import yum
@@ -141,24 +143,33 @@ class EmailUpdateEmitter(UpdateEmitter):
self.rcpts = rcpts
self.smtp_server = smtp_server
- def updatesAvailable(self, updateInfo):
- num = len(updateInfo)
- if num < 1:
- return
+ def _msgGreeting(self):
+ output = """Hi,
+This is the automatic update system on %s.
+
+""" % socket.gethostname()
+ return output
+ def _msgFooter(self):
output = """
- Hi,
- There are %d package updates available. Please run the system
- updater.
-
- Thank You,
- Your Computer
- """ % num
-
- msg = MIMEText(output)
- msg['Subject'] = "%d Updates Available" %(num,)
+Thank You,
+Your Computer
+"""
+ return output
+
+ def _msgPacketList(self, updateInfo):
+ output = ""
+ for package in updateInfo:
+ output += " %-30s %-10s\n" % (package[0]['name'], package[0]['type'])
+ return output
+
+ def _sendMessage(self, subject, body):
+ msg = MIMEText(body)
+ msg['Subject'] = "yum: %s (on %s) " % (subject, socket.gethostname())
msg['From'] = self.sender
msg['To'] = self.rcpts
+ msg['Date'] = rfc822.formatdate()
+
s = smtplib.SMTP()
if self.smtp_server:
s.connect(self.smtp_server)
@@ -167,6 +178,56 @@ class EmailUpdateEmitter(UpdateEmitter):
s.sendmail(self.sender, self.rcpts.split(','), msg.as_string())
s.close()
+ def updatesAvailable(self, updateInfo):
+ num = len(updateInfo)
+ if num < 1:
+ return
+
+ output = self._msgGreeting()
+
+ output += """There are %d package updates available. Please run the system updater.
+
+Packages available for update:
+
+""" % num
+
+ output += self._msgPacketList(updateInfo)
+ output += self._msgFooter()
+
+ self._sendMessage("%d Updates Available" % num, output)
+
+ def updatesApplied(self, updateInfo):
+ num = len(updateInfo)
+ if num < 1:
+ return
+
+ output = self._msgGreeting()
+
+ output += """The system successfully installed/updated %d packages.
+
+Packages installed or updated:
+
+""" % num
+
+ output += self._msgPacketList(updateInfo)
+ output += self._msgFooter()
+
+ self._sendMessage("%d packets installed/updated" % num, output)
+
+ def updatesFailed(self, errmsgs):
+ output = self._msgGreeting()
+
+ output += """There was a problem updating the system. The following error message
+was reported:
+
+%s
+
+If the problem persists, manual intervention may be required.""" % errmsgs
+
+ output += self._msgFooter()
+
+ self._sendMessage("problem updating system", output)
+
class DbusUpdateEmitter(UpdateEmitter):
def __init__(self):
UpdateEmitter.__init__(self)
More information about the Yum-cvs-commits
mailing list