Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3b95932

Browse files
author
vshepard
committed
Normalize error
1 parent 9f69b30 commit 3b95932

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import logging
77
import os
88

9-
import sys
10-
119
from contextlib import contextmanager
1210
from packaging.version import Version, InvalidVersion
1311
import re

0 commit comments

Comments
 (0)