chore: remove dir before extract
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import json
|
import json
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -38,9 +39,12 @@ def download_and_unpack(url: str) -> str:
|
|||||||
print(f"File '{file_name}' already exists. Skipping download.")
|
print(f"File '{file_name}' already exists. Skipping download.")
|
||||||
else:
|
else:
|
||||||
subprocess.call(["wget", url])
|
subprocess.call(["wget", url])
|
||||||
|
file_name_without_ext = file_name.rsplit(".", 2)[0] # Remove .tar.gz
|
||||||
|
shutil.rmtree(
|
||||||
|
file_name_without_ext, ignore_errors=True
|
||||||
|
) # Remove existing dir if exists
|
||||||
print("Unpacking...")
|
print("Unpacking...")
|
||||||
subprocess.call(["tar", "zxvf", file_name])
|
subprocess.call(["tar", "zxvf", file_name])
|
||||||
file_name_without_ext = file_name.rsplit(".", 2)[0] # Remove .tar.gz
|
|
||||||
print(f"Download and unpack complete: {file_name} to {file_name_without_ext}")
|
print(f"Download and unpack complete: {file_name} to {file_name_without_ext}")
|
||||||
return file_name_without_ext
|
return file_name_without_ext
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user