|
|
@ -28,6 +28,19 @@ html_text = ''' |
|
|
|
</html> |
|
|
|
''' |
|
|
|
|
|
|
|
local_html_text = ''' |
|
|
|
<!DOCTYPE html> |
|
|
|
<html lang="zh-CN"> |
|
|
|
<head> |
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> |
|
|
|
</head> |
|
|
|
<body style="font-size:22px;text-align:center"> |
|
|
|
<p>目前这里有{nc}门课程的{np}份资料<br>欢迎继续添砖加瓦</p> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
''' |
|
|
|
|
|
|
|
def check_and_update(last_number): |
|
|
|
np = Paper.query.count() |
|
|
|
if np != last_number: |
|
|
@ -38,6 +51,9 @@ def check_and_update(last_number): |
|
|
|
ssh.load_system_host_keys() |
|
|
|
ssh.connect(host, username=username) |
|
|
|
|
|
|
|
with open('static/login/count-info.html', 'w') as f: |
|
|
|
f.write(local_html_text.format(nc=nc, np=np, target_host=target_host)) |
|
|
|
|
|
|
|
with SCPClient(ssh.get_transport()) as scp: |
|
|
|
fl = io.BytesIO() |
|
|
|
fl.write(bytes(html_text.format(time=t.strftime("%Y-%m-%d %H:%M"), nc=nc, np=np, target_host=target_host), encoding='utf-8')) |
|
|
@ -47,7 +63,7 @@ def check_and_update(last_number): |
|
|
|
return np |
|
|
|
|
|
|
|
|
|
|
|
n = 0 |
|
|
|
n = check_and_update(0) |
|
|
|
while True: |
|
|
|
try: |
|
|
|
print(str(datetime.now()), 'start ------') |
|
|
|