forked from mrcaidev/uestc-temperature
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (26 loc) · 846 Bytes
/
Copy pathmain.py
File metadata and controls
32 lines (26 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys
import time
from report import ReportTask
if __name__ == '__main__':
# Parse session IDs.
if len(sys.argv) != 2:
raise Exception('Session ID required.')
else:
session_ids = sys.argv[1].split('#')
# Print time for debug purpose.
print('-' * 60)
print(time.strftime('%F %H:%M:%S').center(60))
print(f'{"-"*30}'.center(60))
# Read configuration files.
ReportTask.read_config()
# Run tasks.
# Async codes not adopted to ensure a higher rate of success.
all_success = True
for index, session_id in enumerate(session_ids):
print(f'Reporting for student No.{index+1}:', end=' ')
task = ReportTask(session_id)
success = task.run()
if not success:
all_success = False
if not all_success:
raise Exception('Failed')