diff --git a/dnf/automatic/main.py b/dnf/automatic/main.py index 0a9d50414d..5ca4ad3954 100644 --- a/dnf/automatic/main.py +++ b/dnf/automatic/main.py @@ -311,11 +311,13 @@ def remote_address(url_list): def main(args): (opts, parser) = parse_arguments(args) + conf = None + emitters = None try: conf = AutomaticConfig(opts.conf_path, opts.downloadupdates, opts.installupdates) - emitters = None + emitters = build_emitters(conf) with dnf.Base() as base: cli = dnf.cli.Cli(base) cli._read_conf_file() @@ -349,7 +351,6 @@ def main(args): return 0 lst = output.list_transaction(trans, total_width=80) - emitters = build_emitters(conf) emitters.notify_available(lst) if not conf.commands.download_updates: emitters.commit() @@ -378,9 +379,9 @@ def main(args): exit_code = os.waitstatus_to_exitcode(os.system(conf.commands.reboot_command)) if exit_code != 0: raise dnf.exceptions.Error('reboot command returned nonzero exit code: %d', exit_code) - except dnf.exceptions.Error as exc: + except Exception as exc: logger.error(_('Error: %s'), ucd(exc)) - if conf.emitters.send_error_messages and emitters != None: + if conf is not None and conf.emitters.send_error_messages and emitters is not None: emitters.notify_error(_('Error: %s') % str(exc)) emitters.commit() return 1