Skip to content

Commit 3e63a12

Browse files
committed
Deduplicate domlogo.
Also fix log file location.
1 parent 058b3ae commit 3e63a12

File tree

2 files changed

+12
-115
lines changed

2 files changed

+12
-115
lines changed

domlogo/domlogo.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import requests
77
import re
8+
import time
89

910
font = ('Roboto', 14)
1011
team_image = sg.Image(filename='domlogo-files/photos/idle.png')
@@ -41,18 +42,21 @@
4142
api_url = f'{api_url}/contests/{cid}'
4243
print(f'Contest is {cid}.')
4344

44-
latest_logfile = max(glob.glob('output/log/judge.*-0.log'), key=os.path.getctime)
45+
latest_logfile = max(glob.glob('output/log/judge.*-2.log'), key=os.path.getctime)
4546
print(f'Checking logfile {latest_logfile}')
4647
with open(latest_logfile, 'r') as logfile:
4748
# Seeks to the end of the file.
4849
logfile.seek(0, 2)
4950
results = []
5051
last_seen, needs_update = (None, None)
5152
while True:
52-
event, values = window.read(timeout=10)
53+
event, values = window.read(timeout=30)
5354
if event == sg.WIN_CLOSED:
5455
break
5556
line = logfile.readline()
57+
# Sleep here for a tiny amount of time to avoid using too much CPU.
58+
if len(line) == 0:
59+
time.sleep(0.01)
5660
if 'Working directory:' in line:
5761
token = line.strip().split('/')
5862
judging_id = token[-1]
@@ -65,10 +69,9 @@
6569
team_id = submission_data['team_id']
6670
last_seen = (submission_id, judging_id, team_id)
6771
new_filename = f'domlogo-files/photos/{team_id}.png'
68-
if team_id>=120:
69-
team_image.update(filename=new_filename)
70-
f'domlogo-files/photos/{team_id}.png')
71-
team_image.update(filename=f'domlogo-files/photos/{team_id}.png')
72+
if (int)(team_id) >= 120:
73+
new_filename = f'domlogo-files/photos/crew.png'
74+
team_image.update(filename=new_filename)
7275
metadata_text.update(f's{submission_id} / {submission_data["problem_id"]} / {submission_data["language_id"]}')
7376
results_text.update('Busy compiling.')
7477
elif 'No submissions in queue' in line:
@@ -96,6 +99,8 @@
9699
color = 'DeepSkyBlue'
97100
for i in range(len(cache)-1):
98101
cache[i] = cache[i+1]
102+
if (int)(tid) >= 120:
103+
tid = 'DOMjudge'
99104
cache[-1] = (f'domlogo-files/logos/{tid}.png', f's{sid}/j{jid}\n{verdict}', color, jid)
100105
for i in range(len(cache)):
101106
previous_column[i][0].update(filename=cache[i][0])

icpc-wf/ansible/roles/domlogo/files/domlogo.py

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/sitowert/domjudge-scripts/domlogo/domlogo.py

0 commit comments

Comments
 (0)