Source code for commands.execute_all_notifications
"""This module contains a Django management command to execute all task-related notifications sequentially."""from__future__importannotationsfromtypingimportAnyfromdjango.core.managementimportCommandError,call_commandfromdjango.core.management.baseimportBaseCommand
[docs]classCommand(BaseCommand):"""A Django management command to run all task-related commands in sequence."""
[docs]help='Run all task-related commands sequentially.'
[docs]defhandle(self,*args:Any,**kwargs:dict[str,Any])->None:# noqa: ARG002"""Entrypoint for the command. Args: *args: Additional positional arguments. **kwargs: Additional keyword arguments. """commands_to_run=['trustpoint_setup_notifications','check_system_health','check_for_security_vulnerabilities','check_certificate_validity','check_issuing_ca_validity','check_domain_issuing_ca','check_non_onboarded_devices','check_for_weak_signature_algorithms','check_for_insufficient_key_length','check_for_weak_ecc_curves',]forcommandincommands_to_run:self.stdout.write(self.style.NOTICE(f'Running {command}...'))try:call_command(command)self.stdout.write(self.style.SUCCESS(f'Successfully completed {command}.'))exceptCommandErrorase:self.stdout.write(self.style.ERROR(f'CommandError while running {command}: {e}'))exceptExceptionase:# noqa: BLE001self.stdout.write(self.style.ERROR(f'Unexpected error while running {command}: {e}'))self.stdout.write(self.style.SUCCESS('All tasks completed.'))