Best Python code snippet using autotest_python
base_utils.py
Source:base_utils.py
...93 if not pid in __tmp_dirs:94 __tmp_dirs[pid] = []95 __tmp_dirs[pid].append(dir_name)96 return dir_name97def __clean_tmp_dirs():98 """Erase temporary directories that were created by the get_tmp_dir()99 function and that are still present.100 """101 pid = os.getpid()102 if pid not in __tmp_dirs:103 return104 for dir in __tmp_dirs[pid]:105 try:106 shutil.rmtree(dir)107 except OSError, e:108 if e.errno == 2:109 pass110 __tmp_dirs[pid] = []111atexit.register(__clean_tmp_dirs)112subcommand.subcommand.register_join_hook(lambda _: __clean_tmp_dirs())113def unarchive(host, source_material):114 """Uncompress and untar an archive on a host.115 If the "source_material" is compresses (according to the file116 extension) it will be uncompressed. Supported compression formats117 are gzip and bzip2. Afterwards, if the source_material is a tar118 archive, it will be untarred.119 Args:120 host: the host object on which the archive is located121 source_material: the path of the archive on the host122 Returns:123 The file or directory name of the unarchived source material.124 If the material is a tar archive, it will be extracted in the125 directory where it is and the path returned will be the first126 entry in the archive, assuming it is the topmost directory....
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!!