Beispiel #1
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')
Beispiel #2
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')
Beispiel #3
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')