fix: some exception
This commit is contained in:
parent
65beca5067
commit
77b51204af
10
main.py
10
main.py
@ -11,7 +11,7 @@ DEBUG_MODE = False
|
|||||||
URL = 'https://www.cmlab.csie.ntu.edu.tw/status-gpu/'
|
URL = 'https://www.cmlab.csie.ntu.edu.tw/status-gpu/'
|
||||||
GPU_LIMIT = 2
|
GPU_LIMIT = 2
|
||||||
GOOGLE_CODE = os.environ['GOOGLE_CODE']
|
GOOGLE_CODE = os.environ['GOOGLE_CODE']
|
||||||
MAIL_CD_HOUR = 6
|
MAIL_CD_HOUR = 12
|
||||||
MAIL_MESSAGE = '''
|
MAIL_MESSAGE = '''
|
||||||
Hi, {}<br>
|
Hi, {}<br>
|
||||||
<br>
|
<br>
|
||||||
@ -76,7 +76,9 @@ def get_server_gpu_status() -> list:
|
|||||||
for box in boxes[:-1]:
|
for box in boxes[:-1]:
|
||||||
soup = BeautifulSoup(box, 'html.parser')
|
soup = BeautifulSoup(box, 'html.parser')
|
||||||
# get server name
|
# get server name
|
||||||
server_name = soup.find('span', class_='f7').text.replace(' ', '')
|
server = soup.find('span', class_='f7')
|
||||||
|
if server:
|
||||||
|
server_name = server.text.replace(' ', '')
|
||||||
gpu_names = []
|
gpu_names = []
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
@ -93,7 +95,7 @@ def get_server_gpu_status() -> list:
|
|||||||
for user_obj in user_objs:
|
for user_obj in user_objs:
|
||||||
if user_obj != None:
|
if user_obj != None:
|
||||||
username = user_obj.text
|
username = user_obj.text
|
||||||
if username != 'gdm':
|
if username != 'gdm' and username != 'root':
|
||||||
user_in_this_gpu.add(username)
|
user_in_this_gpu.add(username)
|
||||||
|
|
||||||
# get gpu names
|
# get gpu names
|
||||||
@ -197,7 +199,7 @@ def mail_notify(violators: list) -> None:
|
|||||||
msg['Subject'] = f'[網管通知] 提醒您已經超過 CMLab GPU 使用限制!({username})'
|
msg['Subject'] = f'[網管通知] 提醒您已經超過 CMLab GPU 使用限制!({username})'
|
||||||
msg['From'] = 'unix_manager@cmlab.csie.ntu.edu.tw'
|
msg['From'] = 'unix_manager@cmlab.csie.ntu.edu.tw'
|
||||||
msg['To'] = f'{username}@cmlab.csie.ntu.edu.tw' if not DEBUG_MODE else 'snsd0805@cmlab.csie.ntu.edu.tw'
|
msg['To'] = f'{username}@cmlab.csie.ntu.edu.tw' if not DEBUG_MODE else 'snsd0805@cmlab.csie.ntu.edu.tw'
|
||||||
msg['Cc'] = 'unix_manager@cmlab.csie.ntu.edu.tw' if not DEBUG_MODE else 'snsd0805@cmlab.csie.ntu.edu.tw'
|
# msg['Cc'] = 'unix_manager@cmlab.csie.ntu.edu.tw' if not DEBUG_MODE else 'snsd0805@cmlab.csie.ntu.edu.tw'
|
||||||
|
|
||||||
smtp = smtplib.SMTP('smtp.gmail.com', 587)
|
smtp = smtplib.SMTP('smtp.gmail.com', 587)
|
||||||
smtp.ehlo()
|
smtp.ehlo()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user