Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed captive portal bug. #1063

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading