diff --git a/weekly_report.py b/weekly_report.py new file mode 100644 index 0000000..47aa82d --- /dev/null +++ b/weekly_report.py @@ -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 = ''' +
+ 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 {week_count} times in this week\n'
+ msg += '''
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ '''
+ 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)