Skip to content

Commit

Permalink
Added option 'send_error_messages'
Browse files Browse the repository at this point in the history
  • Loading branch information
derickdiaz committed Oct 19, 2023
1 parent fa893a3 commit fbc26e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dnf/automatic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ def __init__(self):
libdnf.conf.VectorString(['email', 'stdio'])))
self.add_option('output_width', libdnf.conf.OptionNumberInt32(80))
self.add_option('system_name', libdnf.conf.OptionString(socket.gethostname()))
self.add_option('send_error_messages', libdnf.conf.OptionString(
libdnf.conf.VectorString(['yes', 'no'])
))


def gpgsigcheck(base, pkgs):
Expand Down Expand Up @@ -367,13 +370,10 @@ def main(args):
(conf.commands.reboot == 'when-needed' and base.reboot_needed())):
exit_code = os.waitstatus_to_exitcode(os.system(conf.commands.reboot_command))
if exit_code != 0:
logger.error('Error: reboot command returned nonzero exit code: %d', exit_code)
emitters.notify_error('Error: reboot command returned nonzero exit code: %d', exit_code)
emitters.commit()
return 1
raise dnf.exceptions.Error('reboot command returned nonzero exit code: %d', exit_code)
except dnf.exceptions.Error as exc:
logger.error(_('Error: %s'), ucd(exc))
if conf.emitters != None:
if conf.emitters.send_error_messages and emitters != None:
emitters.notify_error(_('Error: %s') % str(exc))
emitters.commit()
return 1
Expand Down
5 changes: 5 additions & 0 deletions doc/automatic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ Choosing how the results should be reported.

How the system is called in the reports.

``send_error_messages``
list, default: ``yes, no``

Invokes emitters when an errors occurs

---------------------
``[command]`` section
---------------------
Expand Down
1 change: 1 addition & 0 deletions etc/dnf/automatic.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ reboot_command = "shutdown -r +5 'Rebooting after applying package updates'"
# If emit_via is None or left blank, no messages will be sent.
emit_via = stdio

send_error_messages = "no"

[email]
# The address to send email messages from.
Expand Down

0 comments on commit fbc26e6

Please sign in to comment.