Skip to content

Commit

Permalink
Merge pull request #1063 from nickssl/master
Browse files Browse the repository at this point in the history
Fixed captive portal bug.
  • Loading branch information
nickssl authored Dec 2, 2024
2 parents d74fde2 + b568d2d commit 9fc9762
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyspedas/projects/themis/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

CONFIG = {'local_data_dir': 'themis_data/',
'remote_data_dir': 'http://themis.ssl.berkeley.edu/data/themis/'}
'remote_data_dir': 'https://themis.ssl.berkeley.edu/data/themis/'}

# override local data directory with environment variables
if os.environ.get('SPEDAS_DATA_DIR'):
Expand Down
14 changes: 10 additions & 4 deletions pyspedas/utilities/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def download_file(
return None

if needs_to_download_file:
ftmp = NamedTemporaryFile(delete=False)
froot, fsuffix = os.path.splitext(filename)
ftmp = NamedTemporaryFile(delete=False, suffix=fsuffix)

with open(ftmp.name, "wb") as f:
if text_only:
Expand All @@ -241,13 +242,18 @@ def download_file(
os.makedirs(os.path.dirname(filename))

# if the download was successful, copy to data directory
copy(ftmp.name, filename)
if check_downloaded_file(ftmp.name):
copy(ftmp.name, filename)
logging.info("Download complete: " + filename)
else:
logging.error("Download of '" + filename + "' failed. The temp file will be removed.")
logging.error("If the same file has been already downloaded previously, it might be possible to use that instead.")

# cleanup
fsrc.close()
ftmp.close()
os.unlink(ftmp.name) # delete the temporary file

logging.info("Download complete: " + filename)


# At this point, we check if the file can be opened.
# If it cannot be opened, we delete the file and try again.
Expand Down

0 comments on commit 9fc9762

Please sign in to comment.