Home | Trees | Indices | Help |
|
---|
|
1 # 2 # Copyright (C) 2009 Larne Pekowsky 3 # 4 # This program is free software; you can redistribute it and/or modify it 5 # under the terms of the GNU General Public License as published by the 6 # Free Software Foundation; either version 3 of the License, or (at your 7 # option) any later version. 8 # 9 # This program is distributed in the hope that it will be useful, but 10 # WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 12 # Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License along 15 # with this program; if not, write to the Free Software Foundation, Inc., 16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18 19 # 20 # ============================================================================= 21 # 22 # Preamble 23 # 24 # ============================================================================= 25 # 26 27 28 """ 29 Provides a unified interface for querying sqlite databases and a DB2 database 30 behind a ldbd interface 31 """ 32 33 import os 34 try: 35 import pyRXP 36 except ImportError: 37 import pyRXPU as pyRXP 38 from glue import ldbd 39 40 from glue import git_version 41 __date__ = git_version.date 42 __version__ = git_version.id 43 __author__ = "Larne Pekowsky <lppekows@physics.syr.edu>" 44 4547 """Abstract class. Provides query() method that returns something that 48 behaves like an array of tuples of results and a close() method that 49 does any needed cleanup.""" 50 5356 5759 """QueryEngine for sqlite databases. Really just a minimal wrapper 60 around cursor""" 61 62 connection = None 63 cursor = None 64 6780 8169 self.cursor = self.connection.cursor().execute(sql) 70 ret = [] 71 72 for row in self.cursor: 73 ret.append(row) 74 75 return ret7683 """QueryEngine for databses behind ldbd. Parses ligolw that a query 84 returns into rows""" 85 86 xmlparser = None 87 lwtparser = None 88 ligomd = None 89 90 rows = None 91 92 93106 10795 def dtd_uri_callback(uri): 96 if uri == 'http://ldas-sw.ligo.caltech.edu/doc/ligolwAPI/html/ligolw_dtd.txt': 97 return 'file://localhost' + os.path.join( os.environ["GLUE_PREFIX"], 'etc/ligolw_dtd.txt' ) 98 else: 99 return uri100 101 self.client = client 102 self.xmlparser = pyRXP.Parser() 103 self.xmlparser.eoCB = dtd_uri_callback 104 self.lwtparser = ldbd.LIGOLwParser() 105 self.ligomd = ldbd.LIGOMetadata(self.xmlparser, self.lwtparser, None)109 xml = self.client.query(sql) 110 111 # This is a kludge around bug 2317 112 try: 113 self.client.__disconnect__() 114 self.client.__connect__(self.client.host, self.client.port, self.client.identity) 115 except: 116 pass 117 118 self.ligomd.parse(xml) 119 res = self.ligomd.table 120 self.rows = self.ligomd.table[list(res.keys())[0]]['stream'] 121 122 return self.rows123125 del self.rows126
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Dec 12 00:34:23 2017 | http://epydoc.sourceforge.net |