def set_up_pyfakefs(test_self): """Helper to set up Pyfakefs.""" real_cwd = os.path.realpath(os.getcwd()) config_dir = os.path.realpath(environment.get_config_directory()) test_self.setUpPyfakefs() test_self.fs.add_real_directory(config_dir, lazy_read=False) os.chdir(real_cwd)
def __init__(self, root=None, *args, **kwargs): # pylint: disable=keyword-arg-before-vararg self._root = root.format(*args, **kwargs) if root is not None else None self._config_dir = environment.get_config_directory() self._cache = memoize.FifoInMemory(CACHE_SIZE) # Check that config directory is valid. if not self._config_dir or not os.path.exists(self._config_dir): raise errors.BadConfigError(self._config_dir) # Config roots should exist. if not _validate_root(self._config_dir, self._root): raise errors.BadConfigError(self._config_dir)
def run(): """Run custom platform specific init scripts.""" platform = environment.platform().lower() script_path = os.path.join(environment.get_config_directory(), SCRIPT_DIR, platform + _extension(platform)) if not os.path.exists(script_path): return os.chmod(script_path, 0o750) if script_path.endswith('.ps1'): cmd = 'powershell.exe ' + script_path else: cmd = script_path try: process_handler.run_process(cmd, timeout=1800, need_shell=True, testcase_run=False, ignore_children=True) except Exception: logs.log_error('Failed to execute platform initialization script.')
def set_up_pyfakefs(test_self): """Helper to set up Pyfakefs.""" test_self.setUpPyfakefs() test_self.fs.add_real_directory(environment.get_config_directory())