Exemplo n.º 1
0
    def __init__(self, size):

        # Initialize the PyGame modules.
        if not pygame.display.get_init():
            pygame.display.init()
            pygame.font.init()

        # get screen with 32 bit
        self._screen = pygame.display.set_mode(size, 0, 32)
        if self._screen.get_bitsize() != 32:
            # if the bitsize is not 32 as requested, we need
            # a tmp surface to convert from imlib2 to pygame
            # because imlib2 uses 32 bit and with a different
            # value memcpy will do nasty things
            self._surface = pygame.Surface(size, 0, 32)
        else:
            self._surface = None
        # define signals
        self.signals = {
            'key_press_event': kaa.Signal(),
            'mouse_up_event': kaa.Signal(),
            'mouse_down_event': kaa.Signal()
        }
        # connect to idle loop
        kaa.main.signals['step'].connect(self.poll)
        # keyboard settings
        pygame.key.set_repeat(500, 30)
        # mouse settings
        self.hide_mouse = True
        self.mousehidetime = time.time()
Exemplo n.º 2
0
 def __init__(self):
     self.parent = None
     self.active = False
     self.enabled = True
     self.visible = True
     self.signals = kaa.Signals()
     self.signals['activated'] = kaa.Signal()
     self.signals['deactivated'] = kaa.Signal()
Exemplo n.º 3
0
 def __init__(self, node=None):
     self.properties = ()
     self.parent = None
     self.children = None
     self.has_children = False
     self.type = ''
     self.signals = kaa.Signals()
     self.signals['property-changed'] = kaa.Signal()
     self.signals['child-added'] = kaa.Signal()
     self.signals['child-removed'] = kaa.Signal()
Exemplo n.º 4
0
    def __init__(self, proxy):
        #self._proxy = kaa.weakref.weakref(proxy)
        self._proxy = proxy
        self._state = STATE_NOT_RUNNING
        # Internal error signal.  Not all errors emitted to this signal are
        # meant to be visible to the proxy.
        self._error_signal = kaa.Signal()
        self._error_message = None

        # A kaa.Process object if mplayer is running.
        self._child = None
        self._mp_cmd = proxy._config.mplayer.path
        self._reset_stream()

        # TODO: use these.
        self._filters_pre = []
        self._filters_add = []

        if not self._mp_cmd:
            self._mp_cmd = kaa.utils.which('mplayer')
            if not self._mp_cmd:
                raise PlayerError('No mplayer executable found in PATH')

        # Fetch info for this mplayer.  It's almost guaranteed that this
        # will returned a cached value, so it won't block.
        self._mp_info = get_mplayer_info(self._mp_cmd)
        if not self._mp_info:
            # It is extremely unlikely this will happen, because the backend manager
            # will alraedy have called get_mplayer_info and the proxy would not
            # have received us as a suitable player class if it failed.
            raise PlayerError(
                "MPlayer at %s (found in PATH) isn't behaving as expected" %
                self._mp_cmd)
Exemplo n.º 5
0
 def __init__(self):
     """
     Create a new instance with initially no buttons.
     """
     self.buttons = []
     self.selected_button = None
     self.signals = kaa.Signals()
     self.signals['selection_changed'] = kaa.Signal()
Exemplo n.º 6
0
 def __init__(self, text):
     """
     Creates a new instance.
     @param text: Text to be displayed by the item.
     """
     super(ToggleMenuItemModel, self).__init__(text)
     self.selected = False
     self.signals['toggled'] = kaa.Signal()
Exemplo n.º 7
0
 def __init__(self, text):
     """
     Create a new instance.
     @param text: The text to display along with the state of the button.
     """
     super(ToggleButtonModel, self).__init__(text)
     self.selected = False
     self.group = None
     self.signals['toggled'] = kaa.Signal()
Exemplo n.º 8
0
 def __init__(self, server='127.0.0.1', port=13666):
     self.signals = {
         'connected': kaa.Signal()
     }
     self._server = server
     self._port = port
     self._connected = False
     self._connect()
     self._screenno = 0
Exemplo n.º 9
0
 def __init__(self):
     self._stack = []
     self.locked = False
     if not hasattr(self, 'signals'):
         # The main menu inherits from appication which already
         # defines self.signals. ther menus need this because we
         # want to add a refresh signal
         self.signals = kaa.Signals()
     self.signals['refresh'] = kaa.Signal()
Exemplo n.º 10
0
 def __init__(self):
     self._db = None
     self.signals = {
         'connect': kaa.Signal(),
         'disconnect': kaa.Signal(),
         'media.add': kaa.Signal(),
         'media.remove': kaa.Signal()
     }
     # internal list of active queries, mapping query id to a Query object weakref.
     self._queries = weakref.WeakValueDictionary()
     # internal list of items to update
     self._changed = []
     # add ourself to shutdown handler for correct disconnect
     kaa.main.signals['shutdown'].connect(self._shutdown)
     self.status = DISCONNECTED
     self.channel = kaa.rpc.connect('beacon', retry=1)
     self.channel.signals["closed"].connect(self._disconnected)
     self.channel.register(self)
     self.rpc = self.channel.rpc
Exemplo n.º 11
0
 def __init__(self, text, icon=None):
     """
     Create a new instance.
     @param text: Text to display in the button.
     @param icon: Optional image filename to be displayed.
     """
     super(ButtonModel, self).__init__()
     self.text = text
     self.icon = icon
     self.pressed = False
     self.signals['pressed'] = kaa.Signal()
     self.pressed_timer = kaa.OneShotTimer(self.__unpress)
Exemplo n.º 12
0
 def __init__(self, items=None):
     WidgetModel.__init__(self)
     self.items = []
     self.page = None
     self.offset = 0
     self.active_item = 0
     self.items_per_page = 0
     self.more_up = False
     self.more_down = False
     self.signals['selection_changed'] = kaa.Signal()
     if items:
         for item in items:
             item.parent = self
             self.items.append(item)
Exemplo n.º 13
0
 def __init__(self, name, duration):
     """
     Create a new instance.
     @param name: Name of the skin to render.
     @param duration: Time in seconds the dialog should be shown for by default.
     """
     self.name = name
     self._skin = None
     self.display = None
     self.duration = duration
     self.priority = Dialog.NORMAL_PRIORITY
     self.__first_show = True
     self.signals = kaa.Signals()
     self.signals['prepared'] = kaa.Signal()
     self.signals['shown'] = kaa.Signal()
     self.signals['hidden'] = kaa.Signal()
     self.signals['finished'] = kaa.Signal()
     self.updater = None
     self.__update_interval = 0
     self.last_render = 0.0
     if DEBUG_PERFORMANCE:
         self.__render_count = 0
         self.__first_render_time = 0.0
         self.__hide_time = 0.0
Exemplo n.º 14
0
    def watch(self, path, mask=None):
        """
        Begin monitoring a file or directory for specific events.

        :param path: the full path to the file or directory to be monitored
        :type path: str
        :param mask: a bitmask of events for which to notify, or None
                     to use the default mask (see below).
        :type mask: int
        :returns: :class:`~kaa.Signal` object that is emitted when an event occurs
                  on ``path``.

        
        The default mask is anything that causes a change (new file, deleted
        file, modified file, or attribute change on the file).
        
        Callbacks connected to the returned signal are invoked with the same
        arguments as the :attr:`~kaa.INotify.signals.event` signal.

        The total number of watches (across all INotify instances) is controlled
        by /proc/sys/fs/inotify/max_user_watches
        """
        path = os.path.realpath(fsname(path))
        if path in self._watches_by_path:
            return self._watches_by_path[path][0]

        if mask == None:
            mask = INotify.WATCH_MASK

        wd = self._libc.inotify_add_watch(self._fd, py3_b(path, fs=True), mask)
        if wd < 0:
            raise IOError('Failed to add watch on "%s"' % path)

        signal = kaa.Signal()
        self._watches[wd] = [signal, path]
        self._watches_by_path[path] = [signal, wd]
        return signal
Exemplo n.º 15
0
import time
import logging

# kaa imports
import kaa
import kaa.epg

# record imports
from recording import Recording, SCHEDULED, CONFLICT
from config import config

# get logging object
log = logging.getLogger('tvserver')

signals = {
    'changed': kaa.Signal(),
}


def init():
    # get kaa.epg database filename
    db = os.path.expandvars(os.path.expanduser(config.epg.database)).\
         replace('$(HOME)', os.environ.get('HOME'))
    kaa.epg.load(db)

    # update config.epg.mapping information


#     channels = [ c.name for c in kaa.epg.get_channels() ] + [ u'' ]
#     mapping = config.epg._cfg_get('mapping')
#     mapping._schema._type = channels
Exemplo n.º 16
0
try:
    # try to import python lirc module
    import pylirc
except ImportError:
    # pylirc not installed
    pylirc = None

_key_delay_map = [0.4, 0.2, 0.2, 0.15, 0.1]
_last_code = None
_key_delay_times = None
_last_key_time = 0
_dispatcher = None

# make sure we have the lirc signal, no matter
# if lirc is working or not
signal = kaa.Signal()
kaa.signals["lirc"] = signal


def _handle_lirc_input():
    """
    callback to handle a button press.
    """

    global _key_delay_times, _last_code, _repeat_count, _last_key_time

    now = time.time()
    codes = pylirc.nextcode()

    if codes == None:
        # Either end of repeat, or just a delay between repeats...
Exemplo n.º 17
0
import logging

# kaa imports
import kaa
import kaa.epg
from kaa.utils import property

# record imports
from config import config

# get logging object
log = logging.getLogger('tvserver')

# signals for this module
signals = {
    'changed': kaa.Signal(),
    'start-recording': kaa.Signal(),
    'stop-recording': kaa.Signal()
}

_devices = []
_channel = {}


def get_device(channel):
    return _channel.get(channel)


def get_devices():
    return _devices
Exemplo n.º 18
0
 def __init__(self, job, id, priority):
     self.valid = weakref(job)
     self.id = id
     self.priority = priority
     self.signal = kaa.Signal()
     Job.all.append(self)
Exemplo n.º 19
0
##############################################################
# Signals
#######################
print "Signals ..."


def cb_func(*arg):
    result.extend(arg)


class Cls(object):
    def meth(self, *arg):
        result.extend(arg)


sig = kaa.Signal()

sig.connect(cb_func, 42)

result = []
sig.emit()
test(result, [42])

result = []
sig.emit(42)
test(result, [42, 42])

test(sig.count(), 1)
sig.disconnect(cb_func)
test(sig.count(), 0)
Exemplo n.º 20
0
def getch_disable():
    global _tc_orig_settings
    if _tc_orig_settings != None:
        termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, _tc_orig_settings)
    os.system("stty echo")


def _handle_stdin_keypress():
    ch = getch()
    kaa.signals["stdin_key_press"].emit(ch)
    return True


_dispatcher = kaa.IOMonitor(_handle_stdin_keypress)

def _keypress_signal_changed(s, flag):
    if flag == kaa.Signal.CONNECTED and s.count() == 1:
        getch_enable()
        _dispatcher.register(sys.stdin)
    elif flag == kaa.Signal.DISCONNECTED and s.count() == 0:
        getch_disable()
        _dispatcher.unregister()


# init
signal = kaa.Signal(changed_cb = _keypress_signal_changed)
kaa.signals["stdin_key_press"] = signal
# Backward compatibility (TODO: remove in future)
kaa.signals["stdin_key_press_event"] = signal