0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2025-02-08 04:37:59 -05:00

Fix stdout flushing issue

This commit is contained in:
Bert van der Weerd 2021-11-20 11:17:38 +01:00
parent b854b6f5a4
commit 6278423a5d
No known key found for this signature in database
GPG key ID: 4CFABB96ADE0F5B1

View file

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