-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (33 loc) · 1.33 KB
/
Copy pathutils.py
File metadata and controls
38 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import shutil
import os
def download_file(local_filename, url):
result = True
print('Downloading the file:',local_filename,', please waint until it finishes.')
try:
with requests.get(url, stream=True) as r:
with open(local_filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)
except Exception as e:
print('Unable to download the SDNN model file. You must download the file manually from the url:', url)
print('Error from the download process is:', e)
result = False
return result
def download_model():
url ='https://web.njit.edu/~wangj/deepsuncode/SDNN/pretrained_model.h5'
filename = url.split('/')[-1]
if os.path.exists(filename):
print('File:',filename,'already exists, no need to download it')
else:
if download_file(filename,url):
print('Finished dowloading the file.')
def download_fits():
url ='https://web.njit.edu/~wangj/deepsuncode/SDNN/cals_170713_162012.fts'
filename = url.split('/')[-1]
filename = 'inputs' + os.sep + filename
if os.path.exists(filename):
print('File:',filename,'already exists, no need to download it')
else:
os.makedirs('inputs',exist_ok=True)
if download_file(filename,url):
print('Finished dowloading the file.')