Best Python code snippet using autotest_python
tko_publish.py
Source:tko_publish.py
...20 job result directories.21 Example: user@machine.org:/home/autotest/results"""22PUBLISH_FLAGFILE = '.tko_published'23RSYNC_COMMAND = 'rsync -aqz "%s" "%s"'24def get_job_dirs(path):25 regex = re.compile('[1-9][0-9]*-')26 jobdirs = []27 for dir in os.listdir(path):28 # skip directories not matching the job result dir pattern29 if not regex.match(dir):30 continue31 dir = os.path.join(options.resultsdir, dir)32 if (os.path.isdir(dir)33 and not os.path.exists(os.path.join(dir, PUBLISH_FLAGFILE))):34 jobdirs.append(dir)35 return jobdirs36def publish_job(jobdir):37 cmd = RSYNC_COMMAND % (jobdir, options.dest)38 utils.system(cmd)39 # mark the jobdir as published40 fd = open(os.path.join(jobdir, PUBLISH_FLAGFILE), 'w')41 fd.close()42 print 'Published', jobdir43def main():44 jobdirs = get_job_dirs(options.resultsdir)45 afe = frontend.AFE()46 # the way AFE API is right now is to give a whole list of jobs and can't47 # get specific jobs so minimize the queries caching the result48 finished_jobs = afe.get_jobs(finished=True)49 if options.jobname_pattern:50 jobname_pattern = re.compile(options.jobname_pattern)51 else:52 jobname_pattern = None53 # for each unpublished possible jobdir find it in the database and see54 # if it is completed55 for jobdir in jobdirs:56 job_id = int(os.path.basename(jobdir).split('-')[0])57 job = [job for job in finished_jobs if job.id == job_id]58 if len(job) != 1:...
verify_files.py
Source:verify_files.py
...4REQUIRED_FILES = {CI_JOB_NAME, CI_WORKFLOW_NAME, "README.md", "Dockerfile"}5def check_missing_files() -> List[Tuple[str, Set[str]]]:6 """Check all job directories for missing files."""7 failed_jobs = []8 for job_dir in get_job_dirs():9 files = {content.name for content in job_dir.glob("*") if content.is_file()}10 missing_files = REQUIRED_FILES - files11 if len(missing_files) > 0:12 failed_jobs.append((job_dir.name, missing_files))13 print(f"{job_dir.name} missing files: {', '.join(missing_files)}")14 return failed_jobs15if __name__ == "__main__":...
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!!