Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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"
     })
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
 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()
Ejemplo n.º 9
0
 def inMainThread(self):
     return self._mainThread == QThread.currentThread()
Ejemplo n.º 10
0
 def setupThreads(self):
     self._mainThread = QThread.currentThread()
Ejemplo n.º 11
0
 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()
Ejemplo n.º 13
0
 def __init__(self, main):
     QThread.__init__(self)
     self.main = main
     self.config = main.pm.meta
Ejemplo n.º 14
0
 def __init__(self, lemma_query, query_kargs):
     QThread.__init__(self)
     self.lemma_query = lemma_query
     self.query_kargs = query_kargs