def _getheader(uri): """ Internal method for accessing the storage system. Given the vospace URI for fits file get the header of the file. """ #'https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/data/pub/vospace/OSSOS/dbimages/1616100/ccd00/1616100p00.psf.fits' DATA_URL="https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/data/pub/vospace/" url = DATA_URL+urlparse(uri).path payload = {'fhead': 'true'} r = requests.get(url, params=payload, cert=CERTFILE) if r.status_code != 200: logger.error("{}".format(r.status_code)) logger.error(r.content) return None str_header = r.content.split('\n') headers = [] fobj = cStringIO.StringIO() for line in str_header: if "END" not in line[0:4]: fobj.write(line + "\n") continue fobj.seek(0) header = fits.header.Header.fromfile(fobj, sep='\n', endcard=False, padding=False) headers.append(header) fobj.close() fobj = cStringIO.StringIO() # check if there are lines left in fobj and try to make a header from those. fobj.seek(0,2) if fobj.tell() > 0: fobj.seek(0) header = fits.header.Header.fromfile(fobj, sep='\n', endcard=False, padding=False) headers.append(header) fobj.close() return headers
def test_urlparse(self): parts = vos.urlparse("http://www.test.com/path") assert_that(parts.scheme, equal_to("http")) assert_that(parts.netloc, equal_to("www.test.com")) assert_that(parts.path, equal_to("/path"))
def test_urlparse_multi_depth_path(self): parts = vos.urlparse("http://cadc.nrc.ca!vospace/multi/depth/path.ext") assert_that(parts.scheme, equal_to("http")) assert_that(parts.netloc, equal_to("cadc.nrc.ca!vospace")) assert_that(parts.path, equal_to("/multi/depth/path.ext"))
def test_urlparse_naming_authority(self): parts = vos.urlparse("https://cadc.nrc.ca!vospace/path") assert_that(parts.scheme, equal_to("https")) assert_that(parts.netloc, equal_to("cadc.nrc.ca!vospace")) assert_that(parts.path, equal_to("/path"))