14
14
import re
15
15
from getpass import getpass
16
16
from ...utils .tap .core import TapPlus
17
- from ...query import BaseQuery
17
+ from ...query import BaseQuery , QueryWithLogin
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
24
23
import configparser
25
24
26
25
from astropy .io import fits
@@ -111,7 +110,7 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
111
110
# create url to access the aio
112
111
link = self ._create_link (observation_id , ** kwargs )
113
112
114
- # If the user wants to access proprietary data, ask them for there credentials
113
+ # If the user wants to access proprietary data, ask them for their credentials
115
114
if prop :
116
115
username , password = self ._get_username_and_password (credentials_file )
117
116
link = f"{ link } &AIOUSER={ username } &AIOPWD={ password } "
@@ -309,12 +308,13 @@ def _request_link(self, link, cache):
309
308
def _get_username_and_password (self , credentials_file ):
310
309
if credentials_file is not None :
311
310
self .configuration .read (credentials_file )
312
- username = self .configuration .get ('user' , ' username' )
313
- password = self .configuration .get ('user' , ' password' )
311
+ xmm_username = self .configuration .get ("xmm_newton" , " username" )
312
+ password = self .configuration .get ("xmm_newton" , " password" )
314
313
else :
315
- username = input ("Username: " )
316
- password = getpass ("Password: " )
317
- return username , password
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
318
318
319
319
def _create_filename (self , filename , observation_id , suffixes ):
320
320
if filename is not None :
@@ -615,9 +615,9 @@ def get_epic_metadata(self, *, target_name=None,
615
615
Tables containing the metadata of the target
616
616
"""
617
617
if not target_name and not coordinates :
618
- raise Exception ("Input parameters needed, "
619
- "please provide the name "
620
- "or the coordinates of the target" )
618
+ raise ValueError ("Input parameters needed, "
619
+ "please provide the name "
620
+ "or the coordinates of the target" )
621
621
622
622
epic_source = {"table" : "xsa.v_epic_source" ,
623
623
"column" : "epic_source_equatorial_spoint" }
@@ -635,7 +635,7 @@ def get_epic_metadata(self, *, target_name=None,
635
635
c = SkyCoord .from_name (target_name , parse = True )
636
636
637
637
if type (c ) is not SkyCoord :
638
- raise Exception ("The coordinates must be an "
638
+ raise TypeError ("The coordinates must be an "
639
639
"astroquery.coordinates.SkyCoord object" )
640
640
if not radius :
641
641
radius = 0.1
0 commit comments