How to use _ensure_directory_exists method in autotest

Best Python code snippet using autotest_python

config_helpers.py

Source:config_helpers.py Github

copy

Full Screen

...62 """Return ``user_data_dir``."""63 directory = appdirs.user_data_dir(self.appname, self.appauthor,64 version=self.version, roaming=self.roaming)65 if self.create:66 self._ensure_directory_exists(directory)67 return directory68 @property69 def site_data_dir(self):70 """Return ``site_data_dir``."""71 directory = appdirs.site_data_dir(self.appname, self.appauthor,72 version=self.version, multipath=self.multipath)73 if self.create:74 self._ensure_directory_exists(directory)75 return directory76 @property77 def user_config_dir(self):78 """Return ``user_config_dir``."""79 directory = appdirs.user_config_dir(self.appname, self.appauthor,80 version=self.version, roaming=self.roaming)81 if self.create:82 self._ensure_directory_exists(directory)83 return directory84 @property85 def site_config_dir(self):86 """Return ``site_config_dir``."""87 directory = appdirs.site_config_dir(self.appname, self.appauthor,88 version=self.version, multipath=self.multipath)89 if self.create:90 self._ensure_directory_exists(directory)91 return directory92 @property93 def user_cache_dir(self):94 """Return ``user_cache_dir``."""95 directory = appdirs.user_cache_dir(self.appname, self.appauthor,96 version=self.version)97 if self.create:98 self._ensure_directory_exists(directory)99 return directory100 @property101 def user_log_dir(self):102 """Return ``user_log_dir``."""103 directory = appdirs.user_log_dir(self.appname, self.appauthor,104 version=self.version)105 if self.create:106 self._ensure_directory_exists(directory)107 return directory108 def _ensure_directory_exists(self, directory):109 """Ensure that the passed path exists."""110 if not os.path.lexists(directory):111 os.makedirs(directory)112 return directory113DEFAULT_APP_NAME = 'projecthamster'114DEFAULT_APPDIRS = HamsterAppDirs(DEFAULT_APP_NAME)115DEFAULT_CONFIG_FILENAME = '{}.conf'.format(DEFAULT_APPDIRS.appname)116def get_config_path(appdirs=DEFAULT_APPDIRS, file_name=DEFAULT_CONFIG_FILENAME):117 """118 Return the path where the config file is stored.119 Args:120 app_name (text_type, optional): Name of the application, defaults to121 ``'projecthamster``. Allows you to use your own application specific122 namespace if you wish....

Full Screen

Full Screen

directory_utility.py

Source:directory_utility.py Github

copy

Full Screen

...9 return prepare_directory("$dir_dist", project)10def prepare_directory(dir_variable, project):11 package__format = f"{dir_variable}/integration"12 reports_dir = project.expand_path(package__format)13 return _ensure_directory_exists(reports_dir)14def _ensure_directory_exists(path):15 if not os.path.exists(path):16 os.makedirs(path)17 return path18def get_working_distribution_directory(project):19 dist_directory = prepare_dist_directory(project)20 return _ensure_directory_exists(f"{dist_directory}/working")21def get_latest_distribution_directory(project):22 dist_directory = prepare_dist_directory(project)23 return _ensure_directory_exists(f"{dist_directory}/LATEST")24def get_latest_zipped_distribution_directory(project):25 dist_directory = prepare_dist_directory(project)26 return _ensure_directory_exists(f"{dist_directory}/LATEST/zipped")27def get_local_zip_artifact_path(tool, project, include_ending=False):28 artifact = f"{prepare_dist_directory(project)}/{tool}-{project.name}"29 if include_ending:30 return f"{artifact}.zip"31 return artifact32def package_artifacts(project, test_dir, tool, role):33 # Make a copy for easy access in environment validation34 working_dir = get_working_distribution_directory(project)35 shutil.copytree(test_dir, f"{working_dir}/{tool}",dirs_exist_ok=True)36 with tempfile.TemporaryDirectory() as tempdir:37 shutil.copytree(test_dir, f"{tempdir}/{role}",dirs_exist_ok=True)38 # package a copy for distribution39 # zip up the test and add them to the integration test dist directory40 base_name = get_local_zip_artifact_path(tool=tool, project=project)...

Full Screen

Full Screen

persist.py

Source:persist.py Github

copy

Full Screen

1import json2import os3def _ensure_directory_exists(directory_path):4 """Ensures the directories in directory_path exist."""5 if not os.path.exists(directory_path):6 os.makedirs(directory_path)7def _write_to_file(filepath, content):8 """writes content to a local file."""9 _ensure_directory_exists(os.path.dirname(filepath))10 open(filepath, 'wb').write(content)11class ContentSaver(object):12 """Saves recipe content to disk."""13 def __init__(self, root, write_file_fn=_write_to_file):14 self._root = root15 self._write_file_fn = write_file_fn16 def save_metadata(self, key, metadata):17 self._write_file_fn(18 self._output_path(key, 'metadata.json'),19 json.dumps(metadata, indent=4, separators=(',', ':')))20 def save_recipe_html(self, key, recipe_html):21 self._write_file_fn(self._output_path(key, 'index.html'), recipe_html)22 def _output_path(self, key, filename):23 return os.path.join(self._root, key, filename)

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