Skip to content

Commit 7b99417

Browse files
Bring back old flush()
the flush=True argument to print() was only added with py3.3
1 parent 291d249 commit 7b99417

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyfile/file.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from __future__ import print_function
2222

2323
import os
24+
import sys
2425
import errno
2526
from subprocess import Popen, PIPE
2627
import hashlib
@@ -137,7 +138,8 @@ def _split_patterns(pattern_id=0, magdir="Magdir", file_name="file",
137138
buff = ""
138139
in_pattern = False
139140
prog.increment_amount()
140-
print(prog, "Splitting patterns", end='\r', flush=True)
141+
print(prog, "Splitting patterns", end='\r')
142+
sys.stdout.flush()
141143
with open(mfile, "r") as reader:
142144
lines = reader.readlines()
143145
for line_idx, line in enumerate(lines):
@@ -253,7 +255,8 @@ def compile_patterns(file_name="file", file_binary="file"):
253255
'{1}!'.format(out_file, ret_code))
254256
# os.chdir("..")
255257
prog.increment_amount()
256-
print(prog, "Compiling patterns", end='\r', flush=True)
258+
print(prog, "Compiling patterns", end='\r')
259+
sys.stdout.flush()
257260
print("")
258261

259262

update-db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def data_stored(data):
7979
return
8080
prog.increment_amount()
8181
if not hide:
82-
print(prog, "Updating database", end='\r', flush=True)
82+
print(prog, "Updating database", end='\r')
83+
sys.stdout.flush()
8384

8485
# create thread pool here, so program exits if error occurs earlier
8586
n_threads = 4 # TODO: probably need this instead of 2 in queueTasks

0 commit comments

Comments
 (0)