Skip to content

Commit

Permalink
fixes to download()
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Nov 17, 2023
1 parent f0af18a commit fb1b0ec
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions tests/test_pipeline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pip install pygeodesic -U
pip install pygmsh -U
pip install pyacvd -U
pip install pymeshfix -U
pip install pymeshlab -U
pip install tetgen -U
pip install pyshtools -U
pip install trimesh -U
Expand All @@ -34,6 +35,7 @@ cd $VDIR/examples && time ./run_all.sh 2>&1 | tee $VLOGFILE

grep -aA 1 "Error" $VLOGFILE
grep -aA 3 "Trace" $VLOGFILE
grep -aA 3 "failure" $VLOGFILE
code $VLOGFILE #### inspect logfile
# (Try normal run too with visualization to make sure all is ok)

Expand Down
2 changes: 1 addition & 1 deletion vedo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def draw_scene(args):
args.color = "gold"
plt = applications.IsosurfaceBrowser(
vol, c=args.color, cmap=args.cmap,
precompute=False, progress=True, use_gpu=True,
precompute=False, use_gpu=True,
)
plt.show(zoom=args.zoom, viewup="z")
return
Expand Down
14 changes: 12 additions & 2 deletions vedo/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def _load_file(filename, unpack):
actor.file_size, actor.created = file_info(filename)
return actor


########################################################################
def download(url, to_local_file="", force=False, verbose=True):
"""
Expand All @@ -450,7 +451,8 @@ def download(url, to_local_file="", force=False, verbose=True):
The URL to download the file from.
to_local_file : (str)
The local file name to save the file to.
If not specified, the file name will be the same as the remote file name.
If not specified, the file name will be the same as the remote file name
in the directory specified by `settings.cache_directory + "/vedo"`.
force : (bool)
Force a new download even if the local file is up to date.
verbose : (bool)
Expand All @@ -466,6 +468,11 @@ def download(url, to_local_file="", force=False, verbose=True):
from datetime import datetime
import requests

url = url.replace("www.dropbox", "dl.dropbox")

if "github.com" in url:
url = url.replace("/blob/", "/raw/")

# Get the user's home directory
home_directory = os.path.expanduser("~")

Expand All @@ -477,7 +484,10 @@ def download(url, to_local_file="", force=False, verbose=True):
os.makedirs(cachedir)

if not to_local_file:
to_local_file = os.path.join(cachedir, os.path.basename(url))
basename = os.path.basename(url)
if "?" in basename:
basename = basename.split("?")[0]
to_local_file = os.path.join(cachedir, basename)
if verbose: print(f"Using local file name: {to_local_file}")

# Check if the local file exists and get its last modified time
Expand Down
22 changes: 10 additions & 12 deletions vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4177,12 +4177,11 @@ def _keypress(self, iren, event):
ob.add_scalarbar3d(title=arrnames[i])
self.add(ob.scalarbar)
else:
vedo.printc(f"Active pointdata array: '{arrnames[i]}'", c="g", bold=0)
vedo.printc(
f"Name:'{ob.name}'," if ob.name else '',
f"active pointdata array: '{arrnames[i]}'",
c="g", bold=False,
)
vedo.printc(
f"Name:'{ob.name}'," if ob.name else '',
f"active pointdata array: '{arrnames[i]}'",
c="g", bold=False,
)

elif key == "6": # cycle celldata array
ob = self.clicked_object
Expand Down Expand Up @@ -4230,12 +4229,11 @@ def _keypress(self, iren, event):
ob.add_scalarbar3d(title=arrnames[i])
self.add(ob.scalarbar)
else:
vedo.printc(f"Active celldata array: '{arrnames[i]}'", c="g", bold=0)
vedo.printc(
f"Name:'{ob.name}'," if ob.name else '',
f"active celldata array: '{arrnames[i]}'",
c="g", bold=False,
)
vedo.printc(
f"Name:'{ob.name}'," if ob.name else '',
f"active celldata array: '{arrnames[i]}'",
c="g", bold=False,
)

elif key == "7":
bgc = np.array(renderer.GetBackground()).sum() / 3
Expand Down

0 comments on commit fb1b0ec

Please sign in to comment.