Beispiel #1
0
    def __init__(self):

        plugin.DaemonPlugin.__init__(self)
        self.plugin_name = 'WIIMOTE'

        self.bdaddr = config.WII_ADDRESS
        self.acc_activate = config.WII_ACC_ACTIVATE
        self.acc_rl_repeat = config.WII_ACC_RL_REPEAT
        self.acc_ud_repeat = config.WII_ACC_UD_REPEAT
        self.acc_button = config.WII_ACC_BUTTON
        self.acc_button_time = config.WII_ACC_BUTTON_TIME
        self.ping_interval = config.WII_PING_INTERVAL

        for mapping in config.WII_CMDS:
            self.KEYMAP[mapping] = config.WII_CMDS.get(mapping, '')

        self.rx = bluetooth.BluetoothSocket(bluetooth.L2CAP)
        self.cx = bluetooth.BluetoothSocket(bluetooth.L2CAP)

        self.cx.settimeout(2)
        self.rx.settimeout(2)

        self.rx_dispatcher = kaa.IOMonitor(self.handle_receive)

        # start immediately for the first time
        self.timer = kaa.Timer(self.onTimer)
        self.timer.start(0.1)

        self.acc_timer = kaa.Timer(self.on_acc_timer)

        self.active = True
Beispiel #2
0
 def connect(self, idlebar):
     self.widget = kaa.candy.Label(None, ('100%', '50%'), 0xffffff, 'Vera')
     self.widget.xalign = self.widget.ALIGN_RIGHT
     self.widget.yalign = self.widget.ALIGN_CENTER
     self.widget.text = time.strftime(self.format)
     idlebar.add(self.widget)
     kaa.Timer(self.update).start(10)
Beispiel #3
0
def _update_data_thread(epg,
                        vdr_dir=None,
                        channels_file=None,
                        epg_file=None,
                        host=None,
                        port=None,
                        access_by='sid',
                        limit_channels='conf',
                        exclude_channels=None):
    """
    Update the guide.
    """
    log.debug('_update_data_thread')

    info = UpdateInfo()
    info.total = 0

    if not (isinstance(exclude_channels, list) or \
            isinstance(exclude_channels, tuple)):
        exclude_channels = []

    log.info('excluding channels: %s' % exclude_channels)

    info.vdr = VDR(host=host,
                   port=port,
                   videopath=vdr_dir,
                   channelsfile=channels_file,
                   epgfile=epg_file,
                   close_connection=0)

    if info.vdr.epgfile and os.path.isfile(info.vdr.epgfile):
        log.info('Using VDR EPG from %s.' % info.vdr.epgfile)
        if os.path.isfile(info.vdr.channelsfile):
            info.vdr.readchannels()
        else:
            log.warning('VDR channels file not found: %s.' %
                        info.vdr.channelsfile)
        info.vdr.readepg()
    elif info.vdr.host and info.vdr.port:
        log.info('Using VDR EPG from %s:%s.' % (info.vdr.host, info.vdr.port))
        info.vdr.retrievechannels()
        info.vdr.retrieveepg()
    else:
        log.info('No source for VDR EPG.')
        return False

    for c in info.vdr.channels.values():
        for e in c.events:
            info.total += 1

    info.access_by = access_by
    info.limit_channels = limit_channels
    info.exclude_channels = exclude_channels
    info.epg = epg
    info.progress_step = info.total / 100

    timer = kaa.Timer(_update_process_step, info)
    timer.start(0)
Beispiel #4
0
 def add_animation(self, anim_object):
     """
     Add an animation to our list
     """
     self.animations.append(anim_object)
     if len(self.animations) == 1:
         # first animation, register ourself to the main loop:
         self.timer = kaa.Timer(self.update)
         self.timer.start(0.01)
Beispiel #5
0
    def do_blend_transition(self, transition):
        self.current_screen = osd.main_layer.convert()
        self.screen.show(True)
        self.next_screen = osd.main_layer.convert()

        self.transitioning = True
        self.steps = 0
        self.timer = kaa.Timer(self.do_blend_step, transition)
        self.do_blend_step(transition)
        self.timer.start(0.01)
Beispiel #6
0
 def __init__(self):
     """
     init the lcd
     """
     super(PluginInterface, self).__init__()
     self.lcd = kaa.display.LCD()
     self.lcd.signals['connected'].connect(self._connected)
     self.running = False
     self.current = []
     self.timer = kaa.Timer(self.update)
Beispiel #7
0
    def __init__(self):
        """ Initialise the transcode idlebar plug-in """
        logger.log(9, 'transcode.PluginInterface.__init__()')
        IdleBarPlugin.__init__(self)
        self.plugin_name = 'idlebar.transcode'

        self.background = os.path.join(config.ICON_DIR,
                                       'status/enc_background.png')
        self.leftclamp = os.path.join(config.ICON_DIR,
                                      'status/enc_leftclamp.png')
        self.rightclamp = os.path.join(config.ICON_DIR,
                                       'status/enc_rightclamp.png')
        self.notrunning = os.path.join(config.ICON_DIR,
                                       'status/enc_notrunning.png')
        self.nojobs = os.path.join(config.ICON_DIR, 'status/enc_nojobs.png')
        self.audio = os.path.join(config.ICON_DIR, 'status/enc_audio.png')
        self.video = os.path.join(config.ICON_DIR, 'status/enc_video.png')
        self.video1 = os.path.join(config.ICON_DIR, 'status/enc_video1.png')
        self.video2 = os.path.join(config.ICON_DIR, 'status/enc_video2.png')
        self.video3 = os.path.join(config.ICON_DIR, 'status/enc_video3.png')
        self.multiplex = os.path.join(config.ICON_DIR,
                                      'status/enc_multiplex.png')

        self.cacheimg = {}
        self.background_w, self.background_h = (0, 0)
        self.leftclamp_w, self.leftclamp_h = (0, 0)
        self.rightclamp_w, self.rightclamp_h = (0, 0)
        self.remaining_min = re.compile('[0-9]*')
        self.remaining = ''
        self.progress = 0
        self.progress_x = None
        self.leftclamp_x = 0
        self.rightclamp_x = 0

        self.poll_interval = 1  # 1 sec should be same as most frequent
        self.draw_interval = 5.0  # 5 secs
        self.last_interval = self.poll_interval
        self.lastdraw = 0
        self.lastpoll = 0
        self.drawtime = 0
        self.server = EncodingClientActions()

        self.skin = skin.get_singleton()
        self.calculate = True
        self.jobs = ''
        self.mode = 'Not Running'
        self.state = 'noserver'
        self.laststate = None
        self.percent = 0.0
        self.running = False
        self.font = self.skin.get_font(config.OSD_IDLEBAR_FONT)
        self.timer = kaa.Timer(self._timerhandler)
        self.timer.start(self.poll_interval)
        logger.debug('transcode.PluginInterface.__init__() done.')
    def __init__(self, manager, path, size):
        self.name      = 'vlc'
        self.app_mode  = 'tv'
        self.app       = None
        self.adapter_in_use = -1
        self.fc = FreevoChannels()
        self.path = path
        self.size = size
        self.buffer = ring_buffer.RingBuffer(size, path)
        self.last_channel = None
        self.subtitles = False
        self.paused = False
        self.stop_time = 0
        self.state = STATE_IDLE
        self.manager = manager
        self.udp_receiver = UDPReceiver(self.buffer, WAIT_FOR_DATA_TIMEOUT)
        self.slave_server = SlaveServer(self.buffer, self)
        self.fill = 0
        self.cur_audio      = None
        self.cur_sub        = None
        self.cur_audiodev   = None
        self.lastchan       = None

        self.timer = kaa.Timer(self.__update_data_from_vlc)
        self.timer_start = kaa.OneShotTimer( self.__update_data_from_vlc)
        self.timer_disablebuffering = kaa.OneShotTimer( self.disable_buffering)

        if hasattr(config, 'LIVE_PAUSE_BUFFER_TIMEOUT'):
            self. buffering_timeout=config.LIVE_PAUSE_BUFFER_TIMEOUT
        else: # Disable after 5min if not LIVE_PAUSE_BUFFERING_TIMEOUT
            self.buffering_timeout= 5 * 60

        # Create the command used to start vlc.
        # NOTE: We add the slave server MRL twice so that we can toggle between
        # them, this allows use to effectively reset vlc rendering pipeline and
        # make it possible to seek quickly.
        self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
                       config.VLC_COMMAND.split(' ')  + \
                       [ '--intf', 'rc' ] + \
                       ['--no-interact','--rc-fake-tty'] + \
                       [ '--sub-filter' ,'marq' ] + \
                       [ '--marq-marquee' ,'Playing' ] + \
                       [ '--marq-position','4'] + \
                       [ '--fullscreen', self.slave_server.get_vlc_mrl(),
                                         self.slave_server.get_vlc_mrl()]

        if not rc.PYLIRC and '--no-lirc' in self.command:
            self.command.remove('--no-lirc')

        self.udp_receiver.start()
        self.slave_server.start()
Beispiel #9
0
 def __init__(self, datafile):
     epg.init()
     self.locked = False
     self.datafile = datafile
     # load the recordings file
     self.load_schedule()
     # connect to recorder signals
     device.signals['start-recording'].connect(self._recorder_start)
     device.signals['stop-recording'].connect(self._recorder_stop)
     device.signals['changed'].connect(self.reschedule)
     # start by checking the recordings/favorites
     self.check_favorites_and_reschedule()
     # add schedule timer for SCHEDULE_TIMER / 3 seconds
     kaa.Timer(self.check_favorites_and_reschedule).start(SCHEDULE_TIMER / 3)
Beispiel #10
0
    def update_wait(self):
        """
        This is used while starting freevo
        """
        if osd._singleton == None:
            return

        if self.osd == None:
            self.osd = osd.get_singleton()
            if self.timer:
                self.timer.stop()
            self.update = self.update_enabled
            self.timer = kaa.Timer(self.update)
            self.timer.start(0.01)
Beispiel #11
0
    def do_slide_transition(self, transition):
        if transition == TRANSITION_PAGE:
            self.do_blend_transition(transition)
            return

        self.current_screen = osd.main_layer.convert()
        self.screen.show(True)
        self.next_screen = osd.main_layer.convert()

        self.transitioning = True
        self.steps = 0
        self.timer = kaa.Timer(self.do_slide_step, transition)
        self.do_slide_step(transition)
        self.timer.start(0.01)
Beispiel #12
0
    def __init__(self, use_pylirc=1, use_netremote=1, is_helper=1):
        _debug_('EventHandler.__init__(use_pylirc=%r, use_netremote=%r, is_helper=%r)' % \
            (use_pylirc, use_netremote, is_helper), 1)

        _debug_('config.HELPER=%r' % (config.HELPER,))

        self.inputs = []
        if not config.HELPER:
            if use_pylirc:
                try:
                    self.inputs.append(Lirc())
                except:
                    pass

            if config.USE_SDL_KEYBOARD:
                try:
                    self.inputs.append(Keyboard())
                except:
                    pass

            if config.EVENT_DEVS:
                try:
                    self.inputs.append(Evdev())
                except:
                    pass

            if use_netremote and config.ENABLE_NETWORK_REMOTE and config.REMOTE_CONTROL_PORT:
                self.inputs.append(Network())

            if use_netremote and config.ENABLE_TCP_NETWORK_REMOTE and \
                    config.REMOTE_CONTROL_TCP_HOST and config.REMOTE_CONTROL_TCP_PORT:
                self.inputs.append(TcpNetwork())

        self.app                = None
        self.context            = 'menu'
        self.callbacks          = []
        self.shutdown_callbacks = []
        self.poll_objects       = []
        # lock all critical parts
        #self.lock               = thread.allocate_lock()
        self.lock               = threading.RLock()
        # last time we stopped sleeping
        self.sleep_timer        = 0
        kaa.Timer(self.poll).start(0.01)
        _debug_('EventHandler.self.inputs=%r' % (self.inputs,), 1)
Beispiel #13
0
def get_default_cache():
    """Get the default cache to use for Freevo"""
    global __default_cache
    if __default_cache is None:
        import config
        import version
        import kaa
        __default_cache = WebCache(os.path.join(config.FREEVO_CACHEDIR, 'web'),
                                   'Freevo/' + version.__version__)

        # Remove expired items from the cache.
        __default_cache.clean()

        # Set a timer for every 30 minutes to clean the cache.
        t = kaa.Timer(__default_cache.clean)
        t.start(1800)

    return __default_cache
Beispiel #14
0
 def plugin_activate(self, level):
     if not os.environ.get('DISPLAY') or not kaa.utils.which('xset'):
         return
     # get xset process to call
     self.xset = kaa.Process(kaa.utils.which('xset')).start
     self.counter = 0
     self._mode = OFF
     # Timer to poll and increase counter. It willbe started when the
     # menu is shown.
     self.timer = kaa.Timer(self.poll)
     # register to all events
     kaa.EventHandler(self.eventhandler).register()
     # turn on dpms on shutdown
     kaa.main.signals['shutdown'].connect(self.xset, '+dpms')
     # register to application changes
     freevo.signals['application-change'].connect(self.application_changed)
     # turn off dpms
     self.xset('-dpms s off')
Beispiel #15
0
    def __init__(self):
        plugin.DaemonPlugin.__init__(self)
        self.plugin_name = 'freevused'

        self.event_listener = True

        self.shutdown_plugin = False

        self.connected = False
        self.server_sock = None
        self.tx = None
        self.address = 0
        self.port = 0
        self.data = ''
        self.menuw = None

        self.timer = None
        self.conn_timer = None

        self.osd_message_status = None

        self.menu_isfresh = False
        self.playing = False
        self.menu_client_waiting = False

        self.audioplayer = None

        if hasattr(config, 'FVUSED_BIND_TIMEOUT'):
            self.bind_timeout = config.FVUSED_BIND_TIMEOUT
        else:
            self.bind_timeout = 5

        if hasattr(config, 'FVUSED_OSD_MESSAGE'):
            self.osd_message = config.FVUSED_OSD_MESSAGE
        else:
            self.osd_message = False

        if hasattr(config, 'FVUSED_CMDS'):
            self.cmds = config.FVUSED_CMDS
        else:
            self.cmds = {
                'PREV': 'UP',  # 1st row left
                'STRT': 'SELECT',  # 1nd row center
                'NEXT': 'DOWN',  # 1st row right
                'RWND': 'LEFT',  # 2nd row left
                'PAUS': 'PAUSE',  # 2nd row center
                'FFWD': 'RIGHT',  # 2nd row right
                'VOL-': 'MIXER_VOLDOWN',  # 3rd row left
                'STOP': 'EXIT',  # 3rd row center
                'VOL+': 'MIXER_VOLUP',  # 3rd row right
                'VOLM': 'MIXER_MUTE',  # 4th row left
                'SLCT': 'ENTER',  # 4th row center
                'MAIN': 'STOP',  # 4th row right
                'DISP': 'DISPLAY',  # More actions
                'EJEC': 'EJECT',
                'DEAU': 'DISPLAY',
                'CHA+': 'CH+',
                'CHA-': 'CH-',
                'RECO': 'REC',
                'GUID': 'GUIDE',
                'NUM0': '0',  # Numeric keyboard
                'NUM1': '1',
                'NUM2': '2',
                'NUM3': '3',
                'NUM4': '4',
                'NUM5': '5',
                'NUM6': '6',
                'NUM7': '7',
                'NUM8': '8',
                'NUM9': '9',
                'STAT': 'FVUSED_ITEM_INFO'
            }

#        self.poll_menu_only = False

        self.timer = kaa.Timer(self.timer_handler)
        self.timer.start(config.POLL_TIME)

        self.rc = rc.get_singleton()

        self.FVUSED_ITEM_INFO = em.Event('FVUSED_ITEM_INFO')

        self.connection_thread()
Beispiel #16
0

if method == 0:
    # select the thread loop and provide callbacks for a hander and how to
    # stop the real mainloop
    loop = kaa.main.select_notifier('thread', handler = reactor.callFromThread, \
                                    shutdown = reactor.stop)
    # stop the thread when twisted is done. Without this code the app will wait
    # until the nf thread will be done which will never happen.
    reactor.addSystemEventTrigger('after', 'shutdown', loop.stop)

if method == 1:
    # there is special code in kaa that does the same as method 0
    kaa.main.select_notifier('twisted')
if method == 2:
    # or use the real twisted mainloop
    kaa.main.select_notifier('twisted_experimental')

reactor.callLater(0.5, twisted_callback1)
reactor.callLater(1.5, twisted_callback2)
kaa.Timer(kaa_callback).start(1)
kaa.main.signals['shutdown'].connect(shutdown_callback)

if method == 2:
    # the twisted_experimental needs kaa.main.run()
    kaa.main.run()
else:
    reactor.run()

print 'done'
Beispiel #17
0
kaa.main.step()
test(result, [42])

result = []
kaa.WeakOneShotTimer(Cls().meth, 42).start(0)
kaa.main.step()
test(result, [])

result = []
cb = Cls().meth
kaa.WeakOneShotTimer(cb, 42).start(0)
kaa.main.step()
test(result, [42])

result = []
timer = kaa.Timer(Cls().meth, 42)
timer.start(0)
for i in range(5):
    kaa.main.step()
timer.stop()
test(result, [42, 42, 42, 42, 42])

result = []
# Tests proper destruction of a weak timer.  We hold a weak ref to Cls().meth
# and since there are no other refs, the weak timer never gets activated.
timer = kaa.WeakTimer(Cls().meth, 42)
timer.start(0)
# Notifier technically has nothing to do, so it may sleep for 30 seconds.
print '(This could take 30 seconds or so.)'
for i in range(2):
    kaa.main.step()
Beispiel #18
0
                print 'Warning: Freevo cache helper/information updated.'
                print 'Please rerun \'freevo cache\' to speed up Freevo'
                print
                del_cache()

            elif kaa.metadata.version.VERSION > mmchanged:
                print
                print 'Warning: kaa metadata as changed.'
                print 'Please rerun \'freevo cache\' to get the latest updates'
                print
                del_cache()

            elif (int(time.time()) - part_update) / (3600 * 24) > 7:
                print
                print 'Warning: cache is older than 7 days'
                print 'Running \'freevo cache\' is recommended.'
                print
    except:
        print
        print 'Error: unable to read kaa metadata version information'
        print 'Please update kaa.metadata to the latest release or if you use'
        print 'Freevo svn versions, please also use kaa.metadata svn.'
        print
        print 'Some functions in Freevo may not work or even crash!'
        print
        print

    import kaa
    timer = kaa.Timer(check_cache_status)
    timer.start(1.0)
Beispiel #19
0
        self.cache = (wait, self.last_request_time)
        return wait


scheduler = Scheduler('beacon-daemon')
check = scheduler.check
next = scheduler.next

if __name__ == '__main__':
    sched1 = Scheduler(os.getpid())
    sched2 = Scheduler(os.getpid())
    sched3 = Scheduler(os.getpid())

    def debug():
        print '-----------'
        print 'Polite:', sched1.next('polite')
        print 'Balanced:', sched2.next('balanced')
        print 'Aggressive:', sched3.next('aggressive')

    @kaa.coroutine()
    def add_load():
        x = 0
        for i in range(300000):
            yield kaa.NotFinished
        print "Done load generation"

    add_load()
    t = kaa.Timer(debug)
    t.start(0.3)
    kaa.main.run()
Beispiel #20
0
def __load_plugin__(name, type, level, args, number):
    """
    load the plugin and add it to the lists
    """
    import rc

    global __plugin_type_list__
    global __named_plugins__
    global __plugin_basedir__

    # fallback
    module = name
    object = '%s.PluginInterface' % module
    special = None

    # locate the plugin:
    files = []

    if not isinstance(name, Plugin):
        module, special = __find_plugin_file__(name.replace('.', '/'))
        if module:
            object = module + '.PluginInterface'
        elif name.find('.') > 0:
            module, special = __find_plugin_file__(
                name[:name.rfind('.')].replace('.', '/'))
            if module:
                object = module + '.%s' % name[name.rfind('.') + 1:]
            else:
                print 'can\'t locate plugin %r' % name
                print 'start "freevo plugins -l" to get a list of plugins'
                return
        else:
            print 'can\'t locate plugin %r' % name
            print 'start "freevo plugins -l" to get a list of plugins'
            return

    try:
        if not isinstance(name, Plugin):
            logger.debug('loading %s as plugin %s', module, object)

            exec('import %s' % module)
            if not args:
                p = eval(object)()
            elif isinstance(args, list) or isinstance(args, tuple):
                paramlist = 'args[0]'
                for i in range(1, len(args)):
                    paramlist += ',args[%s]' % i
                p = eval('%s(%s)' % (object, paramlist))
            else:
                p = eval(object)(args)

            if not hasattr(p, '_type'):
                if hasattr(p, 'reason'):
                    reason = p.reason
                else:
                    reason = 'unknown\nThe plugin neither called __init__ nor set a '\
                             'reason why\nPlease contact the plugin author or the freevo list'
                print 'plugin %s deactivated, reason: %s' % (name, reason)
                return
        else:
            p = name

        p._number = number
        p._level = level

        if type:
            special = type

        if special == 'main':
            special = ''
        elif special:
            special = '_%s' % special
        else:
            special = ''

        # special plugin type (e.g. idlebar)
        if p._type:
            __add_to_ptl__(p._type, p)

        else:
            if isinstance(p, DaemonPlugin):
                __add_to_ptl__('daemon', p)
                for type in ('poll', 'draw', 'eventhandler', 'shutdown'):
                    if hasattr(p, type):
                        __add_to_ptl__('daemon_%s' % type, p)
                if hasattr(p, 'poll'):
                    if p.poll_menu_only:
                        # replace poll with the poll wrapper to handle
                        # poll_menu_only
                        p.timer = kaa.Timer(p.poll_wrapper)
                    else:
                        p.timer = kaa.Timer(p.poll)
                    p.timer.start(p.poll_interval)

            if isinstance(p, MainMenuPlugin):
                __add_to_ptl__('mainmenu%s' % special, p)
                if hasattr(p, 'eventhandler'):
                    __add_to_ptl__('daemon_eventhandler', p)

            if isinstance(p, ItemPlugin):
                __add_to_ptl__('item%s' % special, p)

            if isinstance(p, MimetypePlugin):
                __add_to_ptl__('mimetype', p)

        if p.plugin_name:
            __named_plugins__[p.plugin_name] = p

    except:
        print 'failed to load plugin %s' % name
        print 'start \'freevo plugins -l\' to get a list of plugins'
        traceback.print_exc()
Beispiel #21
0
</candyxml>
'''


@kaa.coroutine()
def main():
    stage = kaa.candy.Stage((400, 300), 'candy')
    attr, candy = stage.candyxml(xml)
    container = candy.group.g1()
    stage.add(container)
    yield kaa.NotFinished
    yield kaa.NotFinished
    container.x += 100
    yield kaa.NotFinished
    #container.parent = None
    yield kaa.NotFinished


def garbage_collect():
    gc.collect()
    for g in gc.garbage:
        print 'Unable to free %s' % g


# Set up garbage collector to be called every 5 seconds
kaa.Timer(garbage_collect).start(1)

main()
kaa.main.run()
print 'shutdown'