def __init__(self, path, hkey, auth=None, media=True, hostNum=None): QThread.__init__(self) self.path = path self.hkey = hkey self.auth = auth self.media = media self.hostNum = hostNum self._abort = 0 # 1=flagged, 2=aborting
def __init__(self, language): QThread.__init__(self) self.selLang = language self.term = False self.langShortCut = languages[self.selLang] self.GOOGLE_SEARCH_URL = "https://forvo.com/word/◳t/#" + self.langShortCut #◳r self.session = requests.session() self.session.headers.update({ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) \ Gecko/20100101 Firefox/10.0" })
def run(self): currentThread = QThread.currentThread() def __download(fileName, url): try: if currentThread.isInterruptionRequested(): return r = self.session.get(url, stream=True) if not path.exists(fileName) or path.getsize(fileName) != int(r.headers['Content-Length']): with open(fileName, 'wb') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) self.logger.info(f'{fileName} 下载完成') else: self.logger.info(f'{fileName} 跳过下载') except Exception as e: self.logger.warning(f'下载{fileName}:{url}异常: {e}') finally: self.tick.emit() with ThreadPool(max_workers=3) as executor: for fileName, url in self.audios: executor.submit(__download, fileName, url) self.done.emit()
def run(self): currentThread = QThread.currentThread() for row in self.api.getSentencesWithoutTranslate(): if currentThread.isInterruptionRequested(): return self.api.insertSentenceTranslates(row) self.tick.emit() self.done.emit()
def run(self): currentThread = QThread.currentThread() for row in self.api.getWordsWithoutExample(): if currentThread.isInterruptionRequested(): return self.api.insertWordExamples(row['id']) self.tick.emit() self.done.emit()
def run(self): currentThread = QThread.currentThread() for word in self.api.getAllWords(): if currentThread.isInterruptionRequested(): return self.api.insertWord(word) self.tick.emit() self.done.emit()
def __init__(self, manager, paths): QThread.__init__(self) self.manager = manager self.paths = paths self.index_builders = list()
def __init__(self): QThread.__init__(self) self.GOOGLE_SEARCH_URL = "https://www.google.com/search" self.term = False self.initSession()
def inMainThread(self): return self._mainThread == QThread.currentThread()
def setupThreads(self): self._mainThread = QThread.currentThread()
def __init__(self, code): QThread.__init__(self) self.code = code self.error = None
def __init__(self, mw): self.mw = mw QThread.__init__(self) self.server = MigakuHTTPServer(self, mw) self.start()
def __init__(self, main): QThread.__init__(self) self.main = main self.config = main.pm.meta
def __init__(self, lemma_query, query_kargs): QThread.__init__(self) self.lemma_query = lemma_query self.query_kargs = query_kargs