示例#1
0
文件: query.py 项目: pllim/pyvo
    def execute_votable(self, post=False):
        """
        Submit the query and return the results as an AstroPy votable instance.
        As this is the level where qualified error messages are available,
        they are raised here instead of in the underlying execute_stream.

        Returns
        -------
        astropy.io.votable.tree.Table
           an Astropy votable Table instance

        Raises
        ------
        DALServiceError
           for errors connecting to or communicating with the service
        DALFormatError
           for errors parsing the VOTable response

        See Also
        --------
        astropy.io.votable
        DALServiceError
        DALFormatError
        DALQueryError
        """
        try:
            return votableparse(self.execute_stream(post=post).read)
        except Exception as e:
            self.raise_if_error()
            raise DALFormatError(e, self.queryurl)
示例#2
0
 def from_result_url(cls, result_url):
     """
     Create a result object from a url.
     """
     return cls(
         votableparse(cls._from_result_url(result_url).read),
         url=result_url)
示例#3
0
文件: query.py 项目: pyvirtobs/pyvo
 def from_result_url(cls, result_url):
     """
     Create a result object from a url.
     """
     return cls(
         votableparse(cls._from_result_url(result_url).read),
         url=result_url)
示例#4
0
文件: query.py 项目: pyvirtobs/pyvo
    def execute_votable(self):
        """
        Submit the query and return the results as an AstroPy votable instance.
        As this is the level where qualified error messages are available,
        they are raised here instead of in the underlying execute_stream.

        Returns
        -------
        astropy.io.votable.tree.Table
           an Astropy votable Table instance

        Raises
        ------
        DALServiceError
           for errors connecting to or communicating with the service
        DALFormatError
           for errors parsing the VOTable response

        See Also
        --------
        astropy.io.votable
        DALServiceError
        DALFormatError
        DALQueryError
        """
        try:
            return votableparse(self.execute_stream().read)
        except Exception as e:
            self.raise_if_error()
            raise DALFormatError(e, self.queryurl)
示例#5
0
    def fetch_result(self):
        """
        returns the result votable if query is finished
        """
        response = self.get_result_response()

        response.raw.read = partial(
            response.raw.read, decode_content=True)
        return TAPResults(votableparse(response.raw.read), url=self.result_uri, session=self._session)
示例#6
0
文件: query.py 项目: pllim/pyvo
    def from_result_url(cls, result_url, session=None):
        """
        Create a result object from a url.

        Uses the optional session to make the request.
        """
        session = use_session(session)
        return cls(votableparse(
            cls._from_result_url(result_url, session).read),
                   url=result_url,
                   session=session)
示例#7
0
    def fetch_result(self):
        """
        returns the result votable if query is finished
        """
        try:
            response = session.get(self.result_uri, stream=True)
            response.raise_for_status()
        except requests.RequestException as ex:
            self._update()
            # we propably got a 404 because query error. raise with error msg
            self.raise_if_error()
            raise DALServiceError.from_except(ex, self.url)

        response.raw.read = partial(response.raw.read, decode_content=True)
        return TAPResults(votableparse(response.raw.read), url=self.result_uri)
示例#8
0
文件: tap.py 项目: pyvirtobs/pyvo
    def fetch_result(self):
        """
        returns the result votable if query is finished
        """
        try:
            response = s.get(self.result_uri, stream=True)
            response.raise_for_status()
        except requests.RequestException as ex:
            self._update()
            # we propably got a 404 because query error. raise with error msg
            self.raise_if_error()
            raise DALServiceError.from_except(ex, self.url)

        response.raw.read = partial(
            response.raw.read, decode_content=True)
        return TAPResults(votableparse(response.raw.read), url=self.result_uri)