How to use get_info_file method in autotest

Best Python code snippet using autotest_python

report.py

Source:report.py Github

copy

Full Screen

...34 def __init__(self, directory):35 self.directory = directory36 def __str__(self):37 return "Parent dir %s of job report does not exist" % self.directory38def get_info_file(filename):39 """40 Gets the contents of an autotest info file.41 It also and highlights the file contents with possible problems.42 :param filename: Info file path.43 """44 data = ''45 errors = re.compile(r"\b(error|fail|failed)\b", re.IGNORECASE)46 if os.path.isfile(filename):47 f = open('%s' % filename, "r")48 lines = f.readlines()49 f.close()50 rx = re.compile('(\'|\")')51 for line in lines:52 new_line = rx.sub('', line)53 errors_found = errors.findall(new_line)54 if len(errors_found) > 0:55 data += '<font color=red>%s</font><br>' % str(new_line)56 else:57 data += '%s<br>' % str(new_line)58 if not data:59 data = 'No Information Found.<br>'60 else:61 data = 'File not found.<br>'62 return data63def parse_results_dir(results_dir, relative_links=True):64 """65 Parse a top level status file and produce a dictionary with job data.66 :param dirname: Autotest results directory path67 :return: Dictionary with job data.68 """69 job_data = {}70 op_data = {}71 res_dir = os.path.abspath(results_dir)72 status_file_name = os.path.join(results_dir, 'status')73 if not os.path.isfile(status_file_name):74 raise InvalidAutotestResultDirError(res_dir)75 file_obj = open(status_file_name, "r")76 status_lines = file_obj.readlines()77 file_obj.close()78 sysinfo_dir = os.path.join(results_dir, 'sysinfo')79 job_data['sysinfo'] = {80 'hostname': get_info_file(os.path.join(sysinfo_dir, 'hostname').strip()),81 'uname': get_info_file(os.path.join(sysinfo_dir, 'uname')),82 'cpuinfo': get_info_file(os.path.join(sysinfo_dir, 'cpuinfo')),83 'meminfo': get_info_file(os.path.join(sysinfo_dir, 'meminfo')),84 'df': get_info_file(os.path.join(sysinfo_dir, 'df')),85 'modules': get_info_file(os.path.join(sysinfo_dir, 'modules')),86 'gcc': get_info_file(os.path.join(sysinfo_dir, 'gcc_--version')),87 'dmidecode': get_info_file(os.path.join(sysinfo_dir, 'dmidecode')),88 'dmesg': get_info_file(os.path.join(sysinfo_dir, 'dmesg'))}89 job_data['results_dir'] = res_dir90 if relative_links:91 job_data['absolute_path'] = None92 else:93 job_data['absolute_path'] = res_dir94 # Initialize job pass state95 job_data['job_passed'] = True96 # Initialize operations counter97 job_data['operations_passed'] = 098 job_data['operations_failed'] = 099 # Format date and time to be displayed100 t = datetime.datetime.now()101 epoch_sec = time.mktime(t.timetuple())102 now = datetime.datetime.fromtimestamp(epoch_sec)...

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