parameters: (self)
docstring: Handled critical repositories during runtime.
docstring_summary: Handled critical repositories during runtime.
docstring_tokens: Handled critical repositories during runtime .
function: async def handle_critical_repositories(self):
          """Handled critical repositories during runtime."""
          # Get critical repositories
          critical_queue = QueueManager()
          instored = []
          critical = []
          was_installed = False
  
          try:
              critical = await self.async_github_get_hacs_default_file("critical")
          except GitHubNotModifiedException:
              return
          except GitHubException:
              pass
  
          if not critical:
              self.log.debug("No critical repositories")
              return
  
          stored_critical = await async_load_from_store(self.hass, "critical")
  
          for stored in stored_critical or []:
              instored.append(stored["repository"])
  
          stored_critical = []
  
          for repository in critical:
              removed_repo = get_removed(repository["repository"])
              removed_repo.removal_type = "critical"
              repo = self.get_by_name(repository["repository"])
  
              stored = {
                  "repository": repository["repository"],
                  "reason": repository["reason"],
                  "link": repository["link"],
                  "acknowledged": True,
              }
              if repository["repository"] not in instored:
                  if repo is not None and repo.installed:
                      self.log.critical(
                          "Removing repository %s, it is marked as critical",
                          repository["repository"],
                      )
                      was_installed = True
                      stored["acknowledged"] = False
                      # Remove from HACS
                      critical_queue.add(repository.uninstall())
                      repo.remove()
  
              stored_critical.append(stored)
              removed_repo.update_data(stored)
  
          # Uninstall
          await critical_queue.execute()
  
          # Save to FS
          await async_save_to_store(self.hass, "critical", stored_critical)
  
          # Restart HASS
          if was_installed:
              self.log.critical("Resarting Home Assistant")
              self.hass.async_create_task(self.hass.async_stop(100))
function_tokens: async def handle_critical_repositories ( self ) : # Get critical repositories critical_queue = QueueManager ( ) instored = [ ] critical = [ ] was_installed = False try : critical = await self . async_github_get_hacs_default_file ( "critical" ) except GitHubNotModifiedException : return except GitHubException : pass if not critical : self . log . debug ( "No critical repositories" ) return stored_critical = await async_load_from_store ( self . hass , "critical" ) for stored in stored_critical or [ ] : instored . append ( stored [ "repository" ] ) stored_critical = [ ] for repository in critical : removed_repo = get_removed ( repository [ "repository" ] ) removed_repo . removal_type = "critical" repo = self . get_by_name ( repository [ "repository" ] ) stored = { "repository" : repository [ "repository" ] , "reason" : repository [ "reason" ] , "link" : repository [ "link" ] , "acknowledged" : True , } if repository [ "repository" ] not in instored : if repo is not None and repo . installed : self . log . critical ( "Removing repository %s, it is marked as critical" , repository [ "repository" ] , ) was_installed = True stored [ "acknowledged" ] = False # Remove from HACS critical_queue . add ( repository . uninstall ( ) ) repo . remove ( ) stored_critical . append ( stored ) removed_repo . update_data ( stored ) # Uninstall await critical_queue . execute ( ) # Save to FS await async_save_to_store ( self . hass , "critical" , stored_critical ) # Restart HASS if was_installed : self . log . critical ( "Resarting Home Assistant" ) self . hass . async_create_task ( self . hass . async_stop ( 100 ) )