gavo.votable.tapquery module

An interface to querying TAP servers (i.e., a TAP client).

This is deprecated. Use pyvo.dal.tap instead.

class gavo.votable.tapquery.ADQLEndpoint(endpointURL)[source]

Bases: _WithEndpoint

A facade for an ADQL endpoint.

This is only needed for inspecting server metadata (i.e., in general only for rather fancy applications).

property available

returns True, False, or None (undecidable).

None is returned when /availability gives a 404 (which is legal) or the returned document doesn’t parse.

property capabilities

returns a dictionary containing some meta info on the remote service.

Keys to look for include title, identifier, contact (the mail address), and referenceURL.

If the remote server doesn’t return capabilities as expected, an empty dict is returned.

createJob(query, lang='ADQL-2.0', userParams={})[source]
property tables

returns a sequence of table definitions for the tables accessible through this service.

The table definitions come as gavo.votable.Table instances.

class gavo.votable.tapquery.ADQLSyncJob(endpointURL, query=None, jobId=None, lang='ADQL', userParams={}, timeout=None)[source]

Bases: _WithEndpoint

A facade for a synchronous TAP Job.

This really is just a very glorified urllib.urlopen. Maybe some superficial parallels to ADQLTAPJob are useful.

You can construct it, add uploads, and then start or run the thing. Methods that make no sense at all for sync jobs (“phase”) silently return some more or less sensible fakes.


does nothing.

You could argue that this could come from a different thread and we could try to interrupt the ongoing request. Well, if you want it, try it yourself or ask the author.

addUpload(name, data)[source]
property allResults
property info
property owner
property parameters
property phase
property quote
setParameter(key, value)[source]
waitForPhases(phases, pollInterval=None, increment=None, giveUpAfter=None)[source]
class gavo.votable.tapquery.ADQLTAPJob(endpointURL, query=None, jobId=None, lang='ADQL', userParams={}, timeout=None)[source]

Bases: _WithEndpoint

A facade for an ADQL-based async TAP job.

Construct it with the URL of the async endpoint and a query.

Alternatively, you can give the endpoint URL and a jobId as a keyword parameter. This only makes sense if the service has handed out the jobId before (e.g., when a different program takes up handling of a job started before).

See adql.html for details.


asks the remote side to abort the job.

addUpload(name, data)[source]

adds uploaded tables, either from a file or as a remote URL.

You should not try to change UPLOAD yourself (e.g., using setParameter).

Data is either a string (i.e. a URI) or a file-like object (an upload).

property allResults

returns a list of UWSResult instances.


removes the job on the remote side.

usePOST=True can be used for servers that do not support the DELETE HTTP method (a.k.a. “are broken”).

property destruction
property executionDuration

returns the error message the server gives, verbatim.


returns the URL of the ADQL result table.

property info

returns a dictionary of much job-related information.


returns a file-like object you can read the default TAP result off.

To have the embedded VOTable returned, say votable.load(job.openResult()).

If you pass simple=False, the URL will be taken from the service’s result list (the first one given there). Otherwise (the default), results/result is used.

property owner

returns the owner of the job.

property parameters

returns a dictionary mapping passed parameters to server-provided string representations.

To set a parameter, use the setParameter function. Changing the dictionary returned here will have no effect.

property phase

returns the phase the job is in according to the server.

property quote

returns the estimate the server gives for the run time of the job.


raises an appropriate error message if job has thrown an error or has been aborted.


runs the job and waits until it has finished.

The function raises an exception with an error message gleaned from the server.

setParameter(key, value)[source]

asks the remote side to start the job.

waitForPhases(phases, pollInterval=1, increment=1.189207115002721, giveUpAfter=None)[source]

waits for the job’s phase to become one of the set phases.

This method polls. Initially, it does increases poll times exponentially with increment until it queries every two minutes.

The magic number in increment is 2**(1/4.).

giveUpAfter, if given, is the number of iterations this method will do. If none of the desired phases have been found until then, raise a ProtocolError.

exception gavo.votable.tapquery.Error(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

The base class for all TAP-related exceptions.

class gavo.votable.tapquery.LocalResult(data, id, type)[source]

Bases: object

exception gavo.votable.tapquery.NetworkError(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

is raised when a generic network error happens (can’t connect,…)

exception gavo.votable.tapquery.ProtocolError(msg: str = '', hint: Optional[str] = None)[source]

Bases: Error

is raised when the remote server violated the local assumptions.

exception gavo.votable.tapquery.RemoteAbort[source]

Bases: Error

is raised by certain check functions when the remote side has aborted the job.

exception gavo.votable.tapquery.RemoteError(remoteMessage)[source]

Bases: Error

is raised when the remote size signals an error.

The content of the remote error document can be retrieved in the remoteMessage attribute.

class gavo.votable.tapquery.UWSResult(href, id=None, type=None)[source]

Bases: object

a container type for a result returned by an UWS service.

It exposes id, href, and type attributes.

exception gavo.votable.tapquery.WrongStatus(msg, foundStatus, payload, hint=None)[source]

Bases: ProtocolError

is raised when request detects the server returned an invalid status.

These are constructed with the status returned (available as foundStatus) data payload of the response (available as payload).

gavo.votable.tapquery.request(scheme, host, path, data='', customHeaders={}, method='GET', expectedStatus=None, followRedirects=False, setResponse=None, timeout=None)[source]

returns a HTTPResponse object for an HTTP request to path on host.

This function builds a new connection for every request.

On the returned object, you cannot use the read() method. Instead any data returned by the server is available in the data attribute.

data usually is a byte string, but you can also pass a dictionary which then will be serialized using _FormData above.

You can set followRedirects to True. This means that the 303 “See other” codes that many UWS action generate will be followed and the document at the other end will be obtained. For many operations this will lead to an error; only do this for slightly broken services.

In setResponse, you can pass in a callable that is called with the server response body as soon as it is in. This is for when you want to store the response even if request raises an error later on (i.e., for sync querying).