Skip to content

Commit

Permalink
Fix copy folder error (#65)
Browse files Browse the repository at this point in the history
* Fix copy folder error

* Fix linux musl issue
  • Loading branch information
giswqs committed May 24, 2024
1 parent f8cc2e6 commit d895a9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions whitebox/download_wbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def safe_extract(
if verbose:
print("WhiteboxTools package directory: {}".format(pkg_dir))

zip_dir = zip_name.split(".")[0]
zip_dir = os.path.join(
pkg_dir, os.path.basename(zip_name).replace(".zip", "")
).replace("musl", "amd64")
src_dir = os.path.join(zip_dir, "WBT")

if os.path.exists(src_dir):
Expand All @@ -139,12 +141,14 @@ def safe_extract(
if os.path.exists(new_plugin_dir):
shutil.rmtree(new_plugin_dir)

if os.path.exists(zip_dir):
shutil.rmtree(zip_dir)
if os.path.exists(new_img_dir):
shutil.copytree(init_img_dir, new_img_dir)

shutil.copytree(init_img_dir, new_img_dir)
shutil.copytree(init_plugin_dir, new_plugin_dir)
if os.path.exists(new_plugin_dir):
shutil.copytree(init_plugin_dir, new_plugin_dir)

if os.path.exists(zip_dir):
shutil.rmtree(zip_dir)
exe_ext = "" # file extension for MacOS/Linux
if platform.system() == "Windows":
exe_ext = ".exe"
Expand Down
14 changes: 9 additions & 5 deletions whitebox/whitebox_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ def safe_extract(
if verbose:
print("WhiteboxTools package directory: {}".format(pkg_dir))

zip_dir = zip_name.split(".")[0]
zip_dir = os.path.join(
pkg_dir, os.path.basename(zip_name).replace(".zip", "")
).replace("musl", "amd64")
src_dir = os.path.join(zip_dir, "WBT")

if os.path.exists(src_dir):
Expand All @@ -168,12 +170,14 @@ def safe_extract(
if os.path.exists(new_plugin_dir):
shutil.rmtree(new_plugin_dir)

if os.path.exists(zip_dir):
shutil.rmtree(zip_dir)
if os.path.exists(new_img_dir):
shutil.copytree(init_img_dir, new_img_dir)

shutil.copytree(init_img_dir, new_img_dir)
shutil.copytree(init_plugin_dir, new_plugin_dir)
if os.path.exists(new_plugin_dir):
shutil.copytree(init_plugin_dir, new_plugin_dir)

if os.path.exists(zip_dir):
shutil.rmtree(zip_dir)
exe_ext = "" # file extension for MacOS/Linux
if platform.system() == "Windows":
exe_ext = ".exe"
Expand Down

0 comments on commit d895a9a

Please sign in to comment.