示例#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):
示例#2
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()
        self.obj.show()
示例#3
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):
    """
    Main beacon parse function. Return the load this function produced:
示例#4
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()
示例#5
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)

示例#6
0
文件: __init__.py 项目: clones/kaa
import os
import kaa
import kaa.metadata

backends = {}

WORKER_THREAD = 'WEBMETADATA'

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

from core import Movie, Series, Season, Episode

def init(base='~/.beacon'):
    """
    Initialize the kaa.webmetadata databases
    """
    if backends:
        return
    import thetvdb as backend
    backends['thetvdb'] = backend.TVDB(os.path.expanduser(base + '/thetvdb'))
    import themoviedb as backend
    backends['themoviedb'] = backend.MovieDB(os.path.expanduser(base + '/themoviedb'))

def db_version():
    """
    Get database version
    """
    ver = 0
    for module in backends.values():
        ver += module.version
示例#7
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):
    """
示例#8
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


# TODO: support removing channels not in updates
示例#9
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
示例#10
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)
示例#11
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