Exemple #1
0
 def confirm_system(self, arg=None, menuw=None):
     """
     Pops up a ConfirmBox.
     """
     self.menuw = menuw
     what = _('Do you really want to shut down the system?')
     ConfirmBox(text=what, handler=self.shutdown_system,
                default_choice=1).show()
 def confirm_shutdown_wakeup(self, arg=None, menuw=None):
     if config.AUTOSHUTDOWN_CONFIRM:
         title = _('SHUTDOWN SYSTEM?')
         info = self.message_check(wakeup=True)
         msg = title + "\n\n" + info
         ConfirmBox(text=msg,
                    handler=self.shutdown_wakeup,
                    default_choice=1).show()
     else:
         self.shutdown_wakeup(arg, menuw)
Exemple #3
0
 def confirm_system_restart(self, arg=None, menuw=None):
     """
     Pops up a ConfirmBox.
     """
     _debug_('confirm_system_restart(arg=%r, menuw=%r)' % (arg, menuw), 2)
     self.menuw = menuw
     what = _('Do you really want to restart the system?')
     ConfirmBox(text=what,
                handler=self.shutdown_system_restart,
                default_choice=config.SYS_SHUTDOWN_CONFIRM - 1).show()
Exemple #4
0
 def confirm_freevo(self, arg=None, menuw=None):
     """
     Pops up a ConfirmBox.
     """
     _debug_('confirm_freevo(arg=%r, menuw=%r)' % (arg, menuw), 2)
     self.menuw = menuw
     what = _('Do you really want to shut down Freevo?')
     ConfirmBox(text=what,
                handler=self.shutdown_freevo,
                default_choice=config.SYS_SHUTDOWN_CONFIRM - 1).show()
Exemple #5
0
 def confirm_restart_system(self, arg=None, menuw=None):
     logger.log(9, 'confirm_restart_system(arg=%r, menuw=%r)', arg, menuw)
     if config.AUTOSHUTDOWN_CONFIRM:
         title = _('RESTART SYSTEM?')
         info = self.message_check(wakeup=False)
         info = '' if info is None else '\n\n' + info
         msg = title + '\n' + _('(wakeup disabled)') + info
         ConfirmBox(text=msg, handler=self.restart_system,
                    default_choice=1).show()
     else:
         self.restart_system(arg, menuw)
Exemple #6
0
 def confirm_shutdown_freevo(self, arg=None, menuw=None):
     logger.log(9, 'confirm_shutdown_freevo(arg=%r, menuw=%r)', arg, menuw)
     if config.AUTOSHUTDOWN_CONFIRM:
         title = _('SHUTDOWN FREEVO?')
         info = self.message_check(wakeup=False)
         info = '' if info is None else '\n\n' + info
         msg = title + '\n' + _('(wakeup disabled)') + info
         ConfirmBox(text=msg,
                    handler=self.shutdown_freevo,
                    default_choice=1).show()
     else:
         self.shutdown_freevo(arg, menuw)
 def confirm_restart_system(self, arg=None, menuw=None):
     if config.AUTOSHUTDOWN_CONFIRM:
         title = _('RESTART SYSTEM?')
         info = self.message_check(wakeup=False)
         if (info == None):
             info = ""
         else:
             info = "\n\n" + info
         msg = title + "\n" + _("(wakeup disabled)") + info
         ConfirmBox(text=msg, handler=self.restart_system,
                    default_choice=1).show()
     else:
         self.restart_system(arg, menuw)
 def confirm_shutdown_freevo(self, arg=None, menuw=None):
     if config.AUTOSHUTDOWN_CONFIRM:
         title = _('SHUTDOWN FREEVO?')
         info = self.message_check(wakeup=False)
         if (info == None):
             info = ""
         else:
             info = "\n\n" + info
         msg = title + "\n" + _("(wakeup disabled)") + info
         ConfirmBox(text=msg,
                    handler=self.shutdown_freevo,
                    default_choice=1).show()
     else:
         self.shutdown_freevo(arg, menuw)
Exemple #9
0
    def play(self, arg=None, menuw=None, alternateplayer=False):
        """
        execute commands if defined
        """
        if config.VIDEO_PRE_PLAY:
            os.system(config.VIDEO_PRE_PLAY)
        """
        play the item.
        """
        if not self.possible_player:
            for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
                rating = p.rate(self) * 10
                if config.VIDEO_PREFERED_PLAYER == p.name:
                    rating += 1
                if hasattr(self,
                           'force_player') and p.name == self.force_player:
                    rating += 100
                self.possible_player.append((rating, p))

            self.possible_player.sort(lambda l, o: -cmp(l[0], o[0]))

        if alternateplayer:
            self.possible_player.reverse()

        if not self.possible_player:
            return

        self.player_rating, self.player = self.possible_player[0]
        if self.parent:
            self.parent.current_item = self

        if not self.menuw:
            self.menuw = menuw

        # if we have variants, play the first one as default
        if self.variants:
            self.variants[0].play(arg, menuw)
            return

        # if we have subitems (a movie with more than one file),
        # we start playing the first that is physically available
        if self.subitems:
            self.error_in_subitem = 0
            self.last_error_msg = ''
            self.current_subitem = None

            result = self.set_next_available_subitem()
            if self.current_subitem:  # 'result' is always 1 in this case
                # The media is available now for playing
                # Pass along the options, without loosing the subitem's own
                # options
                if self.current_subitem.mplayer_options:
                    if self.mplayer_options:
                        self.current_subitem.mplayer_options += ' ' + self.mplayer_options
                else:
                    self.current_subitem.mplayer_options = self.mplayer_options
                # When playing a subitem, the menu must be hidden. If it is not,
                # the playing will stop after the first subitem, since the
                # PLAY_END/USER_END event is not forwarded to the parent
                # videoitem.
                # And besides, we don't need the menu between two subitems.
                self.menuw.hide()
                self.last_error_msg = self.current_subitem.play(
                    arg, self.menuw)
                if self.last_error_msg:
                    self.error_in_subitem = 1
                    # Go to the next playable subitem, using the loop in
                    # eventhandler()
                    self.eventhandler(PLAY_END)

            elif not result:
                # No media at all was found: error
                ConfirmBox(text=(_('No media found for "%s".\n') +
                                 _('Please insert the media.')) % self.name,
                           handler=self.play).show()
            return

        # normal plackback of one file
        if self.url.startswith('file://'):
            file = self.filename
            if self.media_id:
                mountdir, file = util.resolve_media_mountdir(
                    self.media_id, file)
                if mountdir:
                    util.mount(mountdir)
                else:
                    self.menuw.show()
                    ConfirmBox(text=(_('No media found for "%s".\n') +
                                     _('Please insert the media.')) % file,
                               handler=self.play).show()
                    return

            elif self.media:
                util.mount(os.path.dirname(self.filename))

        elif self.mode in ('dvd',
                           'vcd') and not self.filename and not self.media:
            media = util.check_media(self.media_id)
            if media:
                self.media = media
            else:
                self.menuw.show()
                ConfirmBox(text=(_('No media found for "%s".\n') +
                                 _('Please insert the media.')) % self.url,
                           handler=self.play).show()
                return

        if self.player_rating < 10:
            AlertBox(text=_('No player for this item found')).show()
            return

        mplayer_options = self.mplayer_options.split(' ')
        if not mplayer_options:
            mplayer_options = []

        if arg:
            mplayer_options += arg.split(' ')

        if self.menuw.visible:
            self.menuw.hide()

        self.plugin_eventhandler(PLAY, menuw)

        error = self.player.play(mplayer_options, self)

        if error:
            # If we are a subitem we don't show any error message before
            # having tried all the subitems
            if hasattr(self.parent, 'subitems') and self.parent.subitems:
                return error
            else:
                AlertBox(text=error, handler=self.error_handler).show()
Exemple #10
0
    def __play(self, arg=None, menuw=None):
        # execute commands if defined
        if config.VIDEO_PRE_PLAY:
            os.system(config.VIDEO_PRE_PLAY)

        if self.parent:
            self.parent.current_item = self

        if not self.menuw:
            self.menuw = menuw

        # if we have variants, play the first one as default
        if self.variants:
            self.variants[0].play(arg, menuw)
            return

        # if we have subitems (a movie with more than one file),
        # we start playing the first that is physically available
        if self.subitems:
            self.error_in_subitem = 0
            self.last_error_msg = ''
            self.current_subitem = None

            result = self.set_next_available_subitem()
            if self.current_subitem:  # 'result' is always 1 in this case
                # The media is available now for playing
                # Pass along the options, without loosing the subitem's own
                # options
                if self.current_subitem.mplayer_options:
                    if self.mplayer_options:
                        # With this set the player options are incorrect when there is more than 1 item
                        #self.current_subitem.mplayer_options += ' ' + self.mplayer_options
                        pass
                else:
                    self.current_subitem.mplayer_options = self.mplayer_options
                # When playing a subitem, the menu must be hidden. If it is not,
                # the playing will stop after the first subitem, since the
                # PLAY_END/USER_END event is not forwarded to the parent
                # videoitem.
                # And besides, we don't need the menu between two subitems.
                self.menuw.hide()
                self.last_error_msg = self.current_subitem.play(
                    arg, self.menuw)
                if self.last_error_msg:
                    self.error_in_subitem = 1
                    # Go to the next playable subitem, using the loop in
                    # eventhandler()
                    self.eventhandler(PLAY_END)

            elif not result:
                # No media at all was found: error
                ConfirmBox(text=(_(
                    'No media found for "%(name)s".\nPlease insert the media "%(media_id)s".'
                )) % ({
                    'name': self.name,
                    'media_id': self.media_id
                }),
                           handler=self.play).show()
            return

        # normal plackback of one file
        if self.url.startswith('file://'):
            file = self.filename
            if self.media_id:
                mountdir, file = util.resolve_media_mountdir(
                    self.media_id, file)
                if mountdir:
                    util.mount(mountdir)
                else:
                    self.menuw.show()
                    ConfirmBox(text=(_('No media found for "%(file)s".\nPlease insert the media "%(media_id)s".')) % \
                        ({'file': file, 'media_id': self.media_id}), handler=self.play).show()
                    return

            elif self.media:
                util.mount(os.path.dirname(self.filename))

        # dvd and vcd
        elif self.mode in ('dvd',
                           'vcd') and not self.filename and not self.media:
            media = util.check_media(self.media_id)
            if media:
                self.media = media
            else:
                self.menuw.show()
                ConfirmBox(text=(_(
                    'No media found for "%(media_id)s".\nPlease insert the media "%(url)s".'
                )) % ({
                    'media_id': self.media_id,
                    'url': self.url
                }),
                           handler=self.play).show()
                return

        mplayer_options = self.mplayer_options.split(' ')
        if not mplayer_options:
            mplayer_options = []

        if arg:
            mplayer_options += arg.split(' ')

        if self.menuw.visible:
            self.menuw.hide()

        self.plugin_eventhandler(PLAY, menuw)

        self.menuw.delete_submenu()

        error = self.player.play(mplayer_options, self)

        # Clear any resume settings
        self['resume'] = ''

        if error:
            # If we are a subitem we don't show any error message before
            # having tried all the subitems
            if hasattr(self.parent, 'subitems') and self.parent.subitems:
                return error
            else:
                AlertBox(text=error, handler=self.error_handler).show()
Exemple #11
0
    def eventhandler(self, event):
        """
        event handling function for the main loop
        """
        if event == OS_EVENT_POPEN2:
            _debug_('popen2 %s' % event.arg[1])
            event.arg[0].child = util.popen3.Popen3(event.arg[1])
            return

        _debug_('handling event %s' % str(event), 2)

        for p in self.eventlistener_plugins:
            p.eventhandler(event=event)

        if event == FUNCTION_CALL:
            event.arg()

        elif event.handler:
            event.handler(event=event)

        # Send events to either the current app or the menu handler
        elif rc.app():
            if not rc.app()(event):
                for p in self.eventhandler_plugins:
                    if p.eventhandler(event=event):
                        break
                else:
                    _debug_('no eventhandler for event %s' % event, 2)

        else:
            app = osd.focused_app()
            if app:
                try:
                    if config.DEBUG_TIME:
                        t1 = time.clock()
                    app.eventhandler(event)
                    if config.DEBUG_TIME:
                        print time.clock() - t1

                except SystemExit:
                    raise SystemExit

                except:
                    if config.FREEVO_EVENTHANDLER_SANDBOX:
                        traceback.print_exc()
                        from gui import ConfirmBox
                        pop = ConfirmBox(text=_('Event \'%s\' crashed\n\nPlease take a ' \
                                                'look at the logfile and report the bug to ' \
                                                'the Freevo mailing list. The state of '\
                                                'Freevo may be corrupt now and this error '\
                                                'could cause more errors until you restart '\
                                                'Freevo.\n\nLogfile: %s\n\n') % \
                                         (event, sys.stdout.logfile),
                                         width=osd.width-(config.OSD_OVERSCAN_LEFT+config.OSD_OVERSCAN_RIGHT)-50,
                                         handler=shutdown,
                                         handler_message = _('shutting down...'))
                        pop.b0.set_text(_('Shutdown'))
                        pop.b0.toggle_selected()
                        pop.b1.set_text(_('Continue'))
                        pop.b1.toggle_selected()
                        pop.show()
                    else:
                        raise
            else:
                _debug_('no target for events given')
Exemple #12
0
    def eventhandler(self, event):
        """
        event handling function for the main loop
        """
        if event == OS_EVENT_POPEN2:
            logger.debug('popen2 %s', event.arg[1])
            event.arg[0].child = util.popen3.Popen3(event.arg[1])
            return

        logger.log(9, 'handling event %s', str(event))
        for p in self.eventlistener_plugins:
            p.eventhandler(event=event)

        if event == FUNCTION_CALL:
            event.arg()

        elif event.handler:
            event.handler(event=event)

        # Pass the event to the dialog subsystem first incase a dialog is being displayed.
        elif dialog.handle_event(event):
            return

        # Send events to either the current app or the menu handler
        elif rc.focused_app():
            consumed = False
            app = rc.focused_app()
            try:
                if config.DEBUG_TIME:
                    t1 = time.clock()

                if hasattr(app, 'eventhandler'):
                    consumed = app.eventhandler(event)
                else:
                    consumed = app(event)

                if config.DEBUG_TIME:
                    print time.clock() - t1

                if not consumed:
                    for p in self.eventhandler_plugins:
                        if p.eventhandler(event=event):
                            break
                    else:
                        logger.log(9, 'no eventhandler for event %s', event)

            except SystemExit:
                logger.debug('SystemExit re-raised')
                raise

            except:
                if config.FREEVO_EVENTHANDLER_SANDBOX:
                    traceback.print_exc()
                    from gui import ConfirmBox
                    pop = ConfirmBox(text=_(
                        "Event '%s' crashed\n\n" +
                        "Please take a look at the logfile and report" +
                        "the bug to the Freevo mailing list. The state" +
                        "of Freevo may be corrupt now and this error" +
                        "could cause more errors until you restart" +
                        "Freevo.\n\n" + "Logfile: %s\n\n") %
                                     (event, config.logfile),
                                     width=osd.width -
                                     (config.OSD_OVERSCAN_LEFT +
                                      config.OSD_OVERSCAN_RIGHT) - 50,
                                     handler=shutdown,
                                     handler_message=_('shutting down...'))
                    pop.b0.set_text(_('Shutdown'))
                    pop.b0.toggle_selected()
                    pop.b1.set_text(_('Continue'))
                    pop.b1.toggle_selected()
                    pop.show()
                else:
                    raise
        else:
            logger.debug('no target for events given')
Exemple #13
0
    def eventhandler(self, event):
        """
        event handling function for the main loop
        """
        if event == OS_EVENT_POPEN2:
            logger.debug('popen2 %s', event.arg[1])
            event.arg[0].child = util.popen3.Popen3(event.arg[1])
            return

        logger.log( 9, 'handling event %s', str(event))
        for p in self.eventlistener_plugins:
            p.eventhandler(event=event)

        if event == FUNCTION_CALL:
            event.arg()

        elif event.handler:
            event.handler(event=event)

        # Pass the event to the dialog subsystem first incase a dialog is being displayed.
        elif dialog.handle_event(event):
            return

        # Send events to either the current app or the menu handler
        elif rc.focused_app():
            consumed = False
            app = rc.focused_app()
            try:
                if config.DEBUG_TIME:
                    t1 = time.clock()

                if hasattr(app, 'eventhandler'):
                    consumed = app.eventhandler(event)
                else:
                    consumed = app(event)

                if config.DEBUG_TIME:
                    print time.clock() - t1

                if not consumed:
                    for p in self.eventhandler_plugins:
                        if p.eventhandler(event=event):
                            break
                    else:
                        logger.log( 9, 'no eventhandler for event %s', event)

            except SystemExit:
                logger.debug('SystemExit re-raised')
                raise

            except:
                if config.FREEVO_EVENTHANDLER_SANDBOX:
                    traceback.print_exc()
                    from gui import ConfirmBox
                    pop = ConfirmBox(
                        text=_("Event '%s' crashed\n\n" +
                            "Please take a look at the logfile and report" +
                            "the bug to the Freevo mailing list. The state" +
                            "of Freevo may be corrupt now and this error" +
                            "could cause more errors until you restart" +
                            "Freevo.\n\n" +
                            "Logfile: %s\n\n") %
                        (event, config.logfile),
                        width=osd.width-(config.OSD_OVERSCAN_LEFT+config.OSD_OVERSCAN_RIGHT)-50,
                        handler=shutdown,
                        handler_message = _('shutting down...'))
                    pop.b0.set_text(_('Shutdown'))
                    pop.b0.toggle_selected()
                    pop.b1.set_text(_('Continue'))
                    pop.b1.toggle_selected()
                    pop.show()
                else:
                    raise
        else:
            logger.debug('no target for events given')