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)