def create(dir=utils.get_tempdir(), prefix='crmsh_'): ''' Create a temporary file and remove it at program exit. Returns (fd, filename) ''' fd, fname = mkstemp(dir=dir, prefix=prefix) add(fname) return fd, fname
def cib_shadow_dir(): if os.getenv("CIB_shadow_dir"): return os.getenv("CIB_shadow_dir") if is_crmuser(): return config.path.crm_config home = userdir.gethomedir(config.core.user) if home and home.startswith(os.path.sep): return os.path.join(home, ".cib") return get_tempdir()
def _generate_workdir_name(): ''' Generate a temporary folder name to use while running the script ''' # TODO: make use of /tmp configurable basefile = 'crm-tmp-%s-%s' % (time.time(), random.randint(0, 2**48)) basetmp = os.path.join(utils.get_tempdir(), basefile) return basetmp
def create_dir(dir=utils.get_tempdir(), prefix='crmsh_'): ret = mkdtemp(dir=dir, prefix=prefix) if len(_FILES) + len(_DIRS) == 0: atexit.register(_exit_handler) _DIRS.append(ret) return ret
def test_systeminfo(): assert utils.getuser() is not None assert utils.gethomedir() is not None assert utils.get_tempdir() is not None