コード例 #1
0
    def update(self):
        """
        update the bar according to showstatus
        """
        if self.status == BAR_SHOW:
            if skin.active():
                skin.redraw()

        elif self.status == BAR_IDLE:
            self.status = self.timer()
            if self.status == BAR_HIDE:
                self.hide()
            if skin.active():
                skin.redraw()
コード例 #2
0
ファイル: __init__.py プロジェクト: adozenlines/freevo1
 def poll(self):
     """
     update the idlebar every 30 secs even if nothing happens
     """
     logger.log( 9, 'PluginInterface.poll()')
     if skin.active():
         skin.redraw()
コード例 #3
0
ファイル: __init__.py プロジェクト: spartrekus/freevo1
 def poll(self):
     """
     update the idlebar every 30 secs even if nothing happens
     """
     logger.log(9, 'PluginInterface.poll()')
     if skin.active():
         skin.redraw()
コード例 #4
0
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     if plugin.isevent(event) == 'IDENTIFY_MEDIA' and skin.active():
         skin.redraw()
     return False
コード例 #5
0
ファイル: __init__.py プロジェクト: adozenlines/freevo1
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     logger.log( 9, 'PluginInterface.eventhandler(event=%r, menuw=%r)', event, menuw)
     if skin.active() and plugin.isevent(event) == 'IDENTIFY_MEDIA':
         skin.redraw()
     return False
コード例 #6
0
ファイル: __init__.py プロジェクト: spartrekus/freevo1
 def eventhandler(self, event, menuw=None):
     """
     catch the IDENTIFY_MEDIA event to redraw the skin (maybe the cd status
     plugin wants to redraw)
     """
     logger.log(9, 'PluginInterface.eventhandler(event=%r, menuw=%r)',
                event, menuw)
     if skin.active() and plugin.isevent(event) == 'IDENTIFY_MEDIA':
         skin.redraw()
     return False
コード例 #7
0
ファイル: encoding.py プロジェクト: adozenlines/freevo1
    def poll(self):
        '''poll function'''
        now = time.time()
        pollduration = now - self.lastpoll
        drawduration = now - self.lastdraw
        self.lastpoll = now
        logger.log( 9, "poll(self): poll=%.2f, draw=%.2f, interval=%s, state=%s", pollduration, drawduration, self.draw_interval, self.state)

        if drawduration >= self.draw_interval / 100:
            if skin.active():
                skin.redraw()
コード例 #8
0
ファイル: transcode.py プロジェクト: adozenlines/freevo1
    def _timerhandler(self):
        """poll function"""
        now = time.time()
        pollduration = now - self.lastpoll
        drawduration = now - self.lastdraw
        self.lastpoll = now
        logger.log( 9, "_timerhandler(): poll=%.2f, draw=%.2f, interval=%s, state=%s", pollduration, drawduration, self.draw_interval, self.state)

        if drawduration >= self.draw_interval:
            if skin.active():
                skin.redraw()
コード例 #9
0
ファイル: encoding.py プロジェクト: 1147279/SoftwareProject
 def poll(self):
     '''poll function'''
     now = time.time()
     pollduration = now - self.lastpoll
     drawduration = now - self.lastdraw
     self.lastpoll = now
     _debug_("poll(self): poll=%.2f, draw=%.2f, interval=%s, state=%s" % \
         (pollduration, drawduration, self.draw_interval, self.state), 2)
     if drawduration >= self.draw_interval / 100:
         if skin.active():
             skin.redraw()
コード例 #10
0
ファイル: transcode.py プロジェクト: spartrekus/freevo1
    def _timerhandler(self):
        """poll function"""
        now = time.time()
        pollduration = now - self.lastpoll
        drawduration = now - self.lastdraw
        self.lastpoll = now
        logger.log(
            9, "_timerhandler(): poll=%.2f, draw=%.2f, interval=%s, state=%s",
            pollduration, drawduration, self.draw_interval, self.state)

        if drawduration >= self.draw_interval:
            if skin.active():
                skin.redraw()
コード例 #11
0
ファイル: rom_drives.py プロジェクト: adozenlines/freevo1
 def check_all(self):
     """ Check all drives """
     if not skin.active():
         # Some app is running, do not scan, it's not necessary
         return
     self.lock.acquire()
     try:
         for media in config.REMOVABLE_MEDIA:
             self.identify(media)
             if media.get_drive_status_changed():
                 logger.debug('posting IDENTIFY_MEDIA event %r', media.drive_status_text(media.drive_status))
                 rc.post_event(plugin.event('IDENTIFY_MEDIA', arg=(media, media.drive_status)))
     finally:
         self.lock.release()
コード例 #12
0
ファイル: rom_drives.py プロジェクト: spartrekus/freevo1
 def check_all(self):
     """ Check all drives """
     if not skin.active():
         # Some app is running, do not scan, it's not necessary
         return
     self.lock.acquire()
     try:
         for media in config.REMOVABLE_MEDIA:
             self.identify(media)
             if media.get_drive_status_changed():
                 logger.debug('posting IDENTIFY_MEDIA event %r',
                              media.drive_status_text(media.drive_status))
                 rc.post_event(
                     plugin.event('IDENTIFY_MEDIA',
                                  arg=(media, media.drive_status)))
     finally:
         self.lock.release()
コード例 #13
0
ファイル: __init__.py プロジェクト: adozenlines/freevo1
    def start_saver(self):
        logger.log( 9, 'start_saver()')
        if self.screensaver_showing or not skin.active():
            return
        self.screensaver_showing = True
        if self.plugins is None:
            self.plugins = plugin.get('screensaver')
            logger.debug('plugins=%r', self.plugins)

        osd.screensaver_running = True
        skin.clear()
        self.current_saver = None
        self.index = 0
        plugins_count = len(self.plugins)
        logger.debug('found %s screensaver(s)', plugins_count)
        if config.SCREENSAVER_SCREEN_OFF_DELAY:
            logger.debug('Enabling DPMS timer')
            self.dpms_timer.start(config.SCREENSAVER_SCREEN_OFF_DELAY)
        self.__next()
コード例 #14
0
    def build(self, arg=None, menuw=None):
        """
        build the items for the directory
        """
        self.menuw = menuw
        self.playlist = []
        self.play_items = []
        self.dir_items = []
        self.pl_items = []

        if self.media:
            self.media.mount()

        if hasattr(self, '__dirwatcher_last_time__'):
            del self.__dirwatcher_last_time__

        if arg == 'update':
            if not self.menu.choices:
                selected_pos = -1
            else:
                # store the current selected item
                selected_id = self.menu.selected.id()
                selected_pos = self.menu.choices.index(self.menu.selected)
            if hasattr(self.menu, 'skin_default_has_description'):
                del self.menu.skin_default_has_description
            if hasattr(self.menu, 'skin_default_no_images'):
                del self.menu.skin_default_no_images
            if hasattr(self.menu, 'skin_force_text_view'):
                del self.menu.skin_force_text_view
        elif not os.path.exists(self.dir):
            AlertBox(text=_('Directory does not exist')).show()
            return

        display_type = self.display_type
        if self.display_type == 'tv':
            display_type = 'video'

        if arg and arg.startswith('playlist:'):
            if arg.endswith(':random'):
                Playlist(playlist=[(self.dir, 0)],
                         parent=self,
                         display_type=display_type,
                         random=True).play(menuw=menuw)
            elif arg.endswith(':recursive'):
                Playlist(playlist=[(self.dir, 1)],
                         parent=self,
                         display_type=display_type,
                         random=False).play(menuw=menuw)
            elif arg.endswith(':random_recursive'):
                Playlist(playlist=[(self.dir, 1)],
                         parent=self,
                         display_type=display_type,
                         random=True).play(menuw=menuw)
            return

        if config.OSD_BUSYICON_TIMER:
            osd.get_singleton().busyicon.wait(config.OSD_BUSYICON_TIMER[0])

        files = vfs.listdir(self.dir, include_overlay=True)
        num_changes = mediainfo.check_cache(self.dir)

        pop = None
        callback = None
        if skin.active():
            if (num_changes > 10) or (num_changes and self.media):
                if self.media:
                    pop = ProgressBox(text=_('Scanning disc, be patient...'),
                                      full=num_changes)
                else:
                    pop = ProgressBox(
                        text=_('Scanning directory, be patient...'),
                        full=num_changes)
                pop.show()
                callback = pop.tick

        elif config.OSD_BUSYICON_TIMER and len(
                files) > config.OSD_BUSYICON_TIMER[1]:
            # many files, just show the busy icon now
            osd.get_singleton().busyicon.wait(0)

        if num_changes > 0:
            mediainfo.cache_dir(self.dir, callback=callback)

        #
        # build items
        #
        # build play_items, pl_items and dir_items
        for p in plugin.mimetype(display_type):
            for i in p.get(self, files):
                if i.type == 'playlist':
                    self.pl_items.append(i)
                elif i.type == 'dir':
                    self.dir_items.append(i)
                else:
                    self.play_items.append(i)

        # normal DirItems
        for filename in files:
            if os.path.isdir(filename):
                d = DirItem(filename, self, display_type=self.display_type)
                self.dir_items.append(d)

        # remove same beginning from all play_items
        if self.DIRECTORY_SMART_NAMES:
            substr = ''
            if len(self.play_items) > 4 and len(self.play_items[0].name) > 5:
                substr = self.play_items[0].name[:-5].lower()
                for i in self.play_items[1:]:
                    if len(i.name) > 5:
                        substr = util.find_start_string(i.name.lower(), substr)
                        if not substr or len(substr) < 10:
                            break
                    else:
                        break
                else:
                    for i in self.play_items:
                        i.name = util.remove_start_string(i.name, substr)

        #
        # sort all items
        #

        # sort directories
        if self.DIRECTORY_SMART_SORT:
            self.dir_items.sort(lambda l, o: util.smartsort(l.dir, o.dir))
        else:
            self.dir_items.sort(lambda l, o: cmp(l.dir.upper(), o.dir.upper()))

        # sort playlist
        self.pl_items.sort(lambda l, o: cmp(l.name.upper(), o.name.upper()))

        # sort normal items
        if self.DIRECTORY_SORT_BY_DATE:
            self.play_items.sort(lambda l, o: cmp(
                l.sort('date').upper(),
                o.sort('date').upper()))
        elif self['%s_advanced_sort' % display_type]:
            self.play_items.sort(lambda l, o: cmp(
                l.sort('advanced').upper(),
                o.sort('advanced').upper()))
        else:
            self.play_items.sort(lambda l, o: cmp(l.sort().upper(),
                                                  o.sort().upper()))

        if self['num_dir_items'] != len(self.dir_items):
            self['num_dir_items'] = len(self.dir_items)

        if self['num_%s_items' %
                display_type] != len(self.play_items) + len(self.pl_items):
            self['num_%s_items' %
                 display_type] = len(self.play_items) + len(self.pl_items)

        if self.DIRECTORY_REVERSE_SORT:
            self.dir_items.reverse()
            self.play_items.reverse()
            self.pl_items.reverse()

        # delete pl_items if they should not be displayed
        if self.display_type and not self.display_type in self.DIRECTORY_ADD_PLAYLIST_FILES:
            self.pl_items = []

        # add all playable items to the playlist of the directory
        # to play one files after the other
        if not self.display_type or self.display_type in self.DIRECTORY_CREATE_PLAYLIST:
            self.playlist = self.play_items

        # build a list of all items
        items = self.dir_items + self.pl_items + self.play_items

        # random playlist (only active for audio)
        if self.display_type and self.display_type in self.DIRECTORY_ADD_RANDOM_PLAYLIST \
               and len(self.play_items) > 1:
            pl = Playlist(_('Random playlist'),
                          self.play_items,
                          self,
                          random=True)
            pl.autoplay = True
            items = [pl] + items

        if pop:
            pop.destroy()
            # closing the poup will rebuild the menu which may umount
            # the drive
            if self.media:
                self.media.mount()

        if config.OSD_BUSYICON_TIMER:
            # stop the timer. If the icons is drawn, it will stay there
            # until the osd is redrawn, if not, we don't need it to pop
            # up the next milliseconds
            osd.get_singleton().busyicon.stop()

        #
        # action
        #

        if arg == 'update':
            # update because of dirwatcher changes
            self.menu.choices = items

            if selected_pos != -1:
                for i in items:
                    if Unicode(i.id()) == Unicode(selected_id):
                        self.menu.selected = i
                        break
                else:
                    # item is gone now, try to the selection close
                    # to the old item
                    pos = max(0, min(selected_pos - 1, len(items) - 1))
                    if items:
                        self.menu.selected = items[pos]
                    else:
                        self.menu.selected = None
            if self.menuw:
                if self.menu.selected and selected_pos != -1:
                    self.menuw.rebuild_page()
                else:
                    self.menuw.init_page()
                self.menuw.refresh()


        elif len(items) == 1 and items[0].actions() and \
                 self.DIRECTORY_AUTOPLAY_SINGLE_ITEM:
            # autoplay
            items[0].actions()[0][0](menuw=menuw)

        elif arg == 'play' and self.play_items:
            # called by play function
            self.playlist = self.play_items
            Playlist.play(self, menuw=menuw)

        else:
            # normal menu build
            item_menu = menu.Menu(
                self.name,
                items,
                reload_func=self.reload,
                item_types=self.skin_display_type,
                force_skin_layout=self.DIRECTORY_FORCE_SKIN_LAYOUT)

            if self.skin_fxd:
                item_menu.skin_settings = skin.load(self.skin_fxd)

            menuw.pushmenu(item_menu)

            dirwatcher.cwd(menuw, self, item_menu, self.dir)
            self.menu = item_menu
            self.menuw = menuw
コード例 #15
0
ファイル: plugin.py プロジェクト: adozenlines/freevo1
 def poll_wrapper(self):
     import skin
     if self.poll_menu_only and not skin.active():
         return
     self.poll()
コード例 #16
0
ファイル: archive.py プロジェクト: spartrekus/freevo1
    def build(self, arg=None, menuw=None):
        """
        build the items for the archive
        """
        logger.log(9, 'build(arg=%r, menuw=%r)', arg, menuw)
        osd.get_singleton().busyicon.wait(config.OSD_BUSYICON_TIMER[0])
        archive = None

        try:
            if zipfile.is_zipfile(self.archive):
                archive = zipfile.ZipFile(self.archive, 'r')
                files = archive.infolist()

            elif tarfile.is_tarfile(self.archive):
                archive = tarfile.open(self.archive, 'r')
                files = archive.getmembers()

            elif ARCHIVE_RAR_AVAILABLE and rarfile.is_rarfile(self.archive):
                archive = rarfile.RarFile(self.archive, 'r')
                files = archive.infolist()

            else:
                # fallback, nothing to do, not an archive
                super(DirItem, self).build(arg, menuw)
                return

        except (ZipError, RarError, TarError) as exc:
            _debug_('Archive %s error: %s' % (self.archive, exc), 1)
            self.valid = False
            osd.get_singleton().busyicon.stop()
            DirItem.build(self, arg, menuw)
            return

        # display the msg box
        pop = None
        to_extract = 0

        xfiles = []
        for f in files:
            logger.debug('testing for %s',
                         os.path.join(self.dir, get_filename(f)))
            if not os.path.exists(os.path.join(self.dir, get_filename(f))):
                logger.debug('%s not found, will extract',
                             os.path.join(self.dir, get_filename(f)))
                xfiles.append(f)

        if len(xfiles) > 8 and skin.active():
            pop = CacheProgressDialog(
                _('Extracting from archive, be patient...'), len(xfiles))
            pop.show()

        elif len(xfiles) > config.OSD_BUSYICON_TIMER[1]:
            # many files, just show the busy icon now
            osd.get_singleton().busyicon.wait(0)

        # extract one file at the time, bump the progress bar for each file extracted
        for f in xfiles:
            archive.extract(f, self.dir)
            if pop:
                pop.processed_file()

        # get rid of the msg box
        if pop:
            pop.hide()

        # stop the timer. If the icons is drawn, it will stay there
        # until the osd is redrawn, if not, we don't need it to pop
        # up the next milliseconds
        osd.get_singleton().busyicon.stop()

        exclude = ''

        if self.cover:
            # we do not want to include the cover img we just created
            # we store original config.IMAGE_EXCLUDE first, then set it to cover
            exclude = config.IMAGE_EXCLUDE
            config.IMAGE_EXCLUDE = ['cover']

        # now we let the base class handle the tmp directory
        DirItem.build(self, arg, menuw)

        if self.cover:
            # and now we restore original cover.IMAGE_RESTORE
            config.IMAGE_EXCLUDE = exclude
コード例 #17
0
ファイル: plugin.py プロジェクト: spartrekus/freevo1
 def poll_wrapper(self):
     import skin
     if self.poll_menu_only and not skin.active():
         return
     self.poll()
コード例 #18
0
ファイル: archive.py プロジェクト: golaizola/freevo1
    def build(self, arg=None, menuw=None):
        """
        build the items for the archive
        """
        logger.log(9, 'build(arg=%r, menuw=%r)', arg, menuw)
        osd.get_singleton().busyicon.wait(config.OSD_BUSYICON_TIMER[0])
        archive = None
        
        try:
            if zipfile.is_zipfile(self.archive):
                archive = zipfile.ZipFile(self.archive, 'r')
                files   = archive.infolist()

            elif tarfile.is_tarfile(self.archive):
                archive = tarfile.open(self.archive, 'r')
                files   = archive.getmembers()
                
            elif ARCHIVE_RAR_AVAILABLE and rarfile.is_rarfile(self.archive):
                archive = rarfile.RarFile(self.archive, 'r')
                files   = archive.infolist()

            else:
                # fallback, nothing to do, not an archive
                super(DirItem, self).build(arg, menuw)
                return

        except (ZipError, RarError, TarError) as exc:
            logger.warning('Archive %s error: %s', self.archive, exc)
            self.valid = False
            osd.get_singleton().busyicon.stop()
            DirItem.build(self, arg, menuw)
            return

        # display the msg box
        pop = None
        to_extract = 0
        
        xfiles = []
        for f in files:
            logger.debug('testing for %s', os.path.join(self.dir, get_filename(f)))
            if not os.path.exists(os.path.join(self.dir, get_filename(f))):
                logger.debug('%s not found, will extract', os.path.join(self.dir, get_filename(f)))
                xfiles.append(f)
        
        if len(xfiles) > 8 and skin.active():
            pop = CacheProgressDialog(_('Extracting from archive, be patient...'), len(xfiles))
            pop.show()

        elif len(xfiles) > config.OSD_BUSYICON_TIMER[1]:
            # many files, just show the busy icon now
            osd.get_singleton().busyicon.wait(0)

        # extract one file at the time, bump the progress bar for each file extracted
        for f in xfiles:
            archive.extract(f, self.dir)
            if pop:
                pop.processed_file()
        
        # get rid of the msg box
        if pop:
            pop.hide()

        # stop the timer. If the icons is drawn, it will stay there
        # until the osd is redrawn, if not, we don't need it to pop
        # up the next milliseconds
        osd.get_singleton().busyicon.stop()

        exclude = ''
        
        if self.cover:
            # we do not want to include the cover img we just created
            # we store original config.IMAGE_EXCLUDE first, then set it to cover
            exclude = config.IMAGE_EXCLUDE
            config.IMAGE_EXCLUDE = ['cover']
        
        # now we let the base class handle the tmp directory
        DirItem.build(self, arg, menuw)
        
        if self.cover:
            # and now we restore original cover.IMAGE_RESTORE
            config.IMAGE_EXCLUDE = exclude
コード例 #19
0
 def poll(self):
     """
     update the idlebar every 30 secs even if nothing happens
     """
     if skin.active():
         skin.redraw()