def blocking(): web_session = CMKWebSession(site) # disable content parsing on each request for performance reasons web_session._handle_http_response = lambda *args, **kwargs: None # type: ignore web_session.login() web_session.enforce_non_localized_gui() return web_session
def prepare_for_tests(self) -> None: self.verify_cmk() web = CMKWebSession(self) web.login() web.enforce_non_localized_gui() self._add_wato_test_config(web)
def init_wato(self): if not self._missing_but_required_wato_files(): logger.info( "WATO is already initialized -> Skipping initializiation") return logger.debug("Initializing WATO...") web = CMKWebSession(self) web.login() # Call WATO once for creating the default WATO configuration logger.debug( "Requesting wato.py (which creates the WATO factory settings)...") response = web.get("wato.py?mode=sites").text # logger.debug("Debug: %r" % response) assert "site=%s" % web.site.id in response logger.debug("Waiting for WATO files to be created...") wait_time = 20.0 while self._missing_but_required_wato_files() and wait_time >= 0: time.sleep(0.5) wait_time -= 0.5 missing_files = self._missing_but_required_wato_files() assert not missing_files, ("Failed to initialize WATO data structures " "(Still missing: %s)" % missing_files) web.enforce_non_localized_gui() self._add_wato_test_config(web)
def web(site: Site): web = CMKWebSession(site) web.login() web.enforce_non_localized_gui() return web