forked from keflavich/brick_linesurvey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
retrieve_data.py
44 lines (42 loc) · 1.51 KB
/
retrieve_data.py
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
39
40
41
42
43
44
from astroquery.alma import Alma
import time
alma = Alma()
rslt = alma.query({'project_code': '2019.1.00092.S'}, public=False, cache=False)
print(rslt['Member ous id','QA2 Status'])
for mousid in rslt['Member ous id']:
#for mousid in ['uid://A001/X1465/X3a53']:
#for mousid in ['uid://A001/X1465/X3a57']:
print(mousid)
alma = Alma()
alma.cache_location='.'
alma.login('keflavich')
try:
stage = alma.stage_data(mousid)
except:
print(f"Staging mousid {mousid} failed")
try:
alma.download_files(stage['URL'])
except Exception as ex:
print(ex)
try:
print(f"trying w/API")
apifiles = [x.replace("dataPortal","dataPortal/api")
for x in stage['URL']]
print(apifiles)
alma.download_files(apifiles, savedir='.',
cache=True, continuation=True,
skip_unauthorized=False)
except Exception as ex:
raise(ex)
print(ex)
for try_number in range(5):
try:
print(f"trying w/sso: try number {try_number}")
alma.download_files([x.replace("dataPortal","dataPortal/sso")
for x in stage['URL']], savedir='.',
cache=True, continuation=True)
break
except Exception as ex:
print(ex)
time.sleep(1)
print()