Skip to content

Commit 4a5a505

Browse files
committed
Merge branch 'master' of github.com:astropy/astroquery into vamdc
2 parents 6cb747a + e326f1a commit 4a5a505

File tree

9 files changed

+159
-100
lines changed

9 files changed

+159
-100
lines changed

.travis.yml

Lines changed: 73 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
language: python
1+
# We set the language to c because python isn't supported on the MacOS X nodes
2+
# on Travis. However, the language ends up being irrelevant anyway, since we
3+
# install Python ourselves using conda.
4+
language: c
5+
6+
os:
7+
- linux
28

39
# Setting sudo to false opts in to Travis-CI container-based builds.
410
sudo: false
@@ -12,98 +18,98 @@ addons:
1218
- texlive-latex-extra
1319
- dvipng
1420

15-
python:
16-
- 2.7
17-
- 3.4
18-
1921
env:
2022
global:
2123
# The following versions are the 'default' for tests, unless
2224
# overridden underneath. They are defined here in order to save having
2325
# to repeat them for all configurations.
26+
- PYTHON_VERSION=3.5
2427
- MAIN_CMD='python setup.py'
25-
- NUMPY_VERSION=1.10
28+
- NUMPY_VERSION=stable
2629
- ASTROPY_VERSION=stable
27-
- CONDA_DEPENDENCIES='requests beautiful-soup matplotlib html5lib'
28-
- PIP_DEPENDENCIES='keyring aplpy pyregion'
30+
- CONDA_DEPENDENCIES='requests beautifulsoup4 matplotlib html5lib keyring aplpy pyregion'
31+
- PIP_DEPENDENCIES=''
32+
- SETUP_CMD='test'
33+
- CONDA_CHANNELS='astropy-ci-extras astropy'
34+
- CONDA_DEPENDENCIES_OLD='requests beautiful-soup matplotlib html5lib'
35+
- PIP_DEPENDENCIES_OLD='pyregion aplpy keyring'
2936

3037
matrix:
31-
- SETUP_CMD='egg_info'
32-
33-
- SETUP_CMD='test'
38+
- PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
39+
- PYTHON_VERSION=3.3 SETUP_CMD='egg_info'
40+
- PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
41+
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
3442

3543
matrix:
36-
include:
3744

38-
# Test for py 3.5 (move this up to the main matrix once beautiful-soup is in conda)
39-
- python: 3.5
40-
env: SETUP_CMD='egg_info'
41-
- python: 3.5
45+
# Don't wait for allowed failures
46+
fast_finish: true
47+
48+
include:
49+
# Try MacOS X
50+
- os: osx
4251
env: SETUP_CMD='test'
43-
CONDA_DEPENDENCIES='requests matplotlib html5lib'
44-
PIP_DEPENDENCIES='keyring aplpy pyregion beautifulsoup4'
4552

46-
# Do a coverage test in Python 2.
47-
- python: 2.7
48-
env: SETUP_CMD='test --coverage'
53+
# Do a coverage test in Python 2. Move coverage to 3.x once speed
54+
# issues have been solved; astropy/astropy#4826
55+
- os: linux
56+
env: PYTHON_VERSION=2.7 SETUP_CMD='test --coverage'
4957

5058
# Check for sphinx doc build warnings - we do this first because it
5159
# may run for a long time
52-
- python: 2.7
53-
env: SETUP_CMD='build_sphinx -w'
54-
55-
# Python 3.3 doesn't have numpy 1.10 in conda, revoke this commit once
56-
# it's available in the astropy-ci-extras channel
57-
- python: 3.3
58-
env: SETUP_CMD='egg_info'
59-
- python: 3.3
60-
env: SETUP_CMD='test' NUMPY_VERSION=1.9
61-
62-
# Try Astropy development and LTS version
63-
- python: 2.7
64-
env: ASTROPY_VERSION=development SETUP_CMD='test'
65-
- python: 3.5
66-
env: ASTROPY_VERSION=development SETUP_CMD='test'
67-
CONDA_DEPENDENCIES='requests matplotlib html5lib'
68-
PIP_DEPENDENCIES='keyring aplpy pyregion beautifulsoup4'
69-
- python: 2.7
70-
env: ASTROPY_VERSION=lts SETUP_CMD='test'
71-
- python: 3.5
72-
env: ASTROPY_VERSION=lts SETUP_CMD='test'
73-
CONDA_DEPENDENCIES='requests matplotlib html5lib'
74-
PIP_DEPENDENCIES='keyring aplpy pyregion beautifulsoup4'
60+
- os: linux
61+
env: PYTHON_VERSION=2.7 SETUP_CMD='build_sphinx -w'
62+
63+
# Try all python versions and Numpy versions. Since we can assume that
64+
# the Numpy developers have taken care of testing Numpy with different
65+
# versions of Python, we can vary Python and Numpy versions at the same
66+
# time.
67+
- os: linux
68+
env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.7
69+
CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_OLD
70+
PIP_DEPENDENCIES=$PIP_DEPENDENCIES_OLD
71+
- os: linux
72+
env: PYTHON_VERSION=3.3 NUMPY_VERSION=1.8
73+
CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_OLD
74+
PIP_DEPENDENCIES=$PIP_DEPENDENCIES_OLD
75+
- os: linux
76+
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.9
77+
CONDA_DEPENDENCIES=$CONDA_DEPENDENCIES_OLD
78+
PIP_DEPENDENCIES=$PIP_DEPENDENCIES_OLD
79+
- os: linux
80+
env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.10
81+
82+
# Now try Astropy dev and LTS vesions with the latest 3.x and 2.7.
83+
- os: linux
84+
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=development
85+
- os: linux
86+
env: ASTROPY_VERSION=development
87+
- os: linux
88+
env: PYTHON_VERSION=2.7 ASTROPY_VERSION=lts
89+
- os: linux
90+
env: ASTROPY_VERSION=lts
7591

7692
# Try with optional dependencies disabled
77-
- python: 2.7
78-
env: SETUP_CMD='test'
79-
CONDA_DEPENDENCIES='requests beautiful-soup html5lib'
80-
PIP_DEPENDENCIES='keyring'
81-
- python: 3.5
82-
env: SETUP_CMD='test'
83-
CONDA_DEPENDENCIES='requests html5lib'
84-
PIP_DEPENDENCIES='keyring beautifulsoup4'
85-
86-
# Try older numpy versions
87-
- python: 2.7
88-
env: NUMPY_VERSION=1.9 SETUP_CMD='test'
89-
- python: 2.7
90-
env: NUMPY_VERSION=1.8 SETUP_CMD='test'
91-
- python: 2.7
92-
env: NUMPY_VERSION=1.7 SETUP_CMD='test'
93-
- python: 2.7
94-
env: NUMPY_VERSION=1.6 SETUP_CMD='test'
93+
- os: linux
94+
env: PYTHON_VERSION=2.7
95+
CONDA_DEPENDENCIES='requests beautifulsoup4 html5lib keyring'
96+
- os: linux
97+
env: CONDA_DEPENDENCIES='requests beautifulsoup4 html5lib keyring'
9598

9699
# Try numpy pre-release version, this runs only when a pre-release
97100
# is available on pypi.
98-
- python: 3.4
99-
env: NUMPY_VERSION=prerelease SETUP_CMD='test'
101+
- os: linux
102+
env: NUMPY_VERSION=prerelease DEBUG=True
100103

101104
# Do a PEP8 test with pycodestyle
102-
- python: 2.7
103-
env: MAIN_CMD='pycodestyle astroquery --count' SETUP_CMD=''
105+
- os: linux
106+
env: PYTHON_VERSION=2.7 MAIN_CMD='pycodestyle astroquery --count'
107+
SETUP_CMD=''
104108

105109
allow_failures:
106-
- env: MAIN_CMD='pycodestyle astroquery --count' SETUP_CMD=''
110+
- os: linux
111+
env: PYTHON_VERSION=2.7 MAIN_CMD='pycodestyle astroquery --count'
112+
SETUP_CMD=''
107113

108114
install:
109115
- git clone git://github.com/astropy/ci-helpers.git

appveyor.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# AppVeyor.com is a Continuous Integration service to build and run tests under
2+
# Windows
3+
4+
environment:
5+
6+
global:
7+
PYTHON: "C:\\conda"
8+
MINICONDA_VERSION: "latest"
9+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
10+
PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
11+
# of 32 bit and 64 bit builds are needed, move this
12+
# to the matrix section.
13+
CONDA_DEPENDENCIES: "requests beautifulsoup4 matplotlib html5lib keyring aplpy pyregion"
14+
15+
matrix:
16+
- PYTHON_VERSION: "2.7"
17+
ASTROPY_VERSION: "stable"
18+
NUMPY_VERSION: "stable"
19+
20+
- PYTHON_VERSION: "3.5"
21+
ASTROPY_VERSION: "stable"
22+
NUMPY_VERSION: "stable"
23+
24+
platform:
25+
-x64
26+
27+
install:
28+
- "git clone git://github.com/astropy/ci-helpers.git"
29+
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
30+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
31+
- "activate test"
32+
33+
# Not a .NET project, we build the package in the install step instead
34+
build: false
35+
36+
test_script:
37+
- "%CMD_IN_ENV% python setup.py test"

astroquery/alma/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from ..exceptions import (RemoteServiceError, TableParseError,
2727
InvalidQueryError, LoginError)
28-
from ..utils import commons, system_tools
28+
from ..utils import commons, system_tools, url_helpers
2929
from ..utils.process_asyncs import async_to_sync
3030
from ..query import QueryWithLogin
3131
from . import conf
@@ -262,7 +262,7 @@ def stage_data(self, uids):
262262

263263
# Submit a request for the specific request ID identified above
264264
submission_url = urljoin(self.dataarchive_url,
265-
os.path.join('rh/submission', request_id))
265+
url_helpers.join('rh/submission', request_id))
266266
log.debug("Submission URL: {0}".format(submission_url))
267267
self._staging_log['submission_url'] = submission_url
268268
staging_submission = self._request('GET', submission_url, cache=True)
@@ -282,8 +282,8 @@ def stage_data(self, uids):
282282
has_completed = False
283283
while not has_completed:
284284
time.sleep(1)
285-
summary = self._request('GET', os.path.join(data_page_url,
286-
'summary'),
285+
summary = self._request('GET', url_helpers.join(data_page_url,
286+
'summary'),
287287
cache=False)
288288
summary.raise_for_status()
289289
print(".", end='')

astroquery/gama/tests/test_gama.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def test_GAMA_find_result():
1919
with open(data_path(DATA_FILES["html_page"])) as f_html:
2020
result_page = f_html.read()
2121
url = gama.core.find_data_url(result_page)
22-
expected_url = os.path.join("../tmp", DATA_FILES["fits_data"])
23-
assert url == expected_url
22+
expected_url = os.path.join("..", "tmp", DATA_FILES["fits_data"])
23+
assert os.path.abspath(url) == os.path.abspath(expected_url)
2424

2525

2626
def test_GAMA_read_data():

astroquery/ibe/core.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import astropy.coordinates as coord
1717
from astropy.table import Table
18+
from astropy.extern import six
1819

1920
from ..exceptions import InvalidQueryError
2021
from ..query import BaseQuery
@@ -240,15 +241,16 @@ def query_region_async(
240241
args['where'] = where
241242

242243
if columns:
243-
if isinstance(columns, basestring):
244+
if isinstance(columns, six.string_types):
244245
columns = columns.split()
245246
args['columns'] = ','.join(columns)
246247

247-
url = os.path.join(
248-
self.URL, action,
249-
mission or self.MISSION,
250-
dataset or self.DATASET,
251-
table or self.TABLE)
248+
url = "{URL}{action}/{mission}/{dataset}/{table}".format(
249+
URL=self.URL,
250+
action=action,
251+
mission=mission or self.MISSION,
252+
dataset=dataset or self.DATASET,
253+
table=table or self.TABLE)
252254

253255
return self._request('GET', url, args, timeout=self.TIMEOUT)
254256

@@ -378,11 +380,11 @@ def show_docs(self, mission=None, dataset=None, table=None):
378380
The table to be queried (if not the default table).
379381
"""
380382

381-
url = os.path.join(
382-
self.URL, 'docs',
383-
mission or self.MISSION,
384-
dataset or self.DATASET,
385-
table or self.TABLE)
383+
url = "{URL}docs/{mission}/{dataset}/{table}".format(
384+
URL=self.URL,
385+
mission=mission or self.MISSION,
386+
dataset=dataset or self.DATASET,
387+
table=table or self.TABLE)
386388

387389
return webbrowser.open(url)
388390

@@ -405,11 +407,11 @@ def get_columns(self, mission=None, dataset=None, table=None):
405407
A table containing a description of the columns
406408
"""
407409

408-
url = os.path.join(
409-
self.URL, 'search',
410-
mission or self.MISSION,
411-
dataset or self.DATASET,
412-
table or self.TABLE)
410+
url = "{URL}search/{mission}/{dataset}/{table}".format(
411+
URL=self.URL,
412+
mission=mission or self.MISSION,
413+
dataset=dataset or self.DATASET,
414+
table=table or self.TABLE)
413415

414416
response = self._request(
415417
'GET', url, {'FORMAT': 'METADATA'}, timeout=self.TIMEOUT)

astroquery/sdss/tests/test_sdss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def test_query_crossid(patch_post, dr):
278278
xid = sdss.SDSS.query_crossid(coords_column, data_release=dr)
279279
data = Table.read(data_path(DATA_FILES['images_id']),
280280
format='ascii.csv', comment='#')
281-
assert all(xid == data)
281+
compare_xid_data(xid, data)
282282
url_tester_crossid(dr)
283283

284284

astroquery/utils/commons.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,13 @@ def save_fits(self, savepath, link_cache='hard'):
417417
if link_cache == 'hard':
418418
try:
419419
os.link(target, savepath)
420-
except (IOError, OSError) as e:
420+
except (IOError, OSError, AttributeError) as e:
421421
shutil.copy(target, savepath)
422422
elif link_cache == 'sym':
423-
os.symlink(target, savepath)
423+
try:
424+
os.symlink(target, savepath)
425+
except AttributeError:
426+
raise OSError('Creating symlinks is not possible on this OS.')
424427
else:
425428
shutil.copy(target, savepath)
426429

astroquery/utils/tests/test_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
from astropy.io import fits
1919
import astropy.utils.data as aud
20-
import astropy.version
2120
import tempfile
2221

2322

@@ -414,12 +413,8 @@ def test_filecontainer_save(patch_getreadablefileobj):
414413
ffile = commons.FileContainer(fitsfilepath, encoding='binary')
415414
temp_dir = tempfile.mkdtemp()
416415
empty_temp_file = temp_dir + os.sep + 'test_emptyfile.fits'
417-
try:
418-
ffile.save_fits(empty_temp_file)
419-
assert os.path.exists(empty_temp_file)
420-
finally:
421-
os.remove(empty_temp_file)
422-
os.rmdir(temp_dir)
416+
ffile.save_fits(empty_temp_file)
417+
assert os.path.exists(empty_temp_file)
423418

424419

425420
def test_filecontainer_get(patch_getreadablefileobj):

astroquery/utils/url_helpers.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ def urljoin_keep_path(url, path):
2727
splitted_url = urlsplit(url)
2828
return SplitResult(splitted_url.scheme,
2929
splitted_url.netloc,
30-
os.path.join(splitted_url.path, path),
30+
join(splitted_url.path, path),
3131
splitted_url.query,
3232
splitted_url.fragment).geturl()
33+
34+
35+
def join(a, *p):
36+
"""Taken from python posixpath."""
37+
sep = '/'
38+
path = a
39+
if not p:
40+
path[:0] + sep
41+
for b in p:
42+
if b.startswith(sep):
43+
path = b
44+
elif not path or path.endswith(sep):
45+
path += b
46+
else:
47+
path += sep + b
48+
return path

0 commit comments

Comments
 (0)