feat: weekly report
This commit is contained in:
parent
5b4982acf1
commit
ad3f5b5b30
31
weekly_report.py
Normal file
31
weekly_report.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
from mailer import Mailer
|
||||||
|
|
||||||
|
GOOGLE_OWNER = 'snsd0805@cmlab.csie.ntu.edu.tw'
|
||||||
|
GOOGLE_CODE = os.environ['GOOGLE_CODE']
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with open('send_log.json') as fp:
|
||||||
|
data = json.load(fp)
|
||||||
|
|
||||||
|
msg = '''
|
||||||
|
<pre>
|
||||||
|
Every Wednesday 00:30
|
||||||
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n
|
||||||
|
'''
|
||||||
|
for username, status in data.items():
|
||||||
|
week_count = status['week_count']
|
||||||
|
if week_count != 0:
|
||||||
|
print(username, week_count)
|
||||||
|
data[username]['week_count'] = 0
|
||||||
|
|
||||||
|
msg += f'\t{username}: notified <span style="color: red">{week_count}</span> times in this week\n'
|
||||||
|
msg += '''
|
||||||
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
</pre>
|
||||||
|
'''
|
||||||
|
mailer = Mailer(GOOGLE_OWNER, GOOGLE_CODE)
|
||||||
|
mailer.send('unix_manager@cmlab.csie.ntu.edu.tw', f'unix_manager@cmlab.csie.ntu.edu.tw', 'CML Server GPU Usage Weekly Report', msg)
|
||||||
|
with open('send_log.json', 'w') as fp:
|
||||||
|
json.dump(data, fp)
|
||||||
Loading…
Reference in New Issue
Block a user