Best Python code snippet using autotest_python
retrieve_logs.py
Source: retrieve_logs.py
...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]...
Check out the latest blogs from LambdaTest on this topic:
How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.
Lack of training is something that creates a major roadblock for a tester. Often, testers working in an organization are all of a sudden forced to learn a new framework or an automation tool whenever a new project demands it. You may be overwhelmed on how to learn test automation, where to start from and how to master test automation for web applications, and mobile applications on a new technology so soon.
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
The sky’s the limit (and even beyond that) when you want to run test automation. Technology has developed so much that you can reduce time and stay more productive than you used to 10 years ago. You needn’t put up with the limitations brought to you by Selenium if that’s your go-to automation testing tool. Instead, you can pick from various test automation frameworks and tools to write effective test cases and run them successfully.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!