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 ...@@ -13,6 +13,7 @@ import ftplib
from functools import lru_cache from functools import lru_cache
import gzip import gzip
from operator import itemgetter from operator import itemgetter
import os.path
import shutil import shutil
import urllib import urllib
import urllib.request import urllib.request
...@@ -476,18 +477,23 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs): ...@@ -476,18 +477,23 @@ def download_magnetogram_adapt(time, map_type='fixed', **kwargs):
raise FileNotFoundError('Could not find a file that matches' raise FileNotFoundError('Could not find a file that matches'
+ 'the pattern.') + 'the pattern.')
directory = kwargs.get('download_dir', './')
if directory[-1] != '/':
directory += '/'
for filename in filenames: for filename in filenames:
# open the file locally # Only try to download if the file does not exist
directory = kwargs.get('download_dir', './') if os.path.isfile(directory+filename) == True:
if directory[-1] != '/': raise RuntimeWarning(f'{filename} exists, not downloading')
directory += '/' else:
with open(directory + filename, 'wb') as fhandle: # open the file locally
# try to download the magnetogram with open(directory + filename, 'wb') as fhandle:
try: # try to download the magnetogram
ftp.retrbinary('RETR ' + filename, fhandle.write) try:
except ftplib.all_errors: ftp.retrbinary('RETR ' + filename, fhandle.write)
ftp.quit() except ftplib.all_errors:
raise FileNotFoundError('Cannot download ', filename) ftp.quit()
raise FileNotFoundError('Cannot download ', filename)
# unzip the file # unzip the file
if '.gz' in filename: 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