Created
April 14, 2014 12:08
-
-
Save keflavich/10641894 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remotes/jwoillez/issue287$ python setup.py test --remote-data | |
| running test | |
| running build | |
| running build_py | |
| running egg_info | |
| writing requirements to astroquery.egg-info/requires.txt | |
| writing astroquery.egg-info/PKG-INFO | |
| writing top-level names to astroquery.egg-info/top_level.txt | |
| writing dependency_links to astroquery.egg-info/dependency_links.txt | |
| reading manifest file 'astroquery.egg-info/SOURCES.txt' | |
| reading manifest template 'MANIFEST.in' | |
| warning: no files found matching 'distribute_setup.py' | |
| warning: no files found matching '*.pyx' under directory 'astroquery' | |
| warning: no files found matching '*.c' under directory 'astroquery' | |
| warning: no previously-included files found matching '*.pyc' | |
| warning: no previously-included files found matching '*.o' | |
| no previously-included directories found matching 'docs/_build' | |
| no previously-included directories found matching 'build' | |
| writing manifest file 'astroquery.egg-info/SOURCES.txt' | |
| regenerating default astroquery.cfg file | |
| copying astroquery/astroquery.cfg -> build/lib.macosx-10.6-intel-2.7/astroquery | |
| ============================================================================= test session starts ============================================================================= | |
| platform darwin -- Python 2.7.6 -- pytest-2.5.1 | |
| Running tests with Astropy version 0.4.dev8035. | |
| Running tests in astroquery /Users/adam/repos/astroquery/docs. | |
| Platform: Darwin-13.1.0-x86_64-i386-64bit | |
| Executable: /Users/adam/virtual-python/bin/python | |
| Full Python Version: | |
| 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) | |
| [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] | |
| encodings: sys: ascii, locale: UTF-8, filesystem: utf-8, unicode bits: 15 | |
| byteorder: little | |
| float info: dig: 15, mant_dig: 15 | |
| Numpy: 1.9.0.dev-b69ee44 | |
| Scipy: 0.14.0.dev-5194d3e | |
| Matplotlib: 1.4.x | |
| h5py: not available | |
| Using Astropy options: remote_data. | |
| collected 443 items | |
| astroquery/alfalfa/tests/test_alfalfa.py ... | |
| astroquery/besancon/tests/test_besancon.py ... | |
| astroquery/eso/tests/test_eso_remote.py . | |
| astroquery/fermi/tests/test_fermi.py .... | |
| astroquery/gama/tests/test_gama.py .. | |
| astroquery/irsa/tests/test_irsa.py ............................. | |
| astroquery/irsa/tests/test_irsa_remote.py ...... | |
| astroquery/irsa_dust/tests/test_irsa_dust.py ............................................................... | |
| astroquery/irsa_dust/tests/test_irsa_dust_remote.py ........................................^@.. | |
| astroquery/lamda/tests/test_lamda.py .... | |
| astroquery/lamda/tests/test_lamda_remote.py ... | |
| astroquery/magpis/tests/test_magpis.py ...x | |
| astroquery/magpis/tests/test_magpis_remote.py .. | |
| astroquery/ned/tests/test_ned.py ....x..................... | |
| astroquery/ned/tests/test_ned_remote.py X................... | |
| astroquery/nist/tests/test_nist.py ... | |
| astroquery/nist/tests/test_nist_remote.py .. | |
| astroquery/nrao/tests/test_nrao.py .. | |
| astroquery/nrao/tests/test_nrao_remote.py .^@. | |
| astroquery/nvas/tests/test_nvas.py ........ | |
| astroquery/nvas/tests/test_nvas_remote.py .^@^@.. | |
| astroquery/ogle/tests/test_ogle.py ... | |
| astroquery/sdss/tests/test_sdss.py ............ | |
| astroquery/sdss/tests/test_sdss_remote.py ...^@^@^@........F | |
| astroquery/sha/tests/test_sha.py ..... | |
| astroquery/simbad/core.py .... | |
| astroquery/simbad/tests/test_simbad.py .................................................. | |
| astroquery/simbad/tests/test_simbad_remote.py ............. | |
| astroquery/splatalogue/tests/test_splatalogue.py .... | |
| astroquery/splatalogue/tests/test_utils.py ... | |
| astroquery/tests/test_internet.py . | |
| astroquery/ukidss/tests/test_ukidss.py ........... | |
| astroquery/ukidss/tests/test_ukidss_remote.py .^@^@F.... | |
| astroquery/utils/commons.py . | |
| astroquery/utils/tests/test_utils.py ..........................FF.. | |
| astroquery/vizier/tests/test_vizier.py ........................ | |
| astroquery/vizier/tests/test_vizier_remote.py ....... | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/api.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gallery.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/index.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/template.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/testing.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/alfalfa/alfalfa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/besancon/besancon.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/eso/eso.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/fermi/fermi.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/gama/gama.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/irsa/irsa_dust.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/lamda/lamda.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/magpis/magpis.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ned/ned.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nist/nist.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nrao/nrao.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/nvas/nvas.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ogle/ogle.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sdss/sdss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/sha/sha.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/simbad/simbad.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/splatalogue/splatalogue.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/ukidss/ukidss.rst . | |
| ../../../../../../../../Users/adam/repos/astroquery/docs/vizier/vizier.rst . | |
| ================================================================================== FAILURES =================================================================================== | |
| _____________________________________________________________________ TestSDSSRemote.test_images_timeout ______________________________________________________________________ | |
| self = <astroquery.sdss.tests.test_sdss_remote.TestSDSSRemote instance at 0x109d0f2d8> | |
| def test_images_timeout(self): | |
| xid = sdss.core.SDSS.query_region(self.coords) | |
| with pytest.raises(TimeoutError): | |
| > img = sdss.core.SDSS.get_images(matches=xid, timeout=self.mintimeout) | |
| E Failed: DID NOT RAISE | |
| astroquery/sdss/tests/test_sdss_remote.py:98: Failed | |
| ________________________________________________________________________ TestUkidss.test_get_images_2 _________________________________________________________________________ | |
| self = <astroquery.ukidss.tests.test_ukidss_remote.TestUkidss instance at 0x10a122368> | |
| def test_get_images_2(self): | |
| images = ukidss.core.Ukidss.get_images(coord.Galactic | |
| (l=49.489, b=-0.27, unit=(u.deg, u.deg)), | |
| > image_width=5 * u.arcmin) | |
| astroquery/ukidss/tests/test_ukidss_remote.py:26: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <astroquery.ukidss.core.UkidssClass object at 0x107e412d0>, coordinates = <Galactic l=49.48900 deg, b=-0.27000 deg>, waveband = 'all', frame_type = 'stack' | |
| image_width = <Quantity 5.0 arcmin>, image_height = None, radius = None, database = 'UKIDSSDR7PLUS', programme_id = 'all', verbose = True, get_query_payload = False | |
| def get_images(self, coordinates, waveband='all', frame_type='stack', | |
| image_width=1*u.arcmin, image_height=None, radius=None, | |
| database='UKIDSSDR7PLUS', programme_id='all', | |
| verbose=True, get_query_payload=False): | |
| """ | |
| Get an image around a target/ coordinates from UKIDSS catalog. | |
| Parameters | |
| ---------- | |
| coordinates : str or `astropy.coordinates` object | |
| The target around which to search. It may be specified as a string | |
| in which case it is resolved using online services or as the appropriate | |
| `astropy.coordinates` object. ICRS coordinates may also be entered as strings | |
| as specified in the `astropy.coordinates` module. | |
| waveband : str | |
| The color filter to download. Must be one of ['all','J','H','K','H2','Z','Y','Br']. | |
| frame_type : str | |
| The type of image. Must be one of | |
| ['stack','normal','interleave','deep_stack','confidence','difference', 'leavstack', 'all'] | |
| image_width : str or `astropy.units.Quantity` object, optional | |
| The image size (along X). Cannot exceed 15 arcmin. If missing, defaults to 1 arcmin. | |
| image_height : str or `astropy.units.Quantity` object, optional | |
| The image size (along Y). Cannot exceed 90 arcmin. If missing, same as image_width. | |
| radius : str or `astropy.units.Quantity` object, optional | |
| The string must be parsable by `astropy.coordinates.Angle`. The appropriate | |
| `Quantity` object from `astropy.units` may also be used. When missing only image | |
| around the given position rather than multi-frames are retrieved. | |
| programme_id : str | |
| The survey or programme in which to search for | |
| database : str | |
| The UKIDSS database to use | |
| verbose : bool | |
| Defaults to `True`. When `True` prints additional messages. | |
| get_query_payload : bool, optional | |
| if set to `True` then returns the dictionary sent as the HTTP request. | |
| Defaults to `False` | |
| Returns | |
| ------- | |
| A list of `astropy.fits.HDUList` objects | |
| """ | |
| readable_objs = self.get_images_async(coordinates, waveband=waveband, frame_type=frame_type, | |
| image_width=image_width, image_height=image_height, | |
| database=database, programme_id=programme_id, | |
| radius=radius, verbose=verbose, | |
| get_query_payload=get_query_payload) | |
| if get_query_payload: | |
| return readable_objs | |
| > return [obj.get_fits() for obj in readable_objs] | |
| astroquery/ukidss/core.py:198: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL http://surveys.roe.ac.uk/wsa/cgi-bin/getFImage.cgi?...826_3&xpos=747&ypos=747.1&band=H&ra=290.8256247&dec=14.56435 with ID 4463957904 | |
| def get_fits(self): | |
| """ | |
| Assuming the contained file is a FITS file, read it | |
| and return the file parsed as FITS HDUList | |
| """ | |
| > filedata = self.get_string() | |
| astroquery/utils/commons.py:369: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL http://surveys.roe.ac.uk/wsa/cgi-bin/getFImage.cgi?...826_3&xpos=747&ypos=747.1&band=H&ra=290.8256247&dec=14.56435 with ID 4463957904 | |
| def get_string(self): | |
| """ | |
| Download the file as a string | |
| """ | |
| if not hasattr(self,'_string'): | |
| try: | |
| with self._readable_object as f: | |
| data = f.read() | |
| self._string = data | |
| except URLError as e: | |
| if isinstance(e.reason, socket.timeout): | |
| raise TimeoutError("Query timed out, time elapsed {t}s". | |
| > format(t=self._timeout)) | |
| E TimeoutError: Query timed out, time elapsed 3.0s | |
| astroquery/utils/commons.py:428: TimeoutError | |
| ------------------------------------------------------------------------------- Captured stdout ------------------------------------------------------------------------------- | |
| Found 6 targets | |
| Downloading http://surveys.roe.ac.uk/wsa/cgi-bin/getFImage.cgi?file=/disk24/wsa/ingest/fits/20060603_v1/w20060603_01510_sf_st_two.fit&mfid=2514752&extNo=1&lx=415&hx=1907&ly=1091&hy=2584&rf=270&flip=1&uniq=5126_553_15_2826_1&xpos=747.1&ypos=747.7&band=J&ra=290.8256247&dec=14.56435 [Done] | |
| Downloading http://surveys.roe.ac.uk/wsa/cgi-bin/getFImage.cgi?file=/disk24/wsa/ingest/fits/20060603_v1/w20060603_01510_sf_st.fit&mfid=966724&extNo=1&lx=415&hx=1907&ly=1091&hy=2584&rf=270&flip=1&uniq=5126_553_15_2826_2&xpos=747&ypos=747.8&band=J&ra=290.8256247&dec=14.56435 [Done] | |
| ___________________________________________________________________________ test_filecontainer_save ___________________________________________________________________________ | |
| patch_getreadablefileobj = None | |
| def test_filecontainer_save(patch_getreadablefileobj): | |
| ffile = commons.FileContainer(fitsfilepath, encoding='binary') | |
| > ffile.save_fits('/tmp/test_emptyfile.fits') | |
| astroquery/utils/tests/test_utils.py:405: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h74000.../astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits with ID 4392898064 | |
| savepath = '/tmp/test_emptyfile.fits', link_cache = 'hard' | |
| def save_fits(self, savepath, link_cache='hard'): | |
| """ | |
| Save a FITS file to savepath | |
| Parameters | |
| ---------- | |
| savepath : str | |
| The full path to a FITS filename, e.g. "file.fits", or | |
| "/path/to/file.fits". | |
| link_cache : 'hard', 'sym', or False | |
| Try to create a hard or symbolic link to the astropy cached file? | |
| If the system is unable to create a hardlink, the file will be | |
| copied to the target location. | |
| """ | |
| from warnings import warn | |
| > self.get_fits() | |
| astroquery/utils/commons.py:391: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h74000.../astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits with ID 4392898064 | |
| def get_fits(self): | |
| """ | |
| Assuming the contained file is a FITS file, read it | |
| and return the file parsed as FITS HDUList | |
| """ | |
| > filedata = self.get_string() | |
| astroquery/utils/commons.py:369: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h74000.../astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits with ID 4392898064 | |
| def get_string(self): | |
| """ | |
| Download the file as a string | |
| """ | |
| if not hasattr(self,'_string'): | |
| try: | |
| > with self._readable_object as f: | |
| data = f.read() | |
| astroquery/utils/commons.py:422: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <contextlib.GeneratorContextManager object at 0x105d64e10> | |
| def __enter__(self): | |
| try: | |
| > return self.gen.next() | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py:17: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| name_or_obj = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| encoding = 'binary', cache = True, show_progress = True, remote_timeout = 3.0 | |
| @contextlib.contextmanager | |
| def get_readable_fileobj(name_or_obj, encoding=None, cache=False, | |
| show_progress=True, remote_timeout=None): | |
| """ | |
| Given a filename or a readable file-like object, return a context | |
| manager that yields a readable file-like object. | |
| This supports passing filenames, URLs, and readable file-like | |
| objects, any of which can be compressed in gzip or bzip2. | |
| Notes | |
| ----- | |
| This function is a context manager, and should be used for example | |
| as:: | |
| with get_readable_fileobj('file.dat') as f: | |
| contents = f.read() | |
| Parameters | |
| ---------- | |
| name_or_obj : str or file-like object | |
| The filename of the file to access (if given as a string), or | |
| the file-like object to access. | |
| If a file-like object, it must be opened in binary mode. | |
| encoding : str, optional | |
| When `None` (default), returns a file-like object with a | |
| `read` method that on Python 2.x returns `bytes` objects and | |
| on Python 3.x returns `str` (`unicode`) objects, using | |
| `locale.getpreferredencoding()` as an encoding. This matches | |
| the default behavior of the built-in `open` when no `mode` | |
| argument is provided. | |
| When `'binary'`, returns a file-like object where its `read` | |
| method returns `bytes` objects. | |
| When another string, it is the name of an encoding, and the | |
| file-like object's `read` method will return `str` (`unicode`) | |
| objects, decoded from binary using the given encoding. | |
| cache : bool, optional | |
| Whether to cache the contents of remote URLs. | |
| show_progress : bool, optional | |
| Whether to display a progress bar if the file is downloaded | |
| from a remote server. Default is `True`. | |
| remote_timeout : float | |
| Timeout for remote requests in seconds (default is the configurable | |
| REMOTE_TIMEOUT, which is 3s by default) | |
| Returns | |
| ------- | |
| file : readable file-like object | |
| """ | |
| # close_fds is a list of file handles created by this function | |
| # that need to be closed. We don't want to always just close the | |
| # returned file handle, because it may simply be the file handle | |
| # passed in. In that case it is not the responsibility of this | |
| # function to close it: doing so could result in a "double close" | |
| # and an "invalid file descriptor" exception. | |
| close_fds = [] | |
| delete_fds = [] | |
| if remote_timeout is None: | |
| # use configfile default | |
| remote_timeout = REMOTE_TIMEOUT() | |
| # Get a file object to the content | |
| if isinstance(name_or_obj, six.string_types): | |
| if _is_url(name_or_obj): | |
| name_or_obj = download_file( | |
| name_or_obj, cache=cache, show_progress=show_progress, | |
| > timeout=remote_timeout) | |
| /Users/adam/repos/astropy/astropy/utils/data.py:169: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| remote_url = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| cache = True, show_progress = True, timeout = 3.0 | |
| def download_file(remote_url, cache=False, show_progress=True, timeout=None): | |
| """ | |
| Accepts a URL, downloads and optionally caches the result | |
| returning the filename, with a name determined by the file's MD5 | |
| hash. If ``cache=True`` and the file is present in the cache, just | |
| returns the filename. | |
| Parameters | |
| ---------- | |
| remote_url : str | |
| The URL of the file to download | |
| cache : bool, optional | |
| Whether to use the cache | |
| show_progress : bool, optional | |
| Whether to display a progress bar during the download (default | |
| is `True`) | |
| timeout : float, optional | |
| Timeout for the requests in seconds (default is the configurable | |
| REMOTE_TIMEOUT, which is 3s by default) | |
| Returns | |
| ------- | |
| local_path : str | |
| Returns the local path that the file was download to. | |
| Raises | |
| ------ | |
| urllib2.URLError, urllib.error.URLError | |
| Whenever there's a problem getting the remote file. | |
| """ | |
| from ..utils.console import ProgressBarOrSpinner | |
| missing_cache = False | |
| if timeout is None: | |
| # use configfile default | |
| timeout = REMOTE_TIMEOUT() | |
| if cache: | |
| try: | |
| dldir, urlmapfn = _get_download_cache_locs() | |
| except (IOError, OSError) as e: | |
| msg = 'Remote data cache could not be accessed due to ' | |
| estr = '' if len(e.args) < 1 else (': ' + str(e)) | |
| warn(CacheMissingWarning(msg + e.__class__.__name__ + estr)) | |
| cache = False | |
| missing_cache = True # indicates that the cache is missing to raise a warning later | |
| try: | |
| if cache: | |
| # We don't need to acquire the lock here, since we are only reading | |
| with _open_shelve(urlmapfn, True) as url2hash: | |
| if str(remote_url) in url2hash: | |
| return url2hash[str(remote_url)] | |
| with contextlib.closing(urllib.request.urlopen( | |
| > remote_url, timeout=timeout)) as remote: | |
| #keep a hash to rename the local file to the hashed name | |
| hash = hashlib.md5() | |
| /Users/adam/repos/astropy/astropy/utils/data.py:905: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| url = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| data = None, timeout = 3.0 | |
| def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| global _opener | |
| if _opener is None: | |
| _opener = build_opener() | |
| > return _opener.open(url, data, timeout) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:127: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.OpenerDirector instance at 0x107ec4b00> | |
| fullurl = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| data = None, timeout = 3.0 | |
| def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| # accept a URL or a Request object | |
| if isinstance(fullurl, basestring): | |
| req = Request(fullurl, data) | |
| else: | |
| req = fullurl | |
| if data is not None: | |
| req.add_data(data) | |
| req.timeout = timeout | |
| > protocol = req.get_type() | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:396: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.Request instance at 0x107bcfbd8> | |
| def get_type(self): | |
| if self.type is None: | |
| self.type, self.__r_type = splittype(self.__original) | |
| if self.type is None: | |
| > raise ValueError, "unknown url type: %s" % self.__original | |
| E ValueError: unknown url type: /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:258: ValueError | |
| ___________________________________________________________________________ test_filecontainer_get ____________________________________________________________________________ | |
| patch_getreadablefileobj = None | |
| def test_filecontainer_get(patch_getreadablefileobj): | |
| ffile = commons.FileContainer(fitsfilepath, encoding='binary') | |
| > ff = ffile.get_fits() | |
| astroquery/utils/tests/test_utils.py:410: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h74000.../astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits with ID 4452202256 | |
| def get_fits(self): | |
| """ | |
| Assuming the contained file is a FITS file, read it | |
| and return the file parsed as FITS HDUList | |
| """ | |
| > filedata = self.get_string() | |
| astroquery/utils/commons.py:369: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = Downloaded object from URL /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h74000.../astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits with ID 4452202256 | |
| def get_string(self): | |
| """ | |
| Download the file as a string | |
| """ | |
| if not hasattr(self,'_string'): | |
| try: | |
| > with self._readable_object as f: | |
| data = f.read() | |
| astroquery/utils/commons.py:422: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <contextlib.GeneratorContextManager object at 0x1095f3710> | |
| def __enter__(self): | |
| try: | |
| > return self.gen.next() | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py:17: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| name_or_obj = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| encoding = 'binary', cache = True, show_progress = True, remote_timeout = 3.0 | |
| @contextlib.contextmanager | |
| def get_readable_fileobj(name_or_obj, encoding=None, cache=False, | |
| show_progress=True, remote_timeout=None): | |
| """ | |
| Given a filename or a readable file-like object, return a context | |
| manager that yields a readable file-like object. | |
| This supports passing filenames, URLs, and readable file-like | |
| objects, any of which can be compressed in gzip or bzip2. | |
| Notes | |
| ----- | |
| This function is a context manager, and should be used for example | |
| as:: | |
| with get_readable_fileobj('file.dat') as f: | |
| contents = f.read() | |
| Parameters | |
| ---------- | |
| name_or_obj : str or file-like object | |
| The filename of the file to access (if given as a string), or | |
| the file-like object to access. | |
| If a file-like object, it must be opened in binary mode. | |
| encoding : str, optional | |
| When `None` (default), returns a file-like object with a | |
| `read` method that on Python 2.x returns `bytes` objects and | |
| on Python 3.x returns `str` (`unicode`) objects, using | |
| `locale.getpreferredencoding()` as an encoding. This matches | |
| the default behavior of the built-in `open` when no `mode` | |
| argument is provided. | |
| When `'binary'`, returns a file-like object where its `read` | |
| method returns `bytes` objects. | |
| When another string, it is the name of an encoding, and the | |
| file-like object's `read` method will return `str` (`unicode`) | |
| objects, decoded from binary using the given encoding. | |
| cache : bool, optional | |
| Whether to cache the contents of remote URLs. | |
| show_progress : bool, optional | |
| Whether to display a progress bar if the file is downloaded | |
| from a remote server. Default is `True`. | |
| remote_timeout : float | |
| Timeout for remote requests in seconds (default is the configurable | |
| REMOTE_TIMEOUT, which is 3s by default) | |
| Returns | |
| ------- | |
| file : readable file-like object | |
| """ | |
| # close_fds is a list of file handles created by this function | |
| # that need to be closed. We don't want to always just close the | |
| # returned file handle, because it may simply be the file handle | |
| # passed in. In that case it is not the responsibility of this | |
| # function to close it: doing so could result in a "double close" | |
| # and an "invalid file descriptor" exception. | |
| close_fds = [] | |
| delete_fds = [] | |
| if remote_timeout is None: | |
| # use configfile default | |
| remote_timeout = REMOTE_TIMEOUT() | |
| # Get a file object to the content | |
| if isinstance(name_or_obj, six.string_types): | |
| if _is_url(name_or_obj): | |
| name_or_obj = download_file( | |
| name_or_obj, cache=cache, show_progress=show_progress, | |
| > timeout=remote_timeout) | |
| /Users/adam/repos/astropy/astropy/utils/data.py:169: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| remote_url = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| cache = True, show_progress = True, timeout = 3.0 | |
| def download_file(remote_url, cache=False, show_progress=True, timeout=None): | |
| """ | |
| Accepts a URL, downloads and optionally caches the result | |
| returning the filename, with a name determined by the file's MD5 | |
| hash. If ``cache=True`` and the file is present in the cache, just | |
| returns the filename. | |
| Parameters | |
| ---------- | |
| remote_url : str | |
| The URL of the file to download | |
| cache : bool, optional | |
| Whether to use the cache | |
| show_progress : bool, optional | |
| Whether to display a progress bar during the download (default | |
| is `True`) | |
| timeout : float, optional | |
| Timeout for the requests in seconds (default is the configurable | |
| REMOTE_TIMEOUT, which is 3s by default) | |
| Returns | |
| ------- | |
| local_path : str | |
| Returns the local path that the file was download to. | |
| Raises | |
| ------ | |
| urllib2.URLError, urllib.error.URLError | |
| Whenever there's a problem getting the remote file. | |
| """ | |
| from ..utils.console import ProgressBarOrSpinner | |
| missing_cache = False | |
| if timeout is None: | |
| # use configfile default | |
| timeout = REMOTE_TIMEOUT() | |
| if cache: | |
| try: | |
| dldir, urlmapfn = _get_download_cache_locs() | |
| except (IOError, OSError) as e: | |
| msg = 'Remote data cache could not be accessed due to ' | |
| estr = '' if len(e.args) < 1 else (': ' + str(e)) | |
| warn(CacheMissingWarning(msg + e.__class__.__name__ + estr)) | |
| cache = False | |
| missing_cache = True # indicates that the cache is missing to raise a warning later | |
| try: | |
| if cache: | |
| # We don't need to acquire the lock here, since we are only reading | |
| with _open_shelve(urlmapfn, True) as url2hash: | |
| if str(remote_url) in url2hash: | |
| return url2hash[str(remote_url)] | |
| with contextlib.closing(urllib.request.urlopen( | |
| > remote_url, timeout=timeout)) as remote: | |
| #keep a hash to rename the local file to the hashed name | |
| hash = hashlib.md5() | |
| /Users/adam/repos/astropy/astropy/utils/data.py:905: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| url = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| data = None, timeout = 3.0 | |
| def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| global _opener | |
| if _opener is None: | |
| _opener = build_opener() | |
| > return _opener.open(url, data, timeout) | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:127: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.OpenerDirector instance at 0x107ec4b00> | |
| fullurl = '/private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits' | |
| data = None, timeout = 3.0 | |
| def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
| # accept a URL or a Request object | |
| if isinstance(fullurl, basestring): | |
| req = Request(fullurl, data) | |
| else: | |
| req = fullurl | |
| if data is not None: | |
| req.add_data(data) | |
| req.timeout = timeout | |
| > protocol = req.get_type() | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:396: | |
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
| self = <urllib2.Request instance at 0x10946d680> | |
| def get_type(self): | |
| if self.type is None: | |
| self.type, self.__r_type = splittype(self.__original) | |
| if self.type is None: | |
| > raise ValueError, "unknown url type: %s" % self.__original | |
| E ValueError: unknown url type: /private/var/folders/_r/c4nkvmpn4vx6qc91qygz8h740000gr/T/astropy-test-CBRZbZ/lib.macosx-10.6-intel-2.7/astroquery/utils/tests/../../sdss/tests/data/emptyfile.fits | |
| /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py:258: ValueError | |
| ======================================================== 4 failed, 436 passed, 2 xfailed, 1 xpassed in 643.06 seconds ========================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment