Fix #219: catch BrokenPipeError
This commit is contained in:
parent
fd49d30a3e
commit
98fd16f075
9
buku.py
9
buku.py
@ -3231,6 +3231,7 @@ def print_rec_with_filter(records, field_filter=0):
|
|||||||
Integer indicating which fields to print.
|
Integer indicating which fields to print.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
if field_filter == 0:
|
if field_filter == 0:
|
||||||
for row in records:
|
for row in records:
|
||||||
print_single_rec(row)
|
print_single_rec(row)
|
||||||
@ -3258,6 +3259,9 @@ def print_rec_with_filter(records, field_filter=0):
|
|||||||
elif field_filter == 40:
|
elif field_filter == 40:
|
||||||
for row in records:
|
for row in records:
|
||||||
print('%s\t%s\t%s' % (row[1], row[2], row[3][1:-1]))
|
print('%s\t%s\t%s' % (row[1], row[2], row[3][1:-1]))
|
||||||
|
except BrokenPipeError:
|
||||||
|
sys.stdout = os.fdopen(1)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def print_single_rec(row, idx=0): # NOQA
|
def print_single_rec(row, idx=0): # NOQA
|
||||||
"""Print a single DB record.
|
"""Print a single DB record.
|
||||||
@ -3293,8 +3297,11 @@ def print_single_rec(row, idx=0): # NOQA
|
|||||||
if row[3] != DELIM:
|
if row[3] != DELIM:
|
||||||
str_list.append(TAG_str % (row[3][1:-1]))
|
str_list.append(TAG_str % (row[3][1:-1]))
|
||||||
|
|
||||||
|
try:
|
||||||
print(''.join(str_list))
|
print(''.join(str_list))
|
||||||
|
except BrokenPipeError:
|
||||||
|
sys.stdout = os.fdopen(1)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def format_json(resultset, single_record=False, field_filter=0):
|
def format_json(resultset, single_record=False, field_filter=0):
|
||||||
"""Return results in json format.
|
"""Return results in json format.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user