diff --git a/GUI.py b/GUI.py index 097f2f5..859e8b2 100644 --- a/GUI.py +++ b/GUI.py @@ -2,6 +2,9 @@ # -*- coding: utf-8 -*- """ GUI + +bug: + stuID未能显示;没有对输入情况进行判断。 """ import tkinter as tk import tkinter.messagebox @@ -200,8 +203,3 @@ def outputAs_all(): command=outputAs_all).place(x=30, y=300) window.mainloop() - -''' -bug: - stuID未能显示 -''' diff --git a/__init__.py b/__init__.py index 3cc5de0..1ebd81f 100644 --- a/__init__.py +++ b/__init__.py @@ -8,7 +8,7 @@ Pull Requests & issues welcome! @Author: MiaoTony, ZegWe, Cooook, Pinyi Qian -@UpdateLog: Please refer to `CHANGELOG.md`. +@ChangeLog: Please refer to `CHANGELOG.md`. """ diff --git a/generateICS.py b/generateICS.py index 5739f5d..3965c8d 100644 --- a/generateICS.py +++ b/generateICS.py @@ -92,8 +92,7 @@ def create_ics(lessons, semester_start_date): try: event.add('description', lesson.output_description(week=week)) except UnicodeDecodeError: - print("ERROR!") - exit(6) # 放弃python2.x了 + raise Exception("ERROR!") # 放弃python2.x了 cal.add_component(event) return cal @@ -136,7 +135,7 @@ def export_ics(cal, semester_year, semester, stuID): tem_path = os.path.abspath(tem.name) tem.write(cal.to_ical()) tem_filename = tem.name - tem.read() # fix a py2.7 bug... issue#2 + tem.read() # fix a py2.7 bug... tem.close() # print(getsizeof(tem.read())) is_update = not is_same(tem_path, filename) diff --git a/generateXLSX.py b/generateXLSX.py index 93c7801..c94dd86 100644 --- a/generateXLSX.py +++ b/generateXLSX.py @@ -34,13 +34,13 @@ def create_xls(lessons, semester_year, semester, stuID): sheet.column_dimensions['A'].width = 3 sheet.row_dimensions[1].height = 20 sheet.row_dimensions[2].height = 20 - # print('1\n') + for i in range(1, 12): sheet.cell(i + 2, 1, i).alignment = alignment sheet.row_dimensions[i + 2].height = 60 weekday = ['一', '二', '三', '四', '五', '六', '天'] ab = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'] - # print('2\n') + for i in range(0, 7): sheet.cell(2, i + 2, '星期' + weekday[i]).alignment = alignment sheet.column_dimensions[ab[i + 1]].width = 20 diff --git a/getClassSchedule.py b/getClassSchedule.py index 454f09d..a21390e 100644 --- a/getClassSchedule.py +++ b/getClassSchedule.py @@ -81,29 +81,28 @@ def aao_login(stuID, stuPwd, captcha_str, retry_cnt=1): logging.debug(r2.text) temp_key = temp_token_match.search(r2.text) if temp_key: # 找到密钥说明没有登录成功,需要重试 - print("ID, Password or Captcha ERROR! Login ERROR!\n") + # print("ID, Password or Captcha ERROR! Login ERROR!\n") temp_key = temp_key.group(1) logging.debug(temp_key) - exit(2) + raise Exception("ID, Password or Captcha ERROR! Login ERROR!") elif re.search(r"ui-state-error", r2.text): # 过快点击 print("ERROR! 请不要过快点击!\n") time.sleep(1) try_cnt += 1 # session.headers["User-Agent"] = UAs[1] # random.randint(0, len(UAs)-1) # 换UA也不行 - # exit(3) else: temp_soup = BeautifulSoup(r2.text.encode('utf-8'), 'lxml') name = temp_soup.find('a', class_='personal-name').string.strip() print("Login OK!\nHello, {}!".format(name)) return name else: - print("Login ERROR!\n") - exit(1) + # print("Login ERROR!\n") + raise Exception("Login ERROR!") else: - print('Search token ERROR!\n') - exit(1) - print("ERROR! 过一会儿再试试吧...\n") - exit(3) + # print('Search token ERROR!\n') + raise Exception("Search token ERROR!") + # print("ERROR! 过一会儿再试试吧...\n") + raise Exception("ERROR! 过一会儿再试试吧...") def getCourseTable(choice=0): @@ -154,8 +153,8 @@ def getCourseTable(choice=0): # logging.debug(session.cookies.get_dict()) return courseTable else: - print("Get ids ERROR!") - exit(4) + # print("Get ids ERROR!") + raise Exception("Get ids ERROR!") def parseCourseTable(courseTable): diff --git a/main.py b/main.py index b54fd95..20f94a3 100644 --- a/main.py +++ b/main.py @@ -80,7 +80,7 @@ # stuPwd = input('Please input your password:') stuPwd = getpass('Please input your password:(不会回显,输入完成即可)') - # Captcha 验证码 # Fix Issue #13 bug, but only for Windows & MacOS. + # Captcha 验证码 # Fix Issue #13 bug. captcha_resp = session.get(host + '/eams/captcha/image.action') # Captcha 验证码图片 img_path = os.path.join(os.getcwd(), 'captcha.jpg') with open(img_path, 'wb') as captcha_fp: @@ -95,6 +95,7 @@ os.startfile(img_path) except: from PIL import Image + # captcha_img = Image.open(BytesIO(captcha_resp.content)) captcha_img = Image.open(img_path) captcha_img.show() # show the captcha @@ -138,7 +139,7 @@ print("Thanks for your use! 欢迎来GitHub上点个Star呢!") except Exception as e: - print("ERROR! 欢迎在GitHub上提出issue & Pull Request!") + print("ERROR! 如果遇到技术问题,欢迎在GitHub上提出issue & Pull Request!") print(e) finally: session.cookies.clear() # 清一下cookie diff --git a/settings.py b/settings.py index 612198e..4a280d6 100644 --- a/settings.py +++ b/settings.py @@ -8,4 +8,4 @@ DEBUG = False -VERSION = "V0.15.1.20200520" +VERSION = "V0.15.2.20200520"