Skip to content

Flush Utilities/bootstrap script logging output #8141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Utilities/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import errno

def log_timestamp(marker):
print("--- %s: note: %s %s" % (os.path.basename(sys.argv[0]), marker, datetime.datetime.now().isoformat()))
print("--- %s: note: %s %s" % (os.path.basename(sys.argv[0]), marker, datetime.datetime.now().isoformat()), flush=True)

def note(message):
print("--- %s: note: %s" % (os.path.basename(sys.argv[0]), message))
print("--- %s: note: %s" % (os.path.basename(sys.argv[0]), message), flush=True)
log_timestamp("timestamp")
sys.stdout.flush()

def error(message):
print("--- %s: error: %s" % (os.path.basename(sys.argv[0]), message))
print("--- %s: error: %s" % (os.path.basename(sys.argv[0]), message), flush=True)
log_timestamp("timestamp")
sys.stdout.flush()
raise SystemExit(1)
Expand All @@ -51,21 +51,21 @@ def mkdir_p(path):
def call(cmd, cwd=None, verbose=False):
"""Calls a subprocess."""
if verbose:
print(' '.join(cmd))
print(' '.join(cmd), flush=True)
try:
subprocess.check_call(cmd, cwd=cwd)
except Exception as e:
if not verbose:
print(' '.join(cmd))
print(' '.join(cmd), flush=True)
error(str(e))

def call_output(cmd, cwd=None, stderr=False, verbose=False):
"""Calls a subprocess for its return data."""
if verbose:
print(' '.join(cmd))
print(' '.join(cmd), flush=True)
try:
return subprocess.check_output(cmd, cwd=cwd, stderr=stderr, universal_newlines=True).strip()
except Exception as e:
if not verbose:
print(' '.join(cmd))
print(' '.join(cmd), flush=True)
error(str(e))