@@ -50,10 +50,12 @@ def __init__(self, driver, menu_url, course_name, pattern=0, rate=1, out_fp=stdo
5050 #self._out_fp=open(course_name+'.txt', 'w+', encoding="utf-8") if SYSTEM==1 else stdout
5151
5252 def _setflag (self ):
53+ self ._err_lt = [] # 错误章节列表
5354 self ._chapter = 0
5455 self ._section = 0
5556 self ._subsection = 0
5657 self ._end = 0
58+ self ._que_server_flag = 0 #1正常 0异常
5759
5860 def work (self ):
5961 if self .pattern == 0 :
@@ -843,6 +845,21 @@ def _ans_question(self):
843845 # if(len(err_lt)==0):
844846 return 0
845847
848+ def _go_que_task (self ):
849+ try :
850+ err_section = self ._ans_question ()
851+
852+ if err_section != 0 :
853+ print (COLOR .ERR , 'unfinished!' , COLOR .END , file = self ._out_fp )
854+ self ._err_lt .append (err_section ) # 记录答题提交失败的章节
855+ else :
856+ print (COLOR .OK , 'finished!' , COLOR .END , file = self ._out_fp )
857+ except :
858+ try :
859+ send_err (traceback .format_exc ())
860+ except :
861+ pass
862+
846863 ##
847864 # brief 单课程自动模式
848865 # details 自动完成单课程下的任务(过程不需要输入),递归调用自身,未完成任务点为空时退出
@@ -856,7 +873,6 @@ def _perform_model0(self):
856873 return
857874 self ._out_fp .flush ()
858875
859- error_lt = [] # 错误章节列表
860876 last_time = time .time ()- 120 # 答题间隔控制,减少答题验证码的弹出
861877
862878 # 遍历每个未完成章节
@@ -883,19 +899,8 @@ def _perform_model0(self):
883899 sleep (120 - (now_time - last_time ))
884900 last_time = time .time ()
885901
886- try :
887- err_section = self ._ans_question ()
888-
889- if err_section != 0 :
890- print (COLOR .ERR , 'unfinished!' , COLOR .END , file = self ._out_fp )
891- error_lt .append (err_section ) # 记录答题提交失败的章节
892- else :
893- print (COLOR .OK , 'finished!' , COLOR .END , file = self ._out_fp )
894- except :
895- try :
896- send_err (traceback .format_exc ())
897- except :
898- pass
902+ if self ._que_server_flag == 1 :
903+ self ._go_que_task ()
899904
900905 if end_flag == 1 :
901906 print (COLOR .OK , 'finish the lesson! quit! ' , COLOR .END , file = self ._out_fp )
@@ -910,7 +915,6 @@ def _perform_model0(self):
910915 def _perform_model1 (self ):
911916 self ._g2p_chapter_section ()
912917
913- error_lt = []
914918 last_time = time .time ()- 300
915919 self ._chapter = eval (input (COLOR .NOTE + "please select which chapter:" + COLOR .END , file = self ._out_fp ))
916920 self ._section = eval (input (COLOR .NOTE + "please select which section:" + COLOR .END , file = self ._out_fp ))
@@ -927,12 +931,8 @@ def _perform_model1(self):
927931 last_time = time .time ()
928932 if self ._end == 2 :
929933 print (COLOR .OK , 'finish the lesson! quit! ' , COLOR .END , file = self ._out_fp )
930- err_section = self ._ans_question ()
931- if err_section != 0 :
932- print (COLOR .ERR , 'unfinished!' , COLOR .END , file = self ._out_fp )
933- error_lt .append (err_section ) # 记录答题提交失败的章节
934- else :
935- print (COLOR .OK , 'finished!' , COLOR .END , file = self ._out_fp )
934+ if self ._que_server_flag == 1 :
935+ self ._go_que_task ()
936936 self ._section += 1
937937 #log_fp.write("err_lt:" + str(error_lt) + '\n')
938938
@@ -948,7 +948,6 @@ def _perform_model2(self):
948948 subsection = eval (input ("please select which subsection(if not input 0):" ))
949949
950950 self ._out_fp .flush ()
951- error_lt = [] # 错误章节列表
952951 last_time = time .time ()- 150 # 答题间隔控制,减少答题验证码的弹出
953952
954953 # 遍历每个未完成章节
@@ -977,17 +976,6 @@ def _perform_model2(self):
977976 sleep (150 - (now_time - last_time ))
978977 last_time = time .time ()
979978
980- try :
981- err_section = self ._ans_question ()
982-
983- if err_section != 0 :
984- print (COLOR .ERR , 'unfinished!' , COLOR .END , file = self ._out_fp )
985- error_lt .append (err_section ) # 记录答题提交失败的章节
986- else :
987- print (COLOR .OK , 'finished!' , COLOR .END , file = self ._out_fp )
988- except :
989- try :
990- send_err (traceback .format_exc ())
991- except :
992- pass
979+ if self ._que_server_flag == 1 :
980+ self ._go_que_task ()
993981 #log_fp.write("err_lt:" + str(error_lt) + '\n')
0 commit comments