Skip to content

Commit 29618e2

Browse files
committed
backend: nicer unknown-resalloc-tickets output
We always printed the "header-like" message, and the output was a bit unreadable. Closes: #2989
1 parent c197398 commit 29618e2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

backend/run/copr-backend-unknown-resalloc-tickets.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,33 @@ def all_ids():
5050
return tickets
5151

5252

53+
def print_once(message):
54+
"""
55+
Print the given message just once, even if called multiple times.
56+
"""
57+
# get the function-static storage
58+
storage = getattr(print_once, "_storage", {})
59+
setattr(print_once, "_storage", storage)
60+
if message not in storage:
61+
print(message)
62+
storage[message] = True
63+
64+
5365
if __name__ == "__main__":
5466
script_requires_user("resalloc")
5567

5668
used = used_ids()
69+
70+
# This is the oldest ticket that Copr Backend currently uses.
5771
min_used = min(used)
72+
5873
all_known = all_ids()
5974
unknown = all_known - used
6075

61-
print("These are old tickets, Copr uses only newer IDs, close them:")
6276
for unknown_id in sorted(unknown):
6377
if unknown_id < min_used:
78+
print_once("These are old tickets, Copr only uses newer tickets, close them:")
6479
print(f"resalloc ticket-close {unknown_id}")
6580
else:
66-
print(f"This seems relatively new to blindly close: {unknown_id}")
81+
print_once("These tickets are relatively new for closing blindly, double check!")
82+
print(f"resalloc ticket-check {unknown_id}")

0 commit comments

Comments
 (0)