-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add(module): add skipper module * fix(module): move skip task out to skipper module * fix(docs): remove an entry of FAQ * fix(module): add function description * fix(module): add progress bar * fix(module): get code formatted * fix(module): change constant source * fix(module): remove unused imports
- Loading branch information
Showing
3 changed files
with
115 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
from src.core import Core | ||
|
||
import threading | ||
from time import sleep | ||
|
||
|
||
class skipper(threading.Thread): | ||
"""用于执行跳过课程任务的线程类""" | ||
|
||
def __init__(self, core: Core, sectionList: list) -> None: | ||
"""参数说明: | ||
*core* 功能内核对象,来自src.core | ||
*sectionList* 包含课程ID的字符串列表 | ||
""" | ||
threading.Thread.__init__(self) | ||
self.core = core | ||
self.sectionList = sectionList | ||
self.success = 0 | ||
self.fail = 0 | ||
self.state = False | ||
|
||
def run(self) -> None: | ||
print("skip thread started") | ||
self.skip(self.sectionList) | ||
|
||
def skip(self, sectionList: list) -> None: | ||
print("skip task started") | ||
for i in sectionList: | ||
result = self.core.skip_section(i) | ||
if result["code"] == 200: | ||
self.success += 1 | ||
else: | ||
self.fail += 1 | ||
# 对于任务列表长度为1的情况就没有必要sleep这么久了,只有长度超过1的才要分别sleep 31秒 | ||
if len(sectionList) != 1: | ||
sleep(31) | ||
# 跳出循环说明任务执行完成,修改状态标志位为True | ||
self.state = True | ||
|
||
def getState(self) -> bool: | ||
"""返回True说明任务执行完成,False为未完成""" | ||
return self.state |