def _set_up_proxy(self): proxy_settings = self.config.get("settings").get("proxy") if proxy_settings and proxy_settings.get("address"): proxy_url = parse.urlsplit(proxy_settings.get("address")) self.log.debug("Using proxy settings: %s", proxy_url) username = proxy_settings.get("username") pwd = proxy_settings.get("password") if username and pwd: proxy_uri = "%s://%s:%s@%s" % (proxy_url.scheme, username, pwd, proxy_url.netloc) else: proxy_uri = "%s://%s" % (proxy_url.scheme, proxy_url.netloc) proxy_handler = ProxyHandler({"https": proxy_uri, "http": proxy_uri}) opener = build_opener(proxy_handler) install_opener(opener)
def prepare(self): """ Read options for uploading, check that they're sane """ super(BlazeMeterUploader, self).prepare() self.client.address = self.settings.get("address", self.client.address) self.client.data_address = self.settings.get("data-address", self.client.data_address) self.client.timeout = dehumanize_time(self.settings.get("timeout", self.client.timeout)) self.send_interval = dehumanize_time(self.settings.get("send-interval", self.send_interval)) self.browser_open = self.settings.get("browser-open", self.browser_open) token = self.settings.get("token", "") proxy_settings = self.engine.config.get("settings").get("proxy") if proxy_settings: if proxy_settings.get("address"): proxy_url = parse.urlsplit(proxy_settings.get("address")) self.log.debug("Using proxy settings: %s", proxy_url) username = proxy_settings.get("username") pwd = proxy_settings.get("password") if username and pwd: proxy_uri = "%s://%s:%s@%s" % (proxy_url.scheme, username, pwd, proxy_url.netloc) else: proxy_uri = "%s://%s" % (proxy_url.scheme, proxy_url.netloc) proxy_handler = ProxyHandler({"https": proxy_uri, "http": proxy_uri}) opener = build_opener(proxy_handler) install_opener(opener) if not token: self.log.warning("No BlazeMeter API key provided, will upload anonymously") self.client.token = token self.client.active_session_id = self.parameters.get("session-id", None) self.client.test_id = self.parameters.get("test-id", None) self.client.user_id = self.parameters.get("user-id", None) self.client.data_signature = self.parameters.get("signature", None) if not self.client.test_id: test_name = self.parameters.get("test", "Taurus Test") # TODO: provide a way to put datetime into test name try: self.client.ping() # to check connectivity and auth if token: self.test_id = self.client.test_by_name(test_name, {"type": "external"}) except HTTPError: self.log.error("Cannot reach online results storage, maybe the address/token is wrong") raise