Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit 90501ff6 authored by Qusai Al Shidi's avatar Qusai Al Shidi 💬
Browse files

Merge branch 'zhenguang-web-patch' into 'master'

@qalshidi commiting for @zghuang

See merge request !6
parents 3b8c6b89 ffe49527
Pipeline #24246 passed with stage
in 1 minute and 10 seconds
......@@ -13,6 +13,7 @@ import ftplib
from functools import lru_cache
import gzip
from operator import itemgetter
import os.path
import shutil
import urllib
import urllib.request
......@@ -476,18 +477,23 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
raise FileNotFoundError('Could not find a file that matches'
+ 'the pattern.')
directory = kwargs.get('download_dir', './')
if directory[-1] != '/':
directory += '/'
for filename in filenames:
# open the file locally
directory = kwargs.get('download_dir', './')
if directory[-1] != '/':
directory += '/'
with open(directory + filename, 'wb') as fhandle:
# try to download the magnetogram
try:
ftp.retrbinary('RETR ' + filename, fhandle.write)
except ftplib.all_errors:
ftp.quit()
raise FileNotFoundError('Cannot download ', filename)
# Only try to download if the file does not exist
if os.path.isfile(directory+filename) == True:
raise RuntimeWarning(f'{filename} exists, not downloading')
else:
# open the file locally
with open(directory + filename, 'wb') as fhandle:
# try to download the magnetogram
try:
ftp.retrbinary('RETR ' + filename, fhandle.write)
except ftplib.all_errors:
ftp.quit()
raise FileNotFoundError('Cannot download ', filename)
# unzip the file
if '.gz' in filename:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment