def __init__(self, suffix='', prefix='tmp', dir=None, delete = None, delete_on_error = None, *args, **kw): super(TempDir, self).__init__(*args, **kw) self.__name = _mkdtemp(suffix, prefix, dir) if delete is not None: self.delete = delete if delete_on_error is not None: self.delete_on_error = delete_on_error
def new_dir(cls, path=None, dir=None, prefix=None, suffix=None): if path is None: cls.make_dir(dir) lazy_dir = cls(_mkdtemp(dir=dir, prefix=prefix, suffix=suffix)) elif _ispathlike(path): lazy_dir = cls(path) lazy_dir.mkdir() else: raise TypeError("'path 'argument should be a None, path or str object, not '%s'" % type(path).__name__) return lazy_dir.resolve()
def _load_remote(cls, path, schema_version, aws_credentials={}): temp_dir = _mkdtemp(prefix='predictive_policy_') if _file_util.is_s3_path(path): _file_util.download_from_s3(path, temp_dir, is_dir=True, aws_credentials=aws_credentials, silent=True) elif _file_util.is_hdfs_path(path): _file_util.download_from_hdfs(path, temp_dir, is_dir=True) else: assert 'Only support S3 and HDFS path for Predictive Object saving location!' return cls._load_local(temp_dir)
def _tmp_dir(self): """ Current client temporary directory. Returns: str: Current temporary directory path. """ try: return self._cache['tmp_dir'] except KeyError: self._cache['tmp_dir'] = _mkdtemp(dir=_cfg.ACCELERATOR_TMP_ROOT) return self._cache['tmp_dir']
def _save_remote(self, path, aws_credentials): tempdir = _mkdtemp(prefix='predictive_policy_') try: self._save_local(tempdir) if _file_util.is_s3_path(path): _file_util.upload_to_s3(tempdir, path, is_dir=True, \ aws_credentials = aws_credentials) elif _file_util.is_hdfs_path(path): _file_util.hdfs_mkdir(path) _file_util.upload_to_hdfs(tempdir + '/*', path) finally: _shutil.rmtree(tempdir)
def __init__(self, suffix='', prefix='tmp', dir=None, delete=None, delete_on_error=None, *args, **kw): super(TempDir, self).__init__(*args, **kw) self.__name = _mkdtemp(suffix, prefix, dir) if delete is not None: self.delete = delete if delete_on_error is not None: self.delete_on_error = delete_on_error
def mk_tmp_dir(suffix: str = None, prefix: str = None, subdir: str = None) -> str: from pytsite import reg tmp_root = reg.get('paths.tmp') if not tmp_root: raise RuntimeError('Cannot determine temporary directory location') if subdir: tmp_root = _path.join(tmp_root, subdir) if not _path.exists(tmp_root): _makedirs(tmp_root, 0o755) return _mkdtemp(suffix, prefix, tmp_root)
rectangle_corner_anti_aliasing = 0 # Picture picture_position = (0, 0) # Video video_position = [0, 0] video_backend = "mediadecoder" # 'mediadecoder' or 'pygame' # Tone tone_frequency = 440 tone_samplerate = 44100 tone_bitdepth = 16 tone_amplitude = 0.5 # Create tmp for compressed stimuli folder try: tempdir = _mkdtemp(prefix="expyriment_") except: tempdir = None pass def _remove_tempdir(): global tempdir try: _rmtree(tempdir) except: pass _atexit.register(_remove_tempdir)
def _create_rootdir(self): path = _mkdtemp(prefix='ldaptest-slapd-') _os.mkdir(_os.path.join(path, 'db')) _os.mkdir(_os.path.join(path, 'slapd.d')) return path
def __init__(self, dir=None, prefix=None, suffix=None): self.__PATH__.make_dir(dir) super().__init__(_mkdtemp(dir=dir, prefix=prefix, suffix=suffix))