refactor: 本地只保存工号和加密密码,并整理后端目录
This commit is contained in:
+7
-12
@@ -1,4 +1,4 @@
|
||||
"""命令行登录中兴 e 学并打印用户资料与学时汇总。"""
|
||||
"""命令行登录中兴 e 学并打印用户资料。资料只打印,不写入本地库。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -6,9 +6,9 @@ import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "backend"))
|
||||
|
||||
from euniv_client import EunivClient
|
||||
from euniv import EunivClient
|
||||
|
||||
|
||||
def main() -> int:
|
||||
@@ -19,26 +19,21 @@ def main() -> int:
|
||||
return 2
|
||||
client = EunivClient(login_name, password)
|
||||
try:
|
||||
session = client.open_session()
|
||||
profile = client.login()
|
||||
client.authorize(profile)
|
||||
info = client.user_info()
|
||||
finally:
|
||||
client.close()
|
||||
info = session["profile"]
|
||||
summary = session["summary"]
|
||||
fields = [
|
||||
("工号", info.get("username")),
|
||||
("姓名", info.get("cnName")),
|
||||
("部门", info.get("departmentName")),
|
||||
("岗位层级", info.get("userClassLevelName")),
|
||||
("邮箱", info.get("email")),
|
||||
("累计学时", summary.get("actual_study_hour")),
|
||||
("累计学分", summary.get("actual_study_score")),
|
||||
("积分", summary.get("points")),
|
||||
("今日学时", summary.get("today_hours")),
|
||||
("今日学分", summary.get("today_score")),
|
||||
]
|
||||
print("登录成功")
|
||||
for label, value in fields:
|
||||
if value is not None and value != "":
|
||||
if value:
|
||||
print(f"{label}:{value}")
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user