How to use find_repository_host method in autotest

Best Python code snippet using autotest_python

retrieve_logs.py

Source:retrieve_logs.py Github

copy

Full Screen

...37 _retrieve_dummy)38site_find_repository_host = utils.import_site_function(__file__,39 "autotest.tko.site_retrieve_logs", "site_find_repository_host",40 _retrieve_dummy)41def find_repository_host(job_path):42 '''43 Find the machine holding the given logs and return a URL to the logs44 :param job_path: when this was a CGI script, this value came from the45 'job' variable, which was usually composed of '/results/' +46 a path such as '1-autotest' or '1-autotest/status.log'47 :type job_path: str48 :returns: a tuple with three members: protocol (such as "http"), host49 (such as "foo.bar.com") and a path such as "/results/1-autotest"50 :rtype: tuple or None51 '''52 site_repo_info = site_find_repository_host(job_path)53 if site_repo_info is not None:54 return site_repo_info55 results_repos = [RESULTS_HOST]56 for drone in DRONES.split(','):57 drone = drone.strip()58 if drone not in results_repos:59 results_repos.append(drone)60 if ARCHIVE_HOST and ARCHIVE_HOST not in results_repos:61 results_repos.append(ARCHIVE_HOST)62 for drone in results_repos:63 if drone == 'localhost':64 continue65 http_path = 'http://%s%s' % (drone, job_path)66 try:67 logging.info('Attempting to access the selected results URL: "%s"',68 http_path)69 utils.urlopen(http_path)70 return 'http', utils.normalize_hostname(drone), job_path71 except urllib2.URLError:72 logging.error('Failed to access the selected results URL. '73 'Reverting to usual results location')74 pass75def get_full_url(info, log_path):76 '''77 Returns the full URL of the requested log path78 :param info: a 3 element tuple such with protocol, host and path, usually79 the output from the find_repository_host function.80 :type info: tuple81 :param log_path: when this was a CGI script, this value came from the82 'job' variable, which was usually composed of '/results/' +83 a path such as '1-autotest' or '1-autotest/status.log'84 :type log_path: str85 :returns: the full url of the log file or directory request86 :rtype: str87 '''88 if info is not None:89 protocol, host, path = info90 prefix = '%s://%s' % (protocol, host)91 else:92 prefix = ''93 path = log_path94 return prefix + path95def retrieve_logs(path):96 host = find_repository_host(path)97 if host is None:98 logging.info('No special host was found holding the results')99 # It's not clear what was intended here. Maybe some custom action to100 # fetch/unpack the logs?101 site_retrieve_logs(path)102 results_url = get_full_url(host, path)103 logging.info('Results url: %s', results_url)104 return results_url105if __name__ == '__main__':106 logging_manager.configure_logging(LoggingConfig(), verbose=True)107 if len(sys.argv) <= 1:108 logging.error('Usage: %s [log_path]', sys.argv[0])109 raise SystemExit110 path = sys.argv[1]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful