ci/marge_queue: add pretty_dutation()
Add pretty_duration() function that prints time in format 6m23s and use it for marge_queue. Signed-of-by: Helen Koike <helen.koike@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25822>
This commit is contained in:
@@ -12,6 +12,17 @@ import time
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_duration(seconds):
|
||||||
|
"""Pretty print duration"""
|
||||||
|
hours, rem = divmod(seconds, 3600)
|
||||||
|
minutes, seconds = divmod(rem, 60)
|
||||||
|
if hours:
|
||||||
|
return f"{hours:0.0f}h{minutes:0.0f}m{seconds:0.0f}s"
|
||||||
|
if minutes:
|
||||||
|
return f"{minutes:0.0f}m{seconds:0.0f}s"
|
||||||
|
return f"{seconds:0.0f}s"
|
||||||
|
|
||||||
|
|
||||||
def get_gitlab_project(glab, name: str):
|
def get_gitlab_project(glab, name: str):
|
||||||
"""Finds a specified gitlab project for given user"""
|
"""Finds a specified gitlab project for given user"""
|
||||||
if "/" in name:
|
if "/" in name:
|
||||||
|
@@ -16,7 +16,7 @@ from datetime import datetime, timezone
|
|||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
|
||||||
import gitlab
|
import gitlab
|
||||||
from gitlab_common import read_token
|
from gitlab_common import read_token, pretty_duration
|
||||||
|
|
||||||
REFRESH_WAIT = 30
|
REFRESH_WAIT = 30
|
||||||
MARGE_BOT_USER_ID = 9716
|
MARGE_BOT_USER_ID = 9716
|
||||||
@@ -52,8 +52,10 @@ if __name__ == "__main__":
|
|||||||
for mr in mrs:
|
for mr in mrs:
|
||||||
updated = parser.parse(mr.updated_at)
|
updated = parser.parse(mr.updated_at)
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
diff = str(now - updated).split('.', maxsplit=1)[0]
|
diff = (now - updated).total_seconds()
|
||||||
print(f"{diff} | \u001b]8;;{mr.web_url}\u001b\\{mr.title}\u001b]8;;\u001b\\")
|
print(
|
||||||
|
f"⛭ \u001b]8;;{mr.web_url}\u001b\\{mr.title}\u001b]8;;\u001b\\ ({pretty_duration(diff)})"
|
||||||
|
)
|
||||||
|
|
||||||
print("Job waiting: " + str(jobs_num))
|
print("Job waiting: " + str(jobs_num))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user