Skip to content

Commit 0784f49

Browse files
author
vshepard
committed
Normalize error
1 parent 9f69b30 commit 0784f49

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

testgres/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,6 @@ def poll_query_until(self,
11651165
assert sleep_time > 0
11661166
attempts = 0
11671167
while max_attempts == 0 or attempts < max_attempts:
1168-
logging.info(f"Pooling {attempts}")
11691168
try:
11701169
res = self.execute(dbname=dbname,
11711170
query=query,
@@ -1189,6 +1188,7 @@ def poll_query_until(self,
11891188
return # done
11901189

11911190
except tuple(suppress or []):
1191+
logging.info(f"Trying execute, attempt {attempts + 1}.\nQuery: {query}")
11921192
pass # we're suppressing them
11931193

11941194
time.sleep(sleep_time)

testgres/operations/remote_ops.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
9393
if not error:
9494
error_found = 0
9595
else:
96+
error = normalize_error(error)
9697
error_found = exit_status != 0 or any(
97-
marker in error for marker in [b'error', b'Permission denied', b'fatal', b'No such file or directory'])
98+
marker in error for marker in ['error', 'Permission denied', 'fatal', 'No such file or directory']
99+
)
98100

99101
if error_found:
100102
if isinstance(error, bytes):
@@ -369,3 +371,9 @@ def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
369371
password=password,
370372
)
371373
return conn
374+
375+
376+
def normalize_error(error):
377+
if isinstance(error, bytes):
378+
return error.decode()
379+
return error

testgres/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import division
44
from __future__ import print_function
55

6-
import logging
76
import os
87

98
import sys
@@ -229,7 +228,7 @@ def eprint(*args, **kwargs):
229228
"""
230229
Print stuff to stderr.
231230
"""
232-
logging.error(*args, **kwargs)
231+
print(*args, file=sys.stderr, **kwargs)
233232

234233

235234
def options_string(separator=u" ", **kwargs):

0 commit comments

Comments
 (0)