Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-121 fixes #121 #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions etc/yum-cron-hourly.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ emit_via = stdio
# formatted to.
output_width = 80

# Send messages even when there are no packages needing updates.
emit_when_up_to_date = no

[email]
# The address to send email messages from.
Expand Down
3 changes: 3 additions & 0 deletions etc/yum-cron-security.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ emit_via = stdio
# formatted to.
output_width = 80

# Send messages even when there are no packages needing updates.
emit_when_up_to_date = no


[email]
# The address to send email messages from.
Expand Down
3 changes: 3 additions & 0 deletions etc/yum-cron.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ emit_via = stdio
# formatted to.
output_width = 80

# Send messages even when there are no packages needing updates.
emit_when_up_to_date = no


[email]
# The address to send email messages from.
Expand Down
1 change: 0 additions & 1 deletion yum-cron/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Documentation:

Mail:
- Use a different subject for success and failure mail
- Make receiving mail when nothing happens optional

General:
- Break out check-updates and download-updates into their own actions;
Expand Down
22 changes: 22 additions & 0 deletions yum-cron/yum-cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def updatesAvailable(self, summary):
self.output.append('The following updates are available on %s:' % self.opts.system_name)
self.output.append(summary)

def updatesUnavailable(self):
"""Appends a message to the output list stating that there are
no updates available.
"""
self.output.append('Yum indicates that there are no updates available')

def updatesDownloading(self, summary):
"""Append a message to the output list stating that
downloading updates has started.
Expand Down Expand Up @@ -164,6 +170,13 @@ def updatesAvailable(self, summary):
super(EmailEmitter, self).updatesAvailable(summary)
self.subject = "Yum: Updates Available on %s" % self.opts.system_name

def updatesUnavailable(self):
"""Appends a message to the output list stating that there are
no updates available, and set an appropiate subject line.
"""
super(EmailEmitter, self).updatesUnavailable()
self.subject = "Yum: Up-To-Date"

def updatesDownloaded(self):
"""Append a message to the output list stating that updates
have been downloaded successfully, and set an appropriate
Expand Down Expand Up @@ -284,6 +297,7 @@ class YumCronConfig(BaseConfig):
lock_retries = IntOption(5)
lock_sleep = IntOption(60)
emit_via = ListOption(['email','stdio'])
emit_when_up_to_date = BoolOption(False)
email_to = ListOption(["root"])
email_from = Option("root")
email_host = Option("localhost")
Expand Down Expand Up @@ -634,6 +648,10 @@ def updatesCheck(self):
gups = self.refreshGroupUpdates()
# If neither have updates, we can just exit.
if not (pups or gups):
if self.opts.emit_when_up_to_date:
self.emitUnavailable()
self.sendMessages()
self.releaseLocks()
sys.exit(0)

# Build the transaction to find the additional dependencies
Expand Down Expand Up @@ -669,6 +687,10 @@ def emitAvailable(self):
summary = self.listTransaction()
map(lambda x: x.updatesAvailable(summary), self.emitters)

def emitUnavailable(self):
"""Emit a notice stating updates are not avaialble."""
map(lambda x: x.updatesUnavailable(), self.emitters)

def emitDownloading(self):
"""Emit a notice stating that updates are downloading."""
summary = self.listTransaction()
Expand Down