Skip to content

Commit 970ce64

Browse files
committed
Bug in dbConnection
query was not capturing duplicate errors and passing them as the internal error object
1 parent 9e4e51f commit 970ce64

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

pgamit/dbConnection.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,32 @@ def __init__(self, configfile, use_float=False, write_cfg_file=False):
171171
raise dbErrConnect(err)
172172

173173
def query(self, command):
174-
self.cursor.execute(command)
174+
try:
175+
self.cursor.execute(command)
175176

176-
debug(" QUERY: command=%r" % command)
177+
debug(" QUERY: command=%r" % command)
177178

178-
# passing a query object to match response from pygresql
179-
return query_obj(self.cursor)
179+
# passing a query object to match response from pygresql
180+
return query_obj(self.cursor)
181+
except Exception as e:
182+
raise DatabaseError(e)
180183

181184
def query_float(self, command, as_dict=False):
182185
# deprecated: using psycopg2 now solves the problem of returning float numbers
183186
# still in to maintain backwards compatibility
187+
try:
188+
if not as_dict:
189+
cursor = self.cnn.cursor()
190+
cursor.execute(command)
191+
recordset = cast_array_to_float(cursor.fetchall())
192+
else:
193+
# return results as a dictionary
194+
self.cursor.execute(command)
195+
recordset = cast_array_to_float(self.cursor.fetchall())
184196

185-
if not as_dict:
186-
cursor = self.cnn.cursor()
187-
cursor.execute(command)
188-
recordset = cast_array_to_float(cursor.fetchall())
189-
else:
190-
# return results as a dictionary
191-
self.cursor.execute(command)
192-
recordset = cast_array_to_float(self.cursor.fetchall())
193-
194-
return recordset
197+
return recordset
198+
except Exception as e:
199+
raise DatabaseError(e)
195200

196201
def get(self, table, filter_fields, return_fields=None, limit=None):
197202
"""

pgamit/igslog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def extract_id_block(
204204
raise LogVersionError(f"Incorrect version string '{version}' passed to the extract_id_block() function")
205205

206206
id_block = _REGEX_ID.search(data)
207-
print(id_block)
207+
208208
if id_block is None:
209209
logger.warning(f"ID rejected from {file_path}")
210210
return _np.array([]).reshape(0, 12)

0 commit comments

Comments
 (0)