Package glue :: Module datafind :: Class GWDataFindHTTPConnection
[hide private]
[frames] | no frames]

Class GWDataFindHTTPConnection

source code

httplib.HTTPConnection --+
                         |
                        GWDataFindHTTPConnection
Known Subclasses:

Connection to LIGO data replicator service using HTTP.

Nested Classes [hide private]
  LIGOTimeGPSType
An object for storing times with nanosecond resolution.

Inherited from httplib.HTTPConnection: response_class

Instance Methods [hide private]
 
__init__(self, host=None, **kwargs)
Connect to the LDR host using HTTPS.
source code
 
_requestresponse(self, method, url, body=None, headers={})
Internal method to perform request and verify reponse.
source code
 
find_frame(self, framefile, urltype=None, on_missing='warn')
Query the LDR host for a single framefile
source code
 
find_frame_urls(self, site, frametype, gpsstart, gpsend, match=None, urltype=None, on_gaps='warn')
Find the framefiles for the given type in the [start, end) interval frame
source code
 
find_latest(self, site, frametype, urltype=None, on_missing='warn')
Query for the most recent framefile of a given type.
source code
 
find_observatories(self, match=None)
Query the LDR host for observatories.
source code
 
find_times(self, site, frametype, gpsstart=None, gpsend=None)
Query the LDR for times for which frames are avaliable
source code
 
find_types(self, site=None, match=None)
Query the LDR host for frame types.
source code
 
ping(self)
Ping the LDR host to test for life
source code

Inherited from httplib.HTTPConnection: close, connect, endheaders, getresponse, putheader, putrequest, request, send, set_debuglevel, set_tunnel

Inherited from httplib.HTTPConnection (private): _get_hostport, _output, _send_output, _send_request, _set_content_length, _tunnel

Class Variables [hide private]

Inherited from httplib.HTTPConnection: auto_open, debuglevel, default_port, strict

Inherited from httplib.HTTPConnection (private): _http_vsn, _http_vsn_str

Method Details [hide private]

__init__(self, host=None, **kwargs)
(Constructor)

source code 

Connect to the LDR host using HTTPS. Default host is defined by the LIGO_DATAFIND_SERVER environment variable.

Parameters:
  • host (str) - the name of the server with which to connect
  • port (int) - the port on which to connect
  • **kwargs - other keyword arguments accepted by httplib.HTTPConnection
Overrides: httplib.HTTPConnection.__init__

_requestresponse(self, method, url, body=None, headers={})

source code 

Internal method to perform request and verify reponse.

Parameters:
  • method (str) - name of the method to use (e.g. 'GET')
  • url (str) - remote URL to query
Returns:
str response from server query
Raises:
  • RuntimeError - if query is unsuccessful

find_frame(self, framefile, urltype=None, on_missing='warn')

source code 

Query the LDR host for a single framefile

Parameters:
  • frametype (str) - name of frametype to match
  • urltype (str) - file scheme to search for (e.g. 'file')
  • on_missing (str) - what to do when the requested frame isn't found, one of:
    • 'warn' (default): print a warning,
    • 'error': raise an RuntimeError, or
    • 'ignore': do nothing
Returns:
Cache
Raises:
  • RuntimeError - if given framefile is malformed

find_frame_urls(self, site, frametype, gpsstart, gpsend, match=None, urltype=None, on_gaps='warn')

source code 

Find the framefiles for the given type in the [start, end) interval frame

Parameters:
  • site (str) - single-character name of site to match
  • frametype (str) - name of frametype to match
  • gpsstart (int) - integer GPS start time of query
  • gpsend (int) - integer GPS end time of query
  • match (str) - regular expression to match against
  • urltype (str) - file scheme to search for (e.g. 'file')
  • on_gaps (str) - what to do when the requested frame isn't found, one of:
    • 'warn' (default): print a warning,
    • 'error': raise an RuntimeError, or
    • 'ignore': do nothing
Returns:
Cache
Raises:
  • RuntimeError - if gaps are found and on_gaps='error'

find_latest(self, site, frametype, urltype=None, on_missing='warn')

source code 

Query for the most recent framefile of a given type.

Parameters:
  • site (str) - single-character name of site to match
  • frametype (str) - name of frametype to match
  • urltype (str) - file scheme to search for (e.g. 'file')
  • on_missing (str) - what to do when the requested frame isn't found, one of:
    • 'warn' (default): print a warning,
    • 'error': raise an RuntimeError, or
    • 'ignore': do nothing
Returns:
Cache with one entry
Raises:
  • RuntimeError - if given framefile is malformed
  • RuntimeError - if no frames are found and on_missing='error'

find_observatories(self, match=None)

source code 

Query the LDR host for observatories. Use match to restrict returned observatories to those matching the regular expression.

Example:

>>> connection.find_observatories()
['AGHLT', 'G', 'GHLTV', 'GHLV', 'GHT', 'H', 'HL', 'HLT',
 'L', 'T', 'V', 'Z']
>>> connection.find_observatories("H")
['H', 'HL', 'HLT']
Parameters:
  • match (str) - name to match return observatories against
Returns:
list of observatory prefixes

find_times(self, site, frametype, gpsstart=None, gpsend=None)

source code 

Query the LDR for times for which frames are avaliable

Use gpsstart and gpsend to restrict the returned times to this semiopen interval.

Parameters:
  • site (str) - single-character name of site to match
  • frametype (str) - name of frametype to match
  • gpsstart (int) - integer GPS start time of query
  • gpsend (int) - integer GPS end time of query
Returns:
segmentlist

find_types(self, site=None, match=None)

source code 

Query the LDR host for frame types. Use site to restrict query to given observatory prefix, and use match to restrict returned types to those matching the regular expression.

Example:

>>> connection.find_types("L", "RDS")
['L1_RDS_C01_LX',
 'L1_RDS_C02_LX',
 'L1_RDS_C03_L2',
 'L1_RDS_R_L1',
 'L1_RDS_R_L3',
 'L1_RDS_R_L4',
 'PEM_RDS_A6',
 'RDS_R_L1',
 'RDS_R_L2',
 'RDS_R_L3',
 'TESTPEM_RDS_A6']
Parameters:
  • site (str) - single-character name of site to match
  • match (str) - type-name to match against
Returns:
list of frame types

ping(self)

source code 

Ping the LDR host to test for life

Returns:
0 if ping was successful
Raises:
  • RuntimeError - when ping fails