14
14
import re
15
15
from getpass import getpass
16
16
from ...utils .tap .core import TapPlus
17
- from ...query import BaseQuery , QueryWithLogin
17
+ from ...query import BaseQuery
18
18
import shutil
19
19
import cgi
20
20
from pathlib import Path
21
21
import tarfile
22
22
import os
23
+ from astroquery import log
23
24
import configparser
24
25
25
26
from astropy .io import fits
26
- from . import conf
27
+ from . import conf , config
27
28
from astroquery import log
28
29
from astropy .coordinates import SkyCoord
29
30
from ...exceptions import LoginError
@@ -42,7 +43,8 @@ def __init__(self, tap_handler=None):
42
43
self .configuration = configparser .ConfigParser ()
43
44
44
45
if tap_handler is None :
45
- self ._tap = TapPlus (url = "https://nxsa.esac.esa.int/tap-server/tap" )
46
+ self ._tap = TapPlus (url = "https://nxsa.esac.esa.int"
47
+ "/tap-server/tap" )
46
48
else :
47
49
self ._tap = tap_handler
48
50
self ._rmf_ftp = str ("http://sasdev-xmm.esac.esa.int/pub/ccf/constituents/extras/responses/" )
@@ -101,16 +103,23 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
101
103
file format, optional, by default all formats
102
104
values: ASC, ASZ, FTZ, HTM, IND, PDF, PNG
103
105
106
+
104
107
Returns
105
108
-------
106
109
None if not verbose. It downloads the observation indicated
107
110
If verbose returns the filename
108
111
"""
112
+ """
113
+ Here we change the log level so that it is above 20, this is to stop a log.debug in query.py. this debug
114
+ reveals the url being sent which in turn reveals the users username and password
115
+ """
116
+ previouslevel = log .getEffectiveLevel ()
117
+ log .setLevel (21 )
109
118
110
119
# create url to access the aio
111
120
link = self ._create_link (observation_id , ** kwargs )
112
121
113
- # If the user wants to access proprietary data, ask them for their credentials
122
+ # If the user wants to access proprietary data, ask them for there credentials
114
123
if prop :
115
124
username , password = self ._get_username_and_password (credentials_file )
116
125
link = f"{ link } &AIOUSER={ username } &AIOPWD={ password } "
@@ -122,23 +131,16 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
122
131
params = self ._request_link (link , cache )
123
132
r_filename = params ["filename" ]
124
133
suffixes = Path (r_filename ).suffixes
134
+ print (suffixes )
125
135
126
136
# get desired filename
127
137
filename = self ._create_filename (filename , observation_id , suffixes )
128
- """
129
- If prop we change the log level so that it is above 20, this is to stop a log.debug (line 431) in query.py.
130
- This debug reveals the url being sent which in turn reveals the users username and password
131
- """
132
- if prop :
133
- previouslevel = log .getEffectiveLevel ()
134
- log .setLevel (21 )
135
- self ._download_file (link , filename , head_safe = True , cache = cache )
136
- log .setLevel (previouslevel )
137
- else :
138
- self ._download_file (link , filename , head_safe = True , cache = cache )
138
+
139
+ self ._download_file (link , filename , head_safe = True , cache = cache )
139
140
140
141
if verbose :
141
142
log .info (f"Wrote { link } to { filename } " )
143
+ log .setLevel (previouslevel )
142
144
143
145
def get_postcard (self , observation_id , * , image_type = "OBS_EPIC" ,
144
146
filename = None , verbose = False ):
@@ -306,15 +308,14 @@ def _request_link(self, link, cache):
306
308
return params
307
309
308
310
def _get_username_and_password (self , credentials_file ):
309
- if credentials_file is not None :
311
+ if credentials_file != None :
310
312
self .configuration .read (credentials_file )
311
- xmm_username = self .configuration .get ("xmm_newton" , " username" )
312
- password = self .configuration .get ("xmm_newton" , " password" )
313
+ username = self .configuration .get ('user' , ' username' )
314
+ password = self .configuration .get ('user' , ' password' )
313
315
else :
314
- xmm_username = input ("Username: " )
315
- password , password_from_keyring = QueryWithLogin ._get_password (self , service_name = "xmm_newton" ,
316
- username = xmm_username , reenter = False )
317
- return xmm_username , password
316
+ username = input ("Username: " )
317
+ password = getpass ("Password: " )
318
+ return username , password
318
319
319
320
def _create_filename (self , filename , observation_id , suffixes ):
320
321
if filename is not None :
@@ -615,9 +616,9 @@ def get_epic_metadata(self, *, target_name=None,
615
616
Tables containing the metadata of the target
616
617
"""
617
618
if not target_name and not coordinates :
618
- raise ValueError ("Input parameters needed, "
619
- "please provide the name "
620
- "or the coordinates of the target" )
619
+ raise Exception ("Input parameters needed, "
620
+ "please provide the name "
621
+ "or the coordinates of the target" )
621
622
622
623
epic_source = {"table" : "xsa.v_epic_source" ,
623
624
"column" : "epic_source_equatorial_spoint" }
@@ -635,7 +636,7 @@ def get_epic_metadata(self, *, target_name=None,
635
636
c = SkyCoord .from_name (target_name , parse = True )
636
637
637
638
if type (c ) is not SkyCoord :
638
- raise TypeError ("The coordinates must be an "
639
+ raise Exception ("The coordinates must be an "
639
640
"astroquery.coordinates.SkyCoord object" )
640
641
if not radius :
641
642
radius = 0.1
0 commit comments