diff --git a/pytyut/BuildingApi.py b/pytyut/BuildingApi.py
index 364cccc..9b71963 100644
--- a/pytyut/BuildingApi.py
+++ b/pytyut/BuildingApi.py
@@ -34,7 +34,7 @@ def get_teach_building_by_campus_id(self, xqh):
req_url = self.node + 'Tschedule/Zhcx/GetJxlhByXqh'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_free_class_info(self, zc: str = '', xq: str = '', ksjc: str = '', jsjc: str = '', xqh: str = '',
@@ -53,7 +53,7 @@ def get_free_class_info(self, zc: str = '', xq: str = '', ksjc: str = '', jsjc:
req_url = self.node + 'Tschedule/Zhcx/GetPageListJson'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_classroom_tree_by_campus(self):
@@ -64,7 +64,7 @@ def get_classroom_tree_by_campus(self):
req_url = self.node + 'Tschedule/Zhcx/GetXqJxlJasTreeJson'
res = self.session.post(req_url, data=GET_CLASSROOM_TREE_BY_CAMPUS_REQUEST_DATA, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
@@ -83,5 +83,5 @@ def get_course_schedule_by_classroom(self, semester: str= "now", xqh: str= "01",
req_url = self.node + 'Tschedule/Zhcx/GetSjjsSjddByJash'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
diff --git a/pytyut/ClassApi.py b/pytyut/ClassApi.py
index 46ac706..daaf791 100644
--- a/pytyut/ClassApi.py
+++ b/pytyut/ClassApi.py
@@ -29,5 +29,5 @@ def get_major_class_tree(self, semester):
req_url = self.node + 'Tschedule/Zhcx/GetNjxszyTreeByrwbjJson'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
diff --git a/pytyut/Connection.py b/pytyut/Connection.py
index cdd6031..93d1765 100644
--- a/pytyut/Connection.py
+++ b/pytyut/Connection.py
@@ -70,7 +70,7 @@ def get_user_info(self):
req_url = self.node + 'Home/StudentResult'
res = self.session.get(req_url, headers=self.default_headers)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
avatar = self.session.get(self.node + 'Tresources/AXsgj/ZpResultXs', headers=self.default_headers).content
param = '
([^^]*?)
[^^]*?<[^^]*?>(.*)[^^]*?>'
result = re.findall(param, res.text)
@@ -92,7 +92,7 @@ def get_total_grades_result(self):
# 这里请求数据与获取课程成绩用的数据是一样的
res = self.session.post(req_url, data=GET_COURSE_SCORE_REQUEST_DATA, headers=self.default_headers)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
if '评教未完成' in res.text:
raise CourseException("评教未完成,系统限制不予允许查询成绩!")
key_info_list = re.findall('([^<]*?)
', res.text)
diff --git a/pytyut/CourseApi.py b/pytyut/CourseApi.py
index 64432ee..565b86d 100644
--- a/pytyut/CourseApi.py
+++ b/pytyut/CourseApi.py
@@ -39,7 +39,7 @@ def get_course_schedule(self) -> dict:
"""
res = self.session.post(self.node + 'Tresources/A1Xskb/GetXsKb', headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_all_course_score(self, moreInformation=False) -> list:
@@ -52,7 +52,7 @@ def get_all_course_score(self, moreInformation=False) -> list:
req_url = self.node + '/Home/GetBxqcj'
res = self.session.post(req_url, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
html_text = json.loads(res.text)["rpath"]["m_StringValue"]
# html_text = html_text.replace('', '').replace('', '')
param = '''| ([^<]*?) | ([^<]*?) |
'''
@@ -63,7 +63,7 @@ def get_all_course_score(self, moreInformation=False) -> list:
res = self.session.post(req_url, headers=DEFAULT_HEADERS, data=GET_COURSE_SCORE_REQUEST_DATA)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
if '评教未完成' in res.text:
raise CourseException("评教未完成,系统限制不予允许查询成绩!")
@@ -116,7 +116,7 @@ def get_test_info(self, semester: str = "now", moreInformation=False) -> list:
}
res = self.session.post(req_url, headers=DEFAULT_HEADERS, data=data)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
html_text = json.loads(res.text)["rpath"]["m_StringValue"]
html_text = html_text.replace('', '').replace('', '')
param = '''| ([^<]*?) | ([^<]*?) | ([^<]*?) | ([^<]*?) |
'''
@@ -127,7 +127,7 @@ def get_test_info(self, semester: str = "now", moreInformation=False) -> list:
data = build_get_test_info_request_data(semester)
res = self.session.post(req_url, headers=DEFAULT_HEADERS, data=data)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_course_schedule_by_bjh(self, semester: str, bjh: str) -> dict:
@@ -145,7 +145,7 @@ def get_course_schedule_by_bjh(self, semester: str, bjh: str) -> dict:
req_url = self.node + 'Tschedule/Zhcx/GetSjjsSjddByBjh'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_selectable_course_list(self, semester: str = 'now') -> dict:
@@ -165,7 +165,7 @@ def get_selectable_course_list(self, semester: str = 'now') -> dict:
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_select_course_list(self, pid: str, semester: str = 'now') -> dict:
@@ -185,7 +185,7 @@ def get_select_course_list(self, pid: str, semester: str = 'now') -> dict:
req_url = self.node + 'Tschedule/C4Xkgl/GetXkkcListByXh'
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
json_info = res.json()
# 判断有没有用错接口
@@ -206,7 +206,7 @@ def get_selected_course_list(self) -> dict:
data = build_get_selected_course_list_request_data()
res = self.session.post(req_url, data=data, headers=DEFAULT_HEADERS)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_set_cookie(self, headers: dict) -> str:
@@ -247,7 +247,7 @@ def select_course(self, json_info) -> dict:
data['__RequestVerificationToken'] = self.get_set_cookie(headers)
res = self.session.post(req_url, data=data, headers=headers)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
# TODO: 未经测试
@@ -278,7 +278,7 @@ def remove_course(self, json_info, course_Id):
data['__RequestVerificationToken'] = self.get_set_cookie(headers)
res = self.session.post(req_url, data=data, headers=headers)
if '出错' in res.text or '教学管理服务平台(S)' in res.text:
- raise LoginException().login_timeout()
+ raise LoginException.login_timeout()
return res.json()
def get_course_schedule_by_classroom(self, xnxq, xqh, jxlh, jash):
diff --git a/pytyut/excepiton/LoginException.py b/pytyut/excepiton/LoginException.py
index 04e5f5a..5a19715 100644
--- a/pytyut/excepiton/LoginException.py
+++ b/pytyut/excepiton/LoginException.py
@@ -12,8 +12,6 @@ class LoginException(Exception):
def __init__(self, msg: str = "未知异常"):
self.msg = msg
- def get_msg(self):
- return self.msg
-
- def login_timeout(self):
- self.msg = "登录已失效"
+ @staticmethod
+ def login_timeout() -> "LoginException":
+ return LoginException("登录已失效")