From 6278423a5df2086a6baef54bbd9f174fd5ab459d Mon Sep 17 00:00:00 2001
From: Bert van der Weerd <bert@stanzabird.nl>
Date: Sat, 20 Nov 2021 11:17:38 +0100
Subject: [PATCH] Fix stdout flushing issue

---
 assets/librewolf-patches.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/assets/librewolf-patches.py b/assets/librewolf-patches.py
index c4df4b9..c01a441 100755
--- a/assets/librewolf-patches.py
+++ b/assets/librewolf-patches.py
@@ -23,7 +23,8 @@ def script_exit(statuscode):
     if (time.time() - start_time) > 60:
         # print elapsed time
         elapsed = time.strftime("%H:%M:%S", time.gmtime(time.time() - start_time))
-        print(f"\n\aElapsed time: {elapsed}")
+        print("\n\aElapsed time: {elapsed}")
+        sys.stdout.flush()
 
     sys.exit(statuscode)
 
@@ -31,10 +32,12 @@ def exec(cmd, exit_on_fail = True, do_print = True):
     if cmd != '':
         if do_print:
             print(cmd)
+            sys.stdout.flush()
         if not options.no_execute:
             retval = os.system(cmd)
             if retval != 0 and exit_on_fail:
                 print("fatal error: command '{}' failed".format(cmd))
+                sys.stdout.flush()
                 script_exit(1)
             return retval
         return None
@@ -42,10 +45,12 @@ def exec(cmd, exit_on_fail = True, do_print = True):
 def patch(patchfile):
     cmd = "patch -p1 -i {}".format(patchfile)
     print("\n*** -> {}".format(cmd))
+    sys.stdout.flush()
     if not options.no_execute:
         retval = os.system(cmd)
         if retval != 0:
             print("fatal error: patch '{}' failed".format(patchfile))
+            sys.stdout.flush()
             script_exit(1)
 
 def enter_srcdir(_dir = None):
@@ -54,15 +59,18 @@ def enter_srcdir(_dir = None):
     else:
         dir = _dir
     print("cd {}".format(dir))
+    sys.stdout.flush()
     if not options.no_execute:
         try:
             os.chdir(dir)
         except:
             print("fatal error: can't change to '{}' folder.".format(dir))
+            sys.stdout.flush()
             script_exit(1)
         
 def leave_srcdir():
     print("cd ..")
+    sys.stdout.flush()
     if not options.no_execute:
         os.chdir("..")