Exemple #1
0
    def __call__(self):
        """ Example of tree_path: [
        [tree_path, type,tag_name,display_text,   icon_path]
        [[0, 0],    2, 'People', '<b>People</b>', '.../People'], 
        [[0, 0, 0], 3, 'toto',   'toto (0)',      '.../toto'],
        [[0, 1],    2, 'Places', '<b>Places</b>', '.../Places'],
        [[0, 2],    2, 'Events', '<b>Events</b>', '.../Events'], 
        [[0, 2, 0], 2, 'cat',    '<b>cat</b>',    '.../cat']
        ]"""

        jobs = self.worker.jobs

        try:
            if not self.tag_walker:
                log.info('Starting WebAlbums tagtree walk on {}'.format(self.collection.name))
                self.tag_walker = self._walk_tagtree()
                self.done = False
                
        except StopIteration:
            self.collection_walker = None
            log.error('Aborted directory walk on {}'.format(self.collection.name))
            return True

        while jobs.ishighestpriority(self) and not self.done:
            backend.idle_add(self.browser.update_backstatus, True, 'Scanning the tag tree')
            
            try:
                tag = self.tag_walker.next()
            except StopIteration:
                self.done = True
                break


            
            if tag is True:     
                self.tree_path_position.append(-1)
                continue
            elif tag is False:
                self.tree_path_position.pop()
                continue
            else:
                uid, name = tag
                
            self.tree_path_position[-1] += 1
            tree_path = []
            tree_path[:] = self.tree_path_position
                
            TYPE = 2
            ICON_PATH = None
                
            entry = (tree_path, TYPE, name, "<b>{}</b>".format(name), ICON_PATH)
            print("{} {}".format(entry[0], name))
            self.user_tag_info.append(entry)

        if self.done:
            self.tagframe.set_user_tags(self.user_tag_info)
        
            return True
        else:
            return False
Exemple #2
0
    def __call__(self):
        jobs = self.worker.jobs
        jobs.clear(None, self.collection, self)
        view = self.collection.get_active_view()
        collection = self.collection

        log.info('Loading collection file {} with type {}'.format(
            self.collection_file, collection.type))

        backend.idle_add(self.browser.update_backstatus, True,
                         'Loading Collection: {}'.format(self.collection_file))
        view.empty()

        pluginmanager.mgr.callback('t_view_emptied', collection, view)

        if collection._open():
            log.info('Collection opened {}'.format(collection.id))

            collection.online = True

            job = WalkWebAlbumThemeJob(self.worker, self.collection,
                                       self.browser)
            self.worker.queue_job_instance(job)

            pluginmanager.mgr.callback_collection('t_collection_loaded',
                                                  collection)

            if not view.loaded:
                self.worker.queue_job_instance(
                    backend.BuildViewJob(self.worker, self.collection,
                                         self.browser))
            else:
                pluginmanager.mgr.callback('t_view_updated', collection, view)

            backend.idle_add(self.worker.coll_set.collection_opened,
                             collection.id)

            log.info('Loaded collection with {} images'.format(
                len(collection)))
        else:
            log.error('Load collection failed {} {}'.format(
                collection.id, collection.type))

        self.collection_file = ''

        return True
Exemple #3
0
 def __call__(self):
     jobs = self.worker.jobs
     jobs.clear(None, self.collection, self)
     view = self.collection.get_active_view()
     collection = self.collection
     
     log.info('Loading collection file {} with type {}'.format(self.collection_file, collection.type))
     
     backend.idle_add(self.browser.update_backstatus, True, 'Loading Collection: {}'.format(self.collection_file))
     view.empty()
     
     pluginmanager.mgr.callback('t_view_emptied',collection,view)
     
     if collection._open():
         log.info('Collection opened {}'.format(collection.id))
         
         collection.online = True
         
         job = WalkWebAlbumThemeJob(self.worker, self.collection, self.browser)
         self.worker.queue_job_instance(job)
         
         pluginmanager.mgr.callback_collection('t_collection_loaded',collection)
         
         if not view.loaded:
             self.worker.queue_job_instance(backend.BuildViewJob(self.worker, self.collection, self.browser))
         else:
             pluginmanager.mgr.callback('t_view_updated', collection, view)
             
             
         backend.idle_add(self.worker.coll_set.collection_opened, collection.id)
             
         log.info('Loaded collection with {} images'.format(len(collection)))
     else:
         log.error('Load collection failed {} {}'.format(collection.id, collection.type))
         
     self.collection_file = ''
     
     return True
Exemple #4
0
    def __call__(self):
        """ Example of tree_path: [
        [tree_path, type,tag_name,display_text,   icon_path]
        [[0, 0],    2, 'People', '<b>People</b>', '.../People'], 
        [[0, 0, 0], 3, 'toto',   'toto (0)',      '.../toto'],
        [[0, 1],    2, 'Places', '<b>Places</b>', '.../Places'],
        [[0, 2],    2, 'Events', '<b>Events</b>', '.../Events'], 
        [[0, 2, 0], 2, 'cat',    '<b>cat</b>',    '.../cat']
        ]"""

        jobs = self.worker.jobs

        try:
            if not self.tag_walker:
                log.info('Starting WebAlbums tagtree walk on {}'.format(
                    self.collection.name))
                self.tag_walker = self._walk_tagtree()
                self.done = False

        except StopIteration:
            self.collection_walker = None
            log.error('Aborted directory walk on {}'.format(
                self.collection.name))
            return True

        while jobs.ishighestpriority(self) and not self.done:
            backend.idle_add(self.browser.update_backstatus, True,
                             'Scanning the tag tree')

            try:
                tag = self.tag_walker.next()
            except StopIteration:
                self.done = True
                break

            if tag is True:
                self.tree_path_position.append(-1)
                continue
            elif tag is False:
                self.tree_path_position.pop()
                continue
            else:
                uid, name = tag

            self.tree_path_position[-1] += 1
            tree_path = []
            tree_path[:] = self.tree_path_position

            TYPE = 2
            ICON_PATH = None

            entry = (tree_path, TYPE, name, "<b>{}</b>".format(name),
                     ICON_PATH)
            print("{} {}".format(entry[0], name))
            self.user_tag_info.append(entry)

        if self.done:
            self.tagframe.set_user_tags(self.user_tag_info)

            return True
        else:
            return False
Exemple #5
0
    def __call__(self):
        collection = self.collection
        jobs = self.worker.jobs
        self.last_update_time = time.time()
        try:
            if not self.collection_walker:
                log.info('Starting WebAlbums theme walk on {}'.format(collection.name))
                self.collection_walker = self._walk_albums()
                self.done = False
                pluginmanager.mgr.suspend_collection_events(self.collection)
                
        except StopIteration:
            self.notify_items = []
            self.collection_walker = None
            log.error('Aborted directory walk on {}'.format(collection.name))
            return True

        while jobs.ishighestpriority(self) and not self.done:

            backend.idle_add(self.browser.update_backstatus, True, 'Scanning for new images')
            
            while jobs.ishighestpriority(self):
                try:
                    photo = self.collection_walker.next()
                except StopIteration:
                    self.done = True
                    break
                
                #import_pdb_set_trace()
                
                try:
                    if photo.find("details").get("isGpx") == "true":
                        continue
                except Exception as e:
                    log.warn(e)
                    pass

                path = photo.find("details").find("photoId").text
                
                fullpath = "{}/images/{}".format(ROOT, path)
                
                item = baseobjects.Item(fullpath)
                
                if collection.find(item) < 0:
                    # if collection.load_meta:
                    #     collection.load_metadata(item, notify_plugins=False)
                    # elif collection.load_preview_icons:
                    #     collection.load_thumbnail(item)
                    #     if not item.thumb:
                    #         item.thumb = False
                            
                    item.mtime = io.get_mtime(fullpath)
                    
                    self.browser.lock.acquire()
                    collection.add(item)
                    self.browser.lock.release()
                    
                    backend.idle_add(self.browser.resize_and_refresh_view, self.collection)
                        
            # once we have found enough items, add to collection and notify browser
            if time.time() > self.last_update_time+1.0 or len(self.notify_items) > 100:
                self.last_update_time = time.time()
                
                self.browser.lock.acquire()
                for item in self.notify_items:
                    collection.add(item, False)
                    
                self.browser.lock.release()
                
                backend.idle_add(self.browser.resize_and_refresh_view, self.collection)
                self.notify_items = []
                
        if not self.done:
            return False
    
        log.info('Directory walk complete for {}'.format(collection))
            
        backend.idle_add(self.browser.resize_and_refresh_view, self.collection)
        backend.idle_add(self.browser.update_backstatus, False, 'Search complete')
                            
        self.notify_items = []
        self.collection_walker = None
        self.done = False
            
        pluginmanager.mgr.resume_collection_events(self.collection)
        
        return True
Exemple #6
0
    def __call__(self):
        collection = self.collection
        jobs = self.worker.jobs
        self.last_update_time = time.time()
        try:
            if not self.collection_walker:
                log.info('Starting WebAlbums theme walk on {}'.format(
                    collection.name))
                self.collection_walker = self._walk_albums()
                self.done = False
                pluginmanager.mgr.suspend_collection_events(self.collection)

        except StopIteration:
            self.notify_items = []
            self.collection_walker = None
            log.error('Aborted directory walk on {}'.format(collection.name))
            return True

        while jobs.ishighestpriority(self) and not self.done:

            backend.idle_add(self.browser.update_backstatus, True,
                             'Scanning for new images')

            while jobs.ishighestpriority(self):
                try:
                    photo = self.collection_walker.next()
                except StopIteration:
                    self.done = True
                    break

                #import_pdb_set_trace()

                try:
                    if photo.find("details").get("isGpx") == "true":
                        continue
                except Exception as e:
                    log.warn(e)
                    pass

                path = photo.find("details").find("photoId").text

                fullpath = "{}/images/{}".format(ROOT, path)

                item = baseobjects.Item(fullpath)

                if collection.find(item) < 0:
                    # if collection.load_meta:
                    #     collection.load_metadata(item, notify_plugins=False)
                    # elif collection.load_preview_icons:
                    #     collection.load_thumbnail(item)
                    #     if not item.thumb:
                    #         item.thumb = False

                    item.mtime = io.get_mtime(fullpath)

                    self.browser.lock.acquire()
                    collection.add(item)
                    self.browser.lock.release()

                    backend.idle_add(self.browser.resize_and_refresh_view,
                                     self.collection)

            # once we have found enough items, add to collection and notify browser
            if time.time() > self.last_update_time + 1.0 or len(
                    self.notify_items) > 100:
                self.last_update_time = time.time()

                self.browser.lock.acquire()
                for item in self.notify_items:
                    collection.add(item, False)

                self.browser.lock.release()

                backend.idle_add(self.browser.resize_and_refresh_view,
                                 self.collection)
                self.notify_items = []

        if not self.done:
            return False

        log.info('Directory walk complete for {}'.format(collection))

        backend.idle_add(self.browser.resize_and_refresh_view, self.collection)
        backend.idle_add(self.browser.update_backstatus, False,
                         'Search complete')

        self.notify_items = []
        self.collection_walker = None
        self.done = False

        pluginmanager.mgr.resume_collection_events(self.collection)

        return True