Always flush after each message

It was already ok before in interactive terminals,
but when invloving pipes to e.g. tee or file redirects,
the output got buffered for such a long time, it made
it seem like the script suddenly broke.
This commit is contained in:
Oneric 2025-08-01 00:00:00 +00:00
commit 73e62c2f2a

View file

@ -13,6 +13,7 @@ from typing import Any, Optional, TypeAlias, Union
VERSION = "0.1"
DEBUG = True
DRYRUN = False
FLUSH = True
NOW = datetime.datetime.now(datetime.timezone.utc)
@ -45,11 +46,11 @@ class Config(argparse.Namespace):
# Utils
def printerr(str: str) -> None:
print(str, file=sys.stderr)
print(str, file=sys.stderr, flush=FLUSH)
def printdbg(str: str) -> None:
if DEBUG:
print(str)
print(str, flush=FLUSH)
def is_http_error(resp: httpx.Response) -> bool:
return resp.status_code >= 300 or resp.status_code < 200