Skip to content

Commit b66f849

Browse files
committed
merge conflicts
1 parent 76d43ff commit b66f849

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

astroquery/esa/xmm_newton/core.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
import re
1515
from getpass import getpass
1616
from ...utils.tap.core import TapPlus
17-
from ...query import BaseQuery, QueryWithLogin
17+
from ...query import BaseQuery
1818
import shutil
1919
import cgi
2020
from pathlib import Path
2121
import tarfile
2222
import os
23+
from astroquery import log
2324
import configparser
2425

2526
from astropy.io import fits
26-
from . import conf
27+
from . import conf, config
2728
from astroquery import log
2829
from astropy.coordinates import SkyCoord
2930
from ...exceptions import LoginError
@@ -42,7 +43,8 @@ def __init__(self, tap_handler=None):
4243
self.configuration = configparser.ConfigParser()
4344

4445
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")
4648
else:
4749
self._tap = tap_handler
4850
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,
101103
file format, optional, by default all formats
102104
values: ASC, ASZ, FTZ, HTM, IND, PDF, PNG
103105
106+
104107
Returns
105108
-------
106109
None if not verbose. It downloads the observation indicated
107110
If verbose returns the filename
108111
"""
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)
109118

110119
# create url to access the aio
111120
link = self._create_link(observation_id, **kwargs)
112121

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
114123
if prop:
115124
username, password = self._get_username_and_password(credentials_file)
116125
link = f"{link}&AIOUSER={username}&AIOPWD={password}"
@@ -122,23 +131,16 @@ def download_data(self, observation_id, *, filename=None, verbose=False,
122131
params = self._request_link(link, cache)
123132
r_filename = params["filename"]
124133
suffixes = Path(r_filename).suffixes
134+
print(suffixes)
125135

126136
# get desired filename
127137
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)
139140

140141
if verbose:
141142
log.info(f"Wrote {link} to {filename}")
143+
log.setLevel(previouslevel)
142144

143145
def get_postcard(self, observation_id, *, image_type="OBS_EPIC",
144146
filename=None, verbose=False):
@@ -306,15 +308,14 @@ def _request_link(self, link, cache):
306308
return params
307309

308310
def _get_username_and_password(self, credentials_file):
309-
if credentials_file is not None:
311+
if credentials_file != None:
310312
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')
313315
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
318319

319320
def _create_filename(self, filename, observation_id, suffixes):
320321
if filename is not None:
@@ -615,9 +616,9 @@ def get_epic_metadata(self, *, target_name=None,
615616
Tables containing the metadata of the target
616617
"""
617618
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")
621622

622623
epic_source = {"table": "xsa.v_epic_source",
623624
"column": "epic_source_equatorial_spoint"}
@@ -635,7 +636,7 @@ def get_epic_metadata(self, *, target_name=None,
635636
c = SkyCoord.from_name(target_name, parse=True)
636637

637638
if type(c) is not SkyCoord:
638-
raise TypeError("The coordinates must be an "
639+
raise Exception("The coordinates must be an "
639640
"astroquery.coordinates.SkyCoord object")
640641
if not radius:
641642
radius = 0.1

0 commit comments

Comments
 (0)