Beispiel #1
0
    def run(self):
        L.d("running")
        self.stopvar = False
        rex = re.compile(".*\[(\d{7})\]$")
        imdb_db = imdb.IMDb()
        db = get_user_db()
        tp = QThreadPool.globalInstance()
        writer = IndexWriter()
        count = 0

        it = QDirIterator(self.media_path, QDirIterator.Subdirectories)
        while it.hasNext():
            dir = it.next()
            try:
                directory = unicode(dir)
                match = rex.match(directory)
                if match:
                    count += 1
                    imdb_id = match.group(1)
                    movie = db.get_doc(imdb_id)
                    if movie:
                        L.d("%s already in db - skipping" % imdb_id)
                    else:
                        j = Job(imdb_db, imdb_id, self)
                        j.obj.finished.connect(writer.index_movie,
                                               Qt.QueuedConnection)
                        tp.start(j)
            except:
                pass
        print count
        self.exec_()
Beispiel #2
0
 def sync(self):
     self.index_thread = IndexThread(MOVIE_DIR)
     print self.index_thread.finished.connect(self._indexer_closed)
     print self.shutmedown.connect(self.index_thread.set_stopped,
                                   Qt.QueuedConnection)
     self.index_thread.start()
     L.d("syncer started")
Beispiel #3
0
    def run(self):
        L.d("running")
        self.stopvar = False
        rex = re.compile(".*\[(\d{7})\]$")
        imdb_db = imdb.IMDb()
        db = get_user_db()
        tp = QThreadPool.globalInstance()
        writer = IndexWriter()
        count = 0

        it = QDirIterator(self.media_path, QDirIterator.Subdirectories)
        while it.hasNext():
            dir = it.next()
            try:
                directory = unicode(dir)
                match = rex.match(directory)
                if match:
                    count += 1
                    imdb_id = match.group(1)
                    movie = db.get_doc(imdb_id)
                    if movie:
                        L.d("%s already in db - skipping" % imdb_id)
                    else:
                        j = Job(imdb_db, imdb_id, self) 
                        j.obj.finished.connect(writer.index_movie,
                                Qt.QueuedConnection)
                        tp.start(j) 
            except:
                pass
        print count
        self.exec_()
Beispiel #4
0
 def sync(self):
     self.index_thread = IndexThread(MOVIE_DIR)
     print self.index_thread.finished.connect(self._indexer_closed)
     print self.shutmedown.connect(self.index_thread.set_stopped,
             Qt.QueuedConnection)
     self.index_thread.start()
     L.d("syncer started")
Beispiel #5
0
 def really_close(self):
     #L.d("stopping indexer thread")
     #self.index_thread.quit()
     #L.d("waiting for threadpool to be done...")
     #from PySide.QtCore import QThreadPool
     #tp = QThreadPool.globalInstance()
     #tp.waitForDone()
     L.d("Threadpool done")
     self.close()
Beispiel #6
0
 def really_close(self):
     #L.d("stopping indexer thread")
     #self.index_thread.quit()
     #L.d("waiting for threadpool to be done...")
     #from PySide.QtCore import QThreadPool
     #tp = QThreadPool.globalInstance()
     #tp.waitForDone()
     L.d("Threadpool done")
     self.close()
Beispiel #7
0
    def run(self):
        if self.thread.stopvar:
            # threadpool already stopped - do nothing
            return

        L.d("fetching %s ..." % self.imdb_id)
        movie = self.imdb_db.get_movie(self.imdb_id)
        nm = normalize(movie)
        nm['_id'] = str(self.imdb_id)

        self.obj.finished.emit(nm)
Beispiel #8
0
    def run(self): 
        if self.thread.stopvar:
            # threadpool already stopped - do nothing
            return

        L.d( "fetching %s ..." % self.imdb_id)
        movie = self.imdb_db.get_movie(self.imdb_id)
        nm = normalize(movie)
        nm['_id'] = str(self.imdb_id)

        self.obj.finished.emit(nm)
Beispiel #9
0
 def closeEvent(self, event):
     L.d("shutdown requested")
     L.d("hiding window")
     self.setVisible(False)
     if self.index_thread and self.index_thread.isRunning():
         event.ignore()
         L.d("setting quit")
         self._shutdown_requested = True
         self.index_thread.set_stopped()
         #self.shutmedown.emit()
         #QTimer.singleShot(10, self.really_close)
     else:
         L.d("goodby")
         event.accept()
Beispiel #10
0
 def closeEvent(self, event):
     L.d("shutdown requested")
     L.d("hiding window")
     self.setVisible(False)
     if self.index_thread and self.index_thread.isRunning():
         event.ignore()
         L.d("setting quit")
         self._shutdown_requested = True
         self.index_thread.set_stopped()
         #self.shutmedown.emit()
         #QTimer.singleShot(10, self.really_close)
     else:
         L.d("goodby")
         event.accept()
Beispiel #11
0
 def _indexer_closed(self):
     L.d("indexer finished")
     if self._shutdown_requested:
         self.close()
Beispiel #12
0
 def index_movie(self, movie):
     self.index.index_movie(movie)
     self.db.create_doc(json.dumps(movie), doc_id=movie["_id"])
     L.d("%s finished" % movie['title'])
Beispiel #13
0
 def _shutdown(self):
     tp = QThreadPool.globalInstance()
     L.d("waiting for threadpool to be done...")
     tp.waitForDone()
     self.quit()
Beispiel #14
0
 def index_movie(self, movie):
     self.index.index_movie(movie)
     self.db.create_doc(json.dumps(movie), doc_id=movie["_id"])
     L.d("%s finished" % movie['title'])
Beispiel #15
0
 def _shutdown(self):
     tp = QThreadPool.globalInstance()
     L.d("waiting for threadpool to be done...")
     tp.waitForDone()
     self.quit()
Beispiel #16
0
 def set_stopped(self):
     L.d("setting stopvar")
     self.stopvar = True
     QTimer.singleShot(10, self._shutdown)
Beispiel #17
0
 def set_stopped(self):
     L.d("setting stopvar")
     self.stopvar = True
     QTimer.singleShot(10, self._shutdown)
Beispiel #18
0
 def _indexer_closed(self):
     L.d("indexer finished")
     if self._shutdown_requested:
         self.close()