diff --git a/vmupdate/tests/test_vmupdate.py b/vmupdate/tests/test_vmupdate.py index 2147d16..d34dcf4 100644 --- a/vmupdate/tests/test_vmupdate.py +++ b/vmupdate/tests/test_vmupdate.py @@ -33,9 +33,11 @@ @patch('logging.FileHandler') @patch('logging.getLogger') def test_no_options_do_nothing(_logger, _log_file, _chmod, _chown, test_qapp): - args = [] test_qapp.domains = test_qapp.Domains() TestVM("dom0", test_qapp, klass="AdminVM") + args = [] + assert main(args, test_qapp) == 0 + args = ['--signal-no-updates'] assert main(args, test_qapp) == 100 diff --git a/vmupdate/vmupdate.py b/vmupdate/vmupdate.py index 9ae8caf..14edf51 100644 --- a/vmupdate/vmupdate.py +++ b/vmupdate/vmupdate.py @@ -55,7 +55,7 @@ def main(args=None, app=qubesadmin.Qubes()): if not targets: if not args.quiet: print("No qube selected for update") - return 100 + return 100 if args.signal_no_updates else 0 independent = [target for target in targets if target.klass in ( 'TemplateVM', 'StandaloneVM')] @@ -75,7 +75,7 @@ def main(args=None, app=qubesadmin.Qubes()): args, independent, templ_statuses, app_statuses, log) ret_code = max(ret_code_independent, ret_code_appvm, ret_code_restart) - if ret_code == 0 and no_updates: + if ret_code == 0 and no_updates and args.signal_no_updates: return 100 return ret_code @@ -97,6 +97,10 @@ def parse_args(args, app): help='Do not remove updater files from target qube') parser.add_argument('--dry-run', action='store_true', help='Just print what happens.') + parser.add_argument( + '--signal-no-updates', action='store_true', + help='Return exit code 100 instread of 0 ' + 'if there is no updates available.') restart = parser.add_mutually_exclusive_group() restart.add_argument(