def purge(): """Remove all build directories in the top-level stage path.""" root = get_stage_root() if os.path.isdir(root): for stage_dir in os.listdir(root): stage_path = os.path.join(root, stage_dir) remove_linked_tree(stage_path)
def remove_whatever_it_is(path): """Type-agnostic remove.""" if os.path.isfile(path): os.remove(path) elif os.path.islink(path): remove_linked_tree(path) else: shutil.rmtree(path)
def test_remove_linked_tree_doesnt_change_file_permission(tmpdir, initial_mode): # Here we test that a failed call to remove_linked_tree, due to passing a file # as an argument instead of a directory, doesn't leave the file with different # permissions as a side effect of trying to handle the error. file_instead_of_dir = tmpdir.ensure('foo') file_instead_of_dir.chmod(initial_mode) initial_stat = os.stat(str(file_instead_of_dir)) fs.remove_linked_tree(str(file_instead_of_dir)) final_stat = os.stat(str(file_instead_of_dir)) assert final_stat == initial_stat
def purge(): """Remove all build directories in the top-level stage path.""" root = get_stage_root() if os.path.isdir(root): for stage_dir in os.listdir(root): if stage_dir.startswith(stage_prefix) or stage_dir == '.lock': stage_path = os.path.join(root, stage_dir) if os.path.isdir(stage_path): remove_linked_tree(stage_path) else: os.remove(stage_path)
def purge(): """Remove all build directories in the top-level stage path.""" root = get_stage_root() if os.path.isdir(root): # TODO: Figure out a "standard" way to identify the hash length # TODO: Should this support alternate base represenations? dir_expr = re.compile(r'.*-[0-9a-f]{32}$') for stage_dir in os.listdir(root): if re.match(dir_expr, stage_dir) or stage_dir == '.lock': stage_path = os.path.join(root, stage_dir) remove_linked_tree(stage_path)
def destroy(self): """Removes this stage directory.""" remove_linked_tree(self.path) # Make sure we don't end up in a removed directory try: os.getcwd() except OSError: os.chdir(os.path.dirname(self.path)) # mark as destroyed self.created = False
def purge(): """Remove all build directories in the top-level stage path.""" if os.path.isdir(spack.stage_path): for stage_dir in os.listdir(spack.stage_path): stage_path = join_path(spack.stage_path, stage_dir) remove_linked_tree(stage_path)
def purge(): """Remove all build directories in the top-level stage path.""" if os.path.isdir(spack.paths.stage_path): for stage_dir in os.listdir(spack.paths.stage_path): stage_path = os.path.join(spack.paths.stage_path, stage_dir) remove_linked_tree(stage_path)