Skip to content

Commit

Permalink
Revert "Revert "add verbose mode to delete_downloads()""
Browse files Browse the repository at this point in the history
This reverts commit 329f9ad.
  • Loading branch information
PProfizi committed Jul 20, 2023
1 parent dcc05a4 commit 0911428
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/ansys/dpf/core/examples/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
EXAMPLE_REPO = "https://github.com/ansys/example-data/raw/master/"


def delete_downloads():
def delete_downloads(verbose=True):
"""Delete all downloaded examples to free space or update the files"""
from ansys.dpf.core import LOCAL_DOWNLOADED_EXAMPLES_PATH, examples

Expand All @@ -34,7 +34,8 @@ def delete_downloads():
if not os.path.join(root, name) in not_to_remove:
try:
os.remove(os.path.join(root, name))
print(f"deleting {os.path.join(root, name)}")
if verbose:
print(f"deleting {os.path.join(root, name)}")
except Exception as e:
warnings.warn(
f"couldn't delete {os.path.join(root, name)} with error:\n {e.args}"
Expand All @@ -43,7 +44,8 @@ def delete_downloads():
if len(dirs) == 0 and len(files) == 0:
try:
os.rmdir(root)
print(f"deleting {root}")
if verbose:
print(f"deleting {root}")
except Exception as e:
warnings.warn(f"couldn't delete {root} with error:\n {e.args}")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_find_examples(example, server_type_remote_process):
def test_delete_downloaded_files():
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
assert os.path.exists(path)
examples.delete_downloads()
examples.delete_downloads(verbose=False)
assert not os.path.exists(path)
path = examples.download_multi_stage_cyclic_result(return_local_path=True)
assert os.path.exists(path)
Expand Down

0 comments on commit 0911428

Please sign in to comment.