Esempio n. 1
0
import time
import os
import sys
import gc
import kaa
import kaa.rpc

sig = kaa.Signals('one', 'two', 'three')

# Named thread pools used later.
kaa.register_thread_pool('yield', kaa.ThreadPool())
kaa.register_thread_pool('foo', kaa.ThreadPool())


class Server(object):
    def __init__(self):
        self.s = kaa.rpc.Server('test')
        self.s.register(self)

    @kaa.rpc.expose('test1')
    def test1(self, x):
        return x, kaa.is_mainthread()

    @kaa.rpc.expose('test2')
    @kaa.threaded('yield')
    def test2(self, x):
        return x, kaa.is_mainthread()

    @kaa.rpc.expose('test3')
    @kaa.coroutine()
    def test3(self, x):
Esempio n. 2
0
import pygame
from pygame.locals import *
import kaa.imlib2 as imlib2

import osd
import os
import util
try:
    import cStringIO as StringIO
except:
    import StringIO

from kaa.metadata.image import EXIF as exif

import kaa
thread_pool = kaa.ThreadPool()

osd = osd.get_singleton()

format_imagecache = util.objectcache.ObjectCache(300, desc='format_image')
load_imagecache = util.objectcache.ObjectCache(20, desc='load_image')


def pygamesurface_imlib2_scale(image, newsize):

    buf = pygame.image.tostring(image, 'RGBA')
    im2 = imlib2.new(image.get_size(), buf)
    scaled_im2 = im2.scale(newsize)

    buf = str(scaled_im2.get_raw_data('BGRA'))
Esempio n. 3
0
import tempfile
import random

# kaa imports
import kaa
import kaa.imlib2

# clutter imports
from gi.repository import Clutter as clutter
from gi.repository import GObject as gobject

# candy backend import
import candy

# register the thread pool for loading images
kaa.register_thread_pool('candy::photo', kaa.ThreadPool())

CENTER = clutter.Point()
CENTER.x = 0.5
CENTER.y = 0.5


class Widget(candy.Widget):
    """
    Backend widget class
    """
    def create(self):
        """
        Create the clutter object
        """
        self.obj = clutter.Group.new()
Esempio n. 4
0
# get logging object
log = logging.getLogger('beacon.parser')

# load extra plugins in the plugins subdirectory
extention_plugins = {}

media_types = {
    kaa.metadata.MEDIA_AUDIO: 'audio',
    kaa.metadata.MEDIA_VIDEO: 'video',
    kaa.metadata.MEDIA_IMAGE: 'image',
    kaa.metadata.MEDIA_AV: 'video',
    kaa.metadata.MEDIA_DIRECTORY: 'dir'
}

# parsing thread
kaa.register_thread_pool('beacon::metadata', kaa.ThreadPool())
parse_thread = kaa.ThreadPoolCallable('beacon::metadata', kaa.metadata.parse)


def register(ext, function):
    """
    Register a plugin to the parser. This function gets called by the
    external plugins in the plugins subdir.
    """
    if not ext in extention_plugins:
        extention_plugins[ext] = []
    extention_plugins[ext].append(function)


def parse(db, item, force_thumbnail_check=False):
    """
Esempio n. 5
0
import os
import kaa
import kaa.metadata
import kaa.beacon

initialized = False

WORKER_THREAD = 'WEBMETADATA'

kaa.metadata.enable_feature('VIDEO_SERIES_PARSER')
kaa.register_thread_pool(WORKER_THREAD, kaa.ThreadPool())

import tv
import movie

from tv.core import Series, Season, Episode
from movie.core import Movie

signals = kaa.Signals('sync', 'changed')


def init(base):
    """
    Initialize the kaa.webmetadata databases
    """
    global initialized
    if initialized:
        return
    for module in tv, movie:
        module.init(base)
    initialized = True
Esempio n. 6
0
# kaa imports
import kaa
import kaa.metadata
import kaa.imlib2
import kaa.rpc

# kaa.beacon imports
from .. import libthumb
from videothumb import VideoThumb
from config import config
import scheduler

# get logging object
log = logging.getLogger('beacon.thumbnail')

kaa.register_thread_pool('beacon::download', kaa.ThreadPool())


@kaa.threaded('beacon::download')
def download(url, filename):
    """
    Download url and store in filename
    """
    if os.path.exists(filename):
        return None
    if not os.path.exists(os.path.dirname(filename)):
        os.makedirs(os.path.dirname(filename))
    log.info('fetch %s', url)
    image = urllib.urlopen(url).read()
    open(filename, 'w').write(image)
Esempio n. 7
0
import kaa.utils

# kaa imports
import kaa
from kaa.db import *

# kaa.epg imports
from config import config

# get logging object
log = logging.getLogger('epg.update')

sources = {}

# Register thread pool for backends.
kaa.register_thread_pool('kaa.epg::update', kaa.ThreadPool())

# Plugins are modules that define:
#    1. a config Group object called 'sourcecfg' (optional)
#    2. An async function update() that takes 1 argument (epg)
filter = lambda x: x != 'update' and not x.startswith('config')
for name, plugin in kaa.utils.get_plugins('kaa.epg.sources',
                                          __file__,
                                          filter=filter).items():
    if isinstance(plugin, Exception):
        log.error('Failed to load plugin %s: %s', name, plugin)
        continue
    if hasattr(plugin, 'sourcecfg'):
        config.add_variable(name, plugin.sourcecfg)
    sources[name] = plugin