def test_cancel_timeout(self): start_time = time() ut.timeout(1) sleep(0.3) ut.cancel_timeout() elapsed_time = time() - start_time self.assertLess(elapsed_time, 5, 'Cancel time does not work. %s' % elapsed_time)
def test_cancel_timeout(self): ut.timeout(1) ut.cancel_timeout() try: sleep(1.1) except ut.TimeExceededError: self.fail("Cannot cancel timeout")
def test_should_timeout_onbeforeunload(self): test_url = cm.BASE_TEST_URL + "crawler/onbeforeunload.html" try: ut.timeout(cr.CRAWLER_CLICKER_VISIT_TIMEOUT + 2) cr.crawl_url("chrome_clicker", test_url, "") except ut.TimeExceededError as texc: self.fail("Crawl has timed out %s" % texc)
def get_wang_and_goldberg(self): """Visit the site according to Wang and Goldberg (WPES'13) settings.""" ut.timeout(cm.HARD_VISIT_TIMEOUT) # set timeout to stop the visit self.sniffer.start_capture( self.pcap_path, 'tcp and not host %s and not host %s and not host %s' % (VBOX_GATEWAY_IP, LOCALHOST_IP, LXC_GATEWAY_IP)) time.sleep(cm.PAUSE_BETWEEN_INSTANCES) try: self.tb_driver.set_page_load_timeout(cm.SOFT_VISIT_TIMEOUT) except: wl_log.info("Exception setting a timeout {}".format(self.page_url)) wl_log.info("Crawling URL: {}".format(self.page_url)) t1 = time.time() self.tb_driver.get(self.page_url) page_load_time = time.time() - t1 wl_log.info("{} loaded in {} sec".format(self.page_url, page_load_time)) time.sleep(cm.WAIT_IN_SITE) if self.capture_screen: self.take_screenshot() self.cleanup_visit()
def test_timeout(self): ut.timeout(1) try: sleep(1.1) except ut.TimeExceededError: pass # this is what we want else: self.fail("Cannot set timeout")
def findURLs(user, message, s): message = message[:-1] message = message.lower() url = re.findall(cfg.URL_REGEX, message) if len(url) > 0 and not utils.isOP(user): utils.timeout(s, user, 1) del url[:]
def test_send_data(self): self.router.get() with timeout(0.2): with open(self.pipe, 'wb') as pipe: pipe.write(b'hello\n') with timeout(0.2): self.endpoint.poll(0.01) self.assertEqual(self.router.get(), b'hello\n')
def main(): # Networking functions s = socket.socket() s.connect((cfg.HOST, cfg.PORT)) s.send("PASS {}\r\n".format(cfg.PASS).encode("utf-8")) s.send("NICK {}\r\n".format(cfg.NICK).encode("utf-8")) s.send("JOIN #{}\r\n".format(cfg.CHAN).encode("utf-8")) CHAT_MSG = re.compile(r"^:\w+!\w+@\w+.tmi\.twitch\.tv PRIVMSG #\w+ :") utils.chat(s, "Hi everyone!") _thread.start_new_thread(utils.threadFillOpList, ()) while True: response = s.recv(1024).decode("utf-8") if response == "PING :tmi.twitch.tv\r\n": s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8")) else: username = re.search(r"\w+", response).group(0) message = CHAT_MSG.sub("", response) print(response) # Custom commands if message.strip() == "!time": utils.chat(s, "It is currently " + time.strftime("%I:%M %p %Z on %A, %B %d, %Y.")) if message.strip() == "Hello FantastiBot!": utils.chat(s, "Hello " + username + "!") if message.strip() == "!mods": modlist = [] for i in cfg.oplist: if cfg.oplist[i] == "mod": modlist.append(i) if len(modlist) == 0: utils.chat(s, "There are no moderators currently online.") elif len(modlist) == 1: utils.chat(s, "Currently, " + modlist[0] + " is the only moderator online.") elif len(modlist) >= 2: modString = "" for i in range(len(modlist)): if i == len(modlist)-1: modString += modlist[i] elif i == len(modlist)-2: modString += modlist[i] + " and " elif i < len(modlist)-2: modString += modlist[i] + ", " utils.chat(s, modString + " are currently moderating.") # Custom OP commands if utils.isOp(username): if message.strip() == "!messages": utils.chat(s, "Please follow me, I don't bite.") utils.chat(s, "I'm so lonely.") if message.strip().find("!timeout") != -1: utils.timeout(s, message[9:]) sleep(1)
def deploy_branch(template_pod, template_service, branch, domain_zone): svc = deploy_service(template_pod, template_service, branch, domain_zone) svc_name = svc[1] lb_name = svc[0] port = set_healthcheck(lb_name) fqdn = "{0}-{1}.{2}".format(svc_name, branch, domain_zone) change_id = create_cname.create_rr(fqdn, lb_name) print "Creating DNS record and waiting for sync" result = utils.timeout(120, 2)(create_cname.is_change_complete)(change_id) print "Created DNS record" print "Waiting for ELB healthcheck to pass" result = utils.timeout(240, 2)(is_elb_up)(lb_name) print "Service up at: {0}".format(fqdn) print "DONE" return "http://{0}:{1}".format(fqdn, port)
def close_all_streams(self): """Close all streams of a controller.""" print("Closing all streams") try: ut.timeout(cm.STREAM_CLOSE_TIMEOUT) for stream in self.controller.get_streams(): print("Closing stream %s %s %s " % (stream.id, stream.purpose, stream.target_address)) self.controller.close_stream(stream.id) # MISC reason except ut.TimeExceededError: print("Closing streams timed out!") except: print("Exception closing stream") finally: ut.cancel_timeout()
def validate_access_key(): # Obtain access key try: access_key = self.cleaned_data['access_key'] except KeyError: raise forms.ValidationError("Access key is missing.") # Validate access key try: user_data = UserData.from_key(access_key) except InvalidUserKeyError: raise forms.ValidationError("Invalid access key.") # Check if this access key has access to given volume user_sx = SXController(cluster, user_data) full_path = self.cleaned_data['path'] volume, path = core.split_path(full_path) with timeout(error_message="" "ShareFileForm.clean.validate_access_key: " "File listing timed out."): try: user_sx.listFiles.json_call(volume, path) except SXClusterClientError: raise forms.ValidationError("Provide a valid access key. " "Make sure you have access to " "the file you want to share.")
def test_presence(self): client = self._connect("user") client = socket.create_connection(self.addr) cl_addr = client.getsockname() self.addCleanup(client.close) self.endpoint.poll(0.01) client.send(b'user\n') with timeout(0.2): self.endpoint.poll(0.01) channel = ':'.join(("tcp", cl_addr[0], str(cl_addr[1]))) data = self.router.get() self.assertTrue(data.endswith(b'\n')) self.assertEqual( json.loads(data.decode().strip()), { 'event': "presence", 'from': { 'user': "******", 'channel': channel }, 'to': { 'user': '******', 'channel': 'brain' } })
def test_link_socats(self): cfg = ''' variables: SOCK: tmpfile components: socat1: command: socat STDIO UNIX-LISTEN:${SOCK} wait-for: ${SOCK} socat2: command: socat STDIO UNIX:${SOCK} after: socat1 ''' km = Kapellmeister(Config(cfg)) km.run() channel1 = km.connect("socat1") channel2 = km.connect("socat2") channel1.write(b'howdy\n') with timeout(1): line = b'' while not line.endswith(b'\n'): line += channel2.read() self.assertEqual(line, b'howdy\n')
def verify(self, data, *expected): client = socket.socket(socket.AF_UNIX) client.connect(self._sock_file) self.addCleanup(client.close) with timeout(0.1): result = self._poller.poll(0.01) cl_chan = result[0][0][1] with timeout(0.1): client.send(data) with timeout(0.1): result = self._poller.poll(0.01) self.assertEqual(result, [(a, cl_chan) for a in expected])
def get_screenshot_if_enabled(self): if self.screenshots: try: with ut.timeout(5): self.driver.get_screenshot_as_file(self.job.png_file) except Exception: wl_log.error("Cannot get screenshot.")
def test_two_components(self): dirname = mkdtemp() sock = os.path.join(dirname, "sock") self.addCleanup(shutil.rmtree, dirname) cfg = ''' components: socat1: command: socat STDIO UNIX-LISTEN:{sock} wait-for: {sock} socat2: command: socat UNIX:{sock} STDIO after: socat1 '''.format(sock=sock) km = Kapellmeister(Config(cfg)) km.run() channel1 = km.connect("socat1") channel2 = km.connect("socat2") channel1.write(b'howdy\n') with timeout(1): line = b'' while not line.endswith(b'\n'): line += channel2.read() self.assertEqual(line, b'howdy\n')
def execute(self): _log.info('Start to execute the plan') _log.info('Start a new benchmark') results = [] benchmarkBuilder = BenchmarkBuilderFactory.create([self.plan['benchmark_builder']]) webRoot = benchmarkBuilder.prepare(self.plan['original_benchmark'], self.plan['benchmark_patch'] if 'benchmark_patch' in self.plan else None) for x in xrange(int(self.plan['count'])): _log.info('Start the iteration %d of current benchmark' % (x + 1)) self.httpServerDriver.serve(webRoot) self.browserDriver.prepareEnv() self.browserDriver.launchUrl(urlparse.urljoin(self.httpServerDriver.baseUrl(), self.plan['entry_point']), self.buildDir) try: with timeout(self.plan['timeout']): result = json.loads(self.httpServerDriver.fetchResult()) assert(not self.httpServerDriver.getReturnCode()) assert(result) results.append(result) except: _log.error('No result or server crashes. Something went wrong. Will skip current benchmark.') self.browserDriver.closeBrowsers() self.httpServerDriver.killServer() benchmarkBuilder.clean() return 1 finally: self.browserDriver.closeBrowsers() _log.info('End of %d iteration of current benchmark' % (x + 1)) results = self.wrap(results) self.dump(results, self.outputFile if self.outputFile else self.plan['output_file']) benchmarkBuilder.clean() return 0
def close_all_streams(self): """Close all streams of a controller.""" wl_log.debug("Closing all streams") try: ut.timeout(cm.STREAM_CLOSE_TIMEOUT) for stream in self.controller.get_streams(): wl_log.debug( "Closing stream %s %s %s " % (stream.id, stream.purpose, stream.target_address)) self.controller.close_stream(stream.id) # MISC reason except ut.TimeExceededError: wl_log.critical("Closing streams timed out!") except: wl_log.debug("Exception closing stream") finally: ut.cancel_timeout()
def execute(self): _log.info('Start to execute the plan') _log.info('Start a new benchmark') results = [] self._benchmark_builder = BenchmarkBuilderFactory.create(self._plan['benchmark_builder']) web_root = self._benchmark_builder.prepare(self._plan_name, self._plan) for x in xrange(int(self._plan['count'])): _log.info('Start the iteration %d of current benchmark' % (x + 1)) self._http_server_driver.serve(web_root) self._browser_driver.prepare_env(self._device_id) url = urlparse.urljoin(self._http_server_driver.base_url(), self._plan_name + '/' + self._plan['entry_point']) self._browser_driver.launch_url(url, self._build_dir) result = None try: with timeout(self._plan['timeout']): result = self._http_server_driver.fetch_result() assert(not self._http_server_driver.get_return_code()) assert(result) results.append(json.loads(result)) except Exception as error: _log.error('No result or the server crashed. Something went wrong. Will skip current benchmark.\nError: %s, Server return code: %d, result: %s' % (error, self._http_server_driver.get_return_code(), result)) self._cleanup() sys.exit(1) finally: self._browser_driver.close_browsers() _log.info('End of %d iteration of current benchmark' % (x + 1)) results = self._wrap(results) self._dump(results, self._output_file if self._output_file else self._plan['output_file']) self._show_results(results) self._benchmark_builder.clean() sys.exit()
def _run_benchmark(self, count, web_root): results = [] for iteration in xrange(1, count + 1): _log.info( 'Start the iteration {current_iteration} of {iterations} for current benchmark' .format(current_iteration=iteration, iterations=count)) try: result = None self._http_server_driver.serve(web_root) self._browser_driver.prepare_env(self._device_id) url = urlparse.urljoin( self._http_server_driver.base_url(), self._plan_name + '/' + self._plan['entry_point']) self._browser_driver.launch_url(url, self._build_dir) with timeout(self._plan['timeout']): result = self._http_server_driver.fetch_result() assert (not self._http_server_driver.get_return_code()) assert (result) results.append(json.loads(result)) finally: self._browser_driver.restore_env() self._browser_driver.close_browsers() self._http_server_driver.kill_server() _log.info( 'End the iteration {current_iteration} of {iterations} for current benchmark' .format(current_iteration=iteration, iterations=count)) results = self._wrap(results) self._dump( results, self._output_file if self._output_file else self._plan['output_file']) self.show_results(results, self._scale_unit)
def test_echo(self): msg = { "message": "test", "from": { "user": "******", "channel": 'channel' }, "to": "brain" } self._sock.send(json.dumps(msg).encode() + b'\n') self._fb.work(1) self.assertEquals(self._fb.messages, [msg]) with timeout(0.2): data = self._sock.recv(1024) self.assertTrue(data.endswith(b'\n')) msg = json.loads(data.decode().strip()) self.assertEqual( msg, { "message": "test", "from": "brain", "to": { "user": "******", "channel": 'channel' } })
def test_poll_no_data(self): chan = TestChannel() self._poller.register(chan) with timeout(0.02): result = self._poller.poll(0.01) self.assertEqual(list(result), [])
def step_impl(context): with timeout(1): while len(context.tr_messages) == context.last_tr_message: sleep(0.1) line = context.tr_messages[context.last_tr_message] _LOGGER.debug("Translator got [%s]", line) compare_json(line, context.text) context.last_tr_message += 1
def clean_path(): invalid_path = forms.ValidationError("Invalid file path.") # Obtain volume and path try: full_path = self.cleaned_data['path'] volume, path = core.split_path(full_path) except (KeyError, ValueError): raise invalid_path # Check if volume exists with timeout(error_message="ShareFileForm.clean.clean_path: " "Volume listing timed out."): volumes = sx.listVolumes \ .json_call(includeMeta=True)['volumeList'] try: volume_data = volumes[volume] except KeyError: raise forms.ValidationError( "No such volume: {}.".format(volume)) # Check for filters (they are unsupported) meta = volume_data['volumeMeta'] if meta.get('filterActive'): raise forms.ValidationError( "Volumes with filters are not supported yet.") # Check if path is valid: with timeout(error_message="ShareFileForm.clean.clean_path: " "File listing timed out."): try: matches = sx.listFiles \ .json_call(volume, path)['fileList'].keys() matches = [m.lstrip('/') for m in matches] except SXClientException: raise invalid_path if not matches: raise forms.ValidationError( "No such file or directory: {}".format(full_path)) elif not core.is_dir(path) and path not in matches: raise forms.ValidationError( "Specify the exact path of the file.") # Store the cleaned path self.cleaned_data['path'] = os.path.join(volume, path.lstrip('/')) return volume, path
def roulette(user, s): utils.sendMessage(s, "places the revolver to " + user + "'s head") time.sleep(2.5) num = random.randint(0, 1) if num == 0: utils.sendMessage( s, "The trigger is pulled, and the revolver clicks. " + user + " has lived to survive roulette!") else: if utils.isOP(user): utils.sendMessage( s, "The trigger is pulled, but the revolver malfunctions! " + user + " has miraculously lived to survive roulette") else: utils.sendMessage( s, "The trigger is pulled, and the revolver fires! " + user + " lies dead in chat") utils.timeout(s, user, 30)
def test_poll_data(self): chan = TestChannel() self._poller.register(chan) chan.put(b'hello\n') with timeout(0.02): result = self._poller.poll() self.assertEqual(list(result), [(b'hello\n', chan)])
def test_unregister(self): chan = TestChannel() self._poller.register(chan) chan.put(b'hello\n') self._poller.unregister(chan) with self.assertRaisesRegex(Exception, "timeout"), timeout(0.02): self._poller.poll()
def logic(s, m, channel, badWords): chat_message = re.compile(r"^:\w+!\w+@\w+\.tmi\.twitch\.tv PRIVMSG #\w+ :") username = re.search(r"\w+", m).group(0) message = chat_message.sub("", m) if m.__contains__(f"@{config.NICK}.tmi.twitch.tv") and username == config.NICK: print(f"Connected to channel {channel} successfully") elif not m.__contains__(f":tmi.twitch.tv 001 {config.NICK} :Welcome, GLHF!") and username != "twi" \ and username != config.NICK and username != "tmi": print(f"{channel}@{username}: {message}") message = message.strip() for word in message.split(): if word in badWords: utils.timeout(s, channel, username, 55) if message == "!time": utils.sendmsg(s, channel, "it's currently: " + asctime(localtime())) elif message.strip().__contains__("!ban"): utils.timeout(s, channel, username, 30 if message.strip() == "!ban" else int(message.strip().split("!ban")[1]))
def get_multitab(self): """Open two tab, use one to load a background site and the other to load the real site.""" PAUSE_BETWEEN_TAB_OPENINGS = 0.5 ut.timeout(cm.HARD_VISIT_TIMEOUT) # set timeout to kill running procs # load a blank page - a page is needed to send keys to the browser self.tb_driver.get(BAREBONE_HOME_PAGE) self.sniffer.start_capture( self.pcap_path, 'tcp and not host %s and not host %s' % (VBOX_GATEWAY_IP, LOCALHOST_IP)) time.sleep(cm.PAUSE_BETWEEN_INSTANCES) try: self.tb_driver.set_page_load_timeout(cm.SOFT_VISIT_TIMEOUT) except: wl_log.info("Exception setting a timeout {}".format(self.page_url)) wl_log.info("Crawling URL: {} with {} in the background".format( self.page_url, self.bg_site)) body = self.tb_driver.find_element_by_tag_name("body") body.send_keys(Keys.CONTROL + 't') # open a new tab # now that the focus is on the address bar, load the background # site by "typing" it to the address bar and "pressing" ENTER (\n) # simulated by send_keys function body.send_keys('%s\n' % self.bg_site) # the delay between the loading of background and real sites time.sleep(PAUSE_BETWEEN_TAB_OPENINGS) body = self.tb_driver.find_element_by_tag_name("body") body.send_keys(Keys.CONTROL + 't') # open a new tab t1 = time.time() self.tb_driver.get(self.page_url) # load the real site in the 2nd tab page_load_time = time.time() - t1 wl_log.info("{} loaded in {} sec".format(self.page_url, page_load_time)) time.sleep(cm.WAIT_IN_SITE) if self.capture_screen: self.take_screenshot() self.cleanup_visit()
def ask_input(self, question): answer = '' while not answer: try: with timeout(seconds=25): answer = input(question) except TimeoutError: print('Input timed out...') yield return answer
def get_multitab(self): """Open two tab, use one to load a background site and the other to load the real site.""" PAUSE_BETWEEN_TAB_OPENINGS = 0.5 ut.timeout(cm.HARD_VISIT_TIMEOUT) # set timeout to kill running procs # load a blank page - a page is needed to send keys to the browser self.tb_driver.get(BAREBONE_HOME_PAGE) self.sniffer.start_capture(self.pcap_path, 'tcp and not host %s and not tcp port 22 and not tcp port 20' % LOCALHOST_IP) time.sleep(cm.PAUSE_BETWEEN_INSTANCES) try: self.tb_driver.set_page_load_timeout(cm.SOFT_VISIT_TIMEOUT) except: wl_log.info("Exception setting a timeout {}".format(self.page_url)) wl_log.info("Crawling URL: {} with {} in the background". format(self.page_url, self.bg_site)) body = self.tb_driver.find_element_by_tag_name("body") body.send_keys(Keys.CONTROL + 't') # open a new tab # now that the focus is on the address bar, load the background # site by "typing" it to the address bar and "pressing" ENTER (\n) # simulated by send_keys function body.send_keys('%s\n' % self.bg_site) # the delay between the loading of background and real sites time.sleep(PAUSE_BETWEEN_TAB_OPENINGS) body = self.tb_driver.find_element_by_tag_name("body") body.send_keys(Keys.CONTROL + 't') # open a new tab t1 = time.time() self.tb_driver.get(self.page_url) # load the real site in the 2nd tab page_load_time = time.time() - t1 wl_log.info("{} loaded in {} sec" .format(self.page_url, page_load_time)) time.sleep(cm.WAIT_IN_SITE) if self.capture_screen: self.take_screenshot() self.cleanup_visit()
def test_closed(self): chan = TestChannel() self._poller.register(chan) chan.close() with timeout(0.01): result = self._poller.poll() self.assertEquals(result, [(b'', chan)])
def test_close_all_servers(self): serv = socket.socket() serv.bind(('127.0.0.1', 0)) serv.listen(0) self.addCleanup(serv.close) self._poller.add_server(serv) self._poller.close_all() with timeout(0.01), self.assertRaises(OSError): serv.accept()
def _is_isomorphic_with_timeout(g1, g2, node_match, edge_match): try: with timeout(seconds=ISOMORPHISM_TIMEOUT): result = nx.is_isomorphic(g1, g2, node_match=node_match, edge_match=edge_match) return result, True except TimeoutError: result = nx.could_be_isomorphic(g1, g2) return result, False
def __do_visit(self): with Sniffer(path=self.job.pcap_file, filter=cm.DEFAULT_FILTER): sleep(1) # make sure dumpcap is running try: with ut.timeout(cm.HARD_VISIT_TIMEOUT): self.driver.get(self.job.url) sleep(float(self.job.config['pause_in_site'])) except (cm.HardTimeoutException, TimeoutException): wl_log.error("Visit to %s has timed out!", self.job.url) except Exception as exc: wl_log.error("Unknown exception: %s", exc)
def identify_task(): start = start_timeout() while timeout(start) < 2.5: image = ImageGrab.grab() for task in TaskIdentifier.tasks: name = task["name"] pos = task["pos"] if image_in_another(image, task["path"], pos): #print(f"[I] Identified task: {name}") return name
def crawl_url(crawler_type, page_url, proxy_opt): if 'clicker' in crawler_type: worker = click_crawler else: worker = lazy_crawler br = init_browser('chrome', ['--allow-running-insecure-content', '--ignore-certificate-errors', '--disk-cache-size=0', \ '--enable-logging', '--v=1', "--proxy-server=%s" % proxy_opt]) if not page_url.startswith('http') and not page_url.startswith('file:'): page_url = 'http://' + page_url wl_log.info('***Will crawl %s***' % page_url) try: ut.timeout(CRAWLER_CLICKER_VISIT_TIMEOUT) worker(br, page_url) # run the worker function except ut.TimeExceededError as texc: wl_log.critical('***CRAWLER_CLICKER_VISIT_TIMEOUT at %s (%s)' % (page_url, texc)) finally: br.quit()
def _run_one_test(self, web_root, test_file): result = None try: self._http_server_driver.serve(web_root) url = urlparse.urljoin(self._http_server_driver.base_url(), self._plan_name + '/' + test_file) self._browser_driver.launch_url(url, self._plan['options'], self._build_dir) with timeout(self._plan['timeout']): result = self._get_result(url) finally: self._browser_driver.close_browsers() self._http_server_driver.kill_server() return json.loads(result)
def get_wang_and_goldberg(self): """Visit the site according to Wang and Goldberg (WPES'13) settings.""" ut.timeout(cm.HARD_VISIT_TIMEOUT) # set timeout to stop the visit self.sniffer.start_capture(self.pcap_path, 'tcp and not host %s and not tcp port 22 and not tcp port 20' % LOCALHOST_IP) time.sleep(cm.PAUSE_BETWEEN_INSTANCES) try: self.tb_driver.set_page_load_timeout(cm.SOFT_VISIT_TIMEOUT) except: wl_log.info("Exception setting a timeout {}".format(self.page_url)) wl_log.info("Crawling URL: {}".format(self.page_url)) t1 = time.time() self.tb_driver.get(self.page_url) page_load_time = time.time() - t1 wl_log.info("{} loaded in {} sec" .format(self.page_url, page_load_time)) time.sleep(cm.WAIT_IN_SITE) if self.capture_screen: self.take_screenshot() self.cleanup_visit()
def start_blocking(login, passw, scums_file): fb = init(login, passw) # records = scums() for i, line in enumerate(scums_file): if scum_exists(line): continue # if url in file already in DB - continue # if line in records: continue # if url in file already in DB - continue try: with timeout(30): fb.block(line) # sleep(t) except (Exception,) as e: logger.error("cycle error {}".format(e)) system("killall firefox") fb = init(login, passw) sleep(t) else: logger.info("{0}:{1} is blocked".format(str(i), line))
def _run_benchmark(self, count, web_root): results = [] for iteration in xrange(1, count + 1): _log.info('Start the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count)) try: result = None self._http_server_driver.serve(web_root) self._browser_driver.prepare_env(self._device_id) url = urlparse.urljoin(self._http_server_driver.base_url(), self._plan_name + '/' + self._plan['entry_point']) self._browser_driver.launch_url(url, self._build_dir) with timeout(self._plan['timeout']): result = self._http_server_driver.fetch_result() assert(not self._http_server_driver.get_return_code()) assert(result) results.append(json.loads(result)) finally: self._browser_driver.restore_env() self._browser_driver.close_browsers() self._http_server_driver.kill_server() _log.info('End the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count)) results = self._wrap(results) self._dump(results, self._output_file if self._output_file else self._plan['output_file']) self.show_results(results, self._scale_unit)
def wait_for_ssh(self, stack_id, timeout=300, interval=30): return utils.timeout(timeout, interval)( self.is_ssh_up_on_all_instances)(stack_id)
set_domain(MULTICAN_DOMAIN) print("\n\nRUNNING MULTI CAN DOMAIN\n\n") else: print("Bad domain input: need l or t for logistics or two box domain respectively") sys.exit(-1) elif opt == "-r": print("Transforming objects to match result of previous plannerWrapper run") pw_file = True try: planner = settings.PLANNER_TO_USE except AttributeError as e: print("No domain provided.") print(usage_str()) sys.exit(-1) if run_test_mode[0]: # settings.toggle_use_ros() hp = HybridPlanner(settings.pddlDomainFile, settings.pddlDomainFileNoGeomEff, settings.initialProblemFile, viewer, envFile, planner=planner, pw_file=pw_file) hp.iterativePlan = utils.timeout(seconds=run_test_mode[1])(hp.iterativePlan) try: hp.iterativePlan() except utils.TimeoutError as e: print("Timed out: %s" %e) sys.exit(1) else: hp = HybridPlanner(settings.pddlDomainFile, settings.pddlDomainFileNoGeomEff, settings.initialProblemFile, viewer, envFile, planner=planner, pw_file=pw_file) hp.iterativePlan()