print real time
All checks were successful
Python package / lint (push) Successful in 6s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in 8s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Successful in 5s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to TestPyPI (push) Successful in 5s
All checks were successful
Python package / lint (push) Successful in 6s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in 8s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Successful in 5s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to TestPyPI (push) Successful in 5s
This commit is contained in:
parent
0e9eba4900
commit
5891409fdb
|
@ -69,20 +69,25 @@ def wrap(command: List[str], config: Path, retries: int, version: bool, dry_run:
|
||||||
attempt = 0
|
attempt = 0
|
||||||
while attempt <= retries:
|
while attempt <= retries:
|
||||||
# run the command
|
# run the command
|
||||||
result = subprocess.run(
|
with subprocess.Popen(
|
||||||
" ".join(command),
|
" ".join(command),
|
||||||
shell=True,
|
shell=True,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
encoding="utf-8",
|
) as proc:
|
||||||
)
|
stdout = ""
|
||||||
|
while True:
|
||||||
|
c = proc.stdout.read(1)
|
||||||
|
if c == b"":
|
||||||
|
break
|
||||||
|
s = c.decode("utf-8")
|
||||||
|
stdout += s
|
||||||
|
print(s, end="", flush=True)
|
||||||
|
return_code = proc.wait()
|
||||||
|
|
||||||
# TODO: print lines real time as the subprocess runs
|
if return_code:
|
||||||
print(result.stdout, end="")
|
|
||||||
|
|
||||||
if result.returncode:
|
|
||||||
# failed
|
# failed
|
||||||
title = f"Command failed with exit code {result.returncode}"
|
title = f"Command failed with exit code {return_code}"
|
||||||
if attempt < retries:
|
if attempt < retries:
|
||||||
title += f" - Retrying (attempt {attempt+1}/{retries})"
|
title += f" - Retrying (attempt {attempt+1}/{retries})"
|
||||||
else:
|
else:
|
||||||
|
@ -92,7 +97,7 @@ def wrap(command: List[str], config: Path, retries: int, version: bool, dry_run:
|
||||||
title = "Command succeeded"
|
title = "Command succeeded"
|
||||||
|
|
||||||
MAX_LINES = 20
|
MAX_LINES = 20
|
||||||
lines = result.stdout.splitlines()
|
lines = stdout.splitlines()
|
||||||
if len(lines) > MAX_LINES:
|
if len(lines) > MAX_LINES:
|
||||||
lines = lines[-MAX_LINES:]
|
lines = lines[-MAX_LINES:]
|
||||||
message = (
|
message = (
|
||||||
|
@ -106,13 +111,13 @@ def wrap(command: List[str], config: Path, retries: int, version: bool, dry_run:
|
||||||
with gotify.Gotify(base_url=url, app_token=app_token) as gotify_connection:
|
with gotify.Gotify(base_url=url, app_token=app_token) as gotify_connection:
|
||||||
gotify_connection.create_message(message=message, title=title)
|
gotify_connection.create_message(message=message, title=title)
|
||||||
|
|
||||||
if not result.returncode:
|
if not return_code:
|
||||||
# only retry on failure
|
# only retry on failure
|
||||||
break
|
break
|
||||||
|
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
||||||
sys.exit(result.returncode)
|
sys.exit(return_code)
|
||||||
|
|
||||||
|
|
||||||
# %% main
|
# %% main
|
||||||
|
|
Loading…
Reference in New Issue
Block a user