available_languages = dict() def set_language(lang=None): from pygui.config import user_config if not lang: pass language = lang iso_code = iso(language) t = available_languages.get(iso_code) if t is None: dir_name = iso_code + '_' + iso_code.upper() try: t = gettext.translation(application, locale_dir, languages=[dir_name]) available_languages[iso_code] = t except IOError: log.error("language '%s' not available", language) return False t.install(unicode=True, names=['ngettext']) return None def init(): gettext.install(application, locale_dir, unicode=True, names=['ngettext']) init() log.info(_('Internationalisation loaded.')) def omnicode(txt): if isinstance(txt, unicode): pass else: if isinstance(txt, basestring): pass
n 0(None)[from __future__ import absolute_import from peewee.debug import GET_LOGGER from peewee.misc_utils import MetaSingleton from pygui.shared import pygui_globs import functools import fcntl log = GET_LOGGER(__name__) class WyLed(object): __doc__ = ' Switches leds on or off ' __metaclass__ = MetaSingleton def __init__(self): try: self._WyLed__wyled0 = file('/dev/wyled0', 'rw') fd = self._WyLed__wyled0.fileno() except Exception, e: log.error("Can't load Led subsystem: %s", str(e)) def self.on(): return None def self.off(): return None else: self.on = functools.partial(fcntl.ioctl, fd, 10) self.off = functools.partial(fcntl.ioctl, fd, 11) def ask_standby(self): wdb = pygui_globs['wydbus'] self.ask_standby = wdb.signal('/com/wyplay/wycrs/wylight', 'standbyAsked', '') self.ask_standby()
]: i: 0(try) o: 239() nname: 0 n 0(None)[from __future__ import absolute_import from peewee.debug import GET_LOGGER from wyvas import Container, Image, Text log = GET_LOGGER(__name__) ]: i: o: 75(try), 162(except) nname: 162 n 162(None)[except ImportError: log.error('Cannot import widgets from wyvas') from .progressbar import Progressbar from .textblock import TextBlock log.debug('pygui widgets imported') from .core.widgetfactory import WidgetLibrary ]: i: 0() o: nname: 0 n 0(None)[from __future__ import absolute_import from peewee.debug import GET_LOGGER from wyvas import Container, Image, Text log = GET_LOGGER(__name__) try: from wyvas import __version__
self.name = module.name self.position = module.position self.category = module.category.strip().lower() self._module = module self.default = getattr(module, 'default', False) self.unique = getattr(module, 'unique', False) GenericContainer.__init__(self, self.name, type_='action') def is_available(self, context): return self._module.is_available(context) def browse(self, context=None): try: return self._module.get_action_info_list(context) except Exception, e: log.error('get_action_info_list failed !') PRINT_EXCEPTION(e) return [] def __cmp__(self, other): return cmp(self.position, other.position) category_dict = dict() ]: i: o: 149(loop), 255(AL) nname: 288 n 288(None)[def get_actiongroups_by_category(context, category):
# # Description: # # GetTime Entry Point Definition # # # # Changes: # # 2012-04-15 # Initial Commit # # # Copyright 2010-2012, WyDev Team. # Author: Polo35 ([email protected]) # # Licenced under Academic Free License version 3.0 # Review WyGui README & LICENSE files for further details. from __future__ import absolute_import from peewee.debug import GET_LOGGER log = GET_LOGGER(__name__) try: from peewee._gettime import time except ImportError: log.error("Couldn't import monotonic time C module. Falling back to time.time.") from time import time
from peewee.gettime import time from peewee.debug import GET_LOGGER from Queue import Full from pygui.input import DIRECTFB_MAP from socket import socket, AF_UNIX, SOCK_STREAM import threading log = GET_LOGGER(__name__) class PluginInterface(.): __doc__ = '\n Plugin for stdin control.\n ' def __init__(self, *args): threading.Thread.__init__(self) try: self.lircd = socket(AF_UNIX, SOCK_STREAM) self.lircd.connect('/dev/lircd') except: log.error("Can't load lirc plugin") del self.lircd else: self.kbmap_get = DIRECTFB_MAP.get self.setDaemon(True) self.setName('LircPlugin') Task(self.start).start(1.0) def run(self): pass ]: i: o:
self._vol = val return None def getmute(self): return (self._mute, self._mute) def setmute(self, val): self._mute = val return None try: from alsaaudio import Mixer, ALSAAudioError except: log.error('ALSA not found ! using FakeMixer instead') Mixer = FakeMixer ALSAAudioError = Exception class Mix(object): __metaclass__ = MetaSingleton def __init__(self, control='Primary', id=0, card='hw:4'): self._mixers = dict() self._limiters = dict() self._def_control = control self._def_id = id self._def_card = card
if play._timeout_timer: play._timeout_timer.stop() play.hide() play.timeout_callback() return True class CancelOnlyEventHandler(WindowEventHandler): def event_stop(self, event): play = self.player if play._cancel_fn: try: play._cancel_fn() except Exception, e: log.error('Cancel action failed: %s', str(e)) return True class NoHomeEventHandler(CancelOnlyEventHandler): def event_home(self, event): return True class ButtonListEventHandler(WindowEventHandler): def event_left(self, event): play = self.player sel_idx = play.buttons.index(play.selected) if sel_idx > 0:
# Note that the process is asynchronous -- L{_transition} is called once # the picture is properly loaded. # # TODO Handle failure cases via callbacks (once wyvas supports that). def _display_picture(self): try: louie_send('picture_%d' % pos[0], sender=self, value=self.selected['uri'], callback=self.tasks['transition'].start) except IOError, e: from pygui.window import MessageWindow MessageWindow(_('Invalid picture'), button=None).show(timeout=5) except: PRINT_EXCEPTION() log.error('Unable to display this image') return None # Retrieve the rotation information for the current picture, and apply it. def _apply_rotation(self): self.selected.media_update('rotation') rot = int( self.selected['rotation'] if self.selected['rotation'] else 0) log.info('rotation=%i', rot) louie_send('picture_%i' % pos[0], sender=self, rotate=rot) return None # Launch the transition between current and next picture. def _transition(self): global pos anim = user_config['photo']['transition']
self.template = copy(tpl_base) if self.config != None and isinstance(self.config, dict): try: tu_keys = tpl_updaters.keys() tu_keys.sort() for tu_key in tu_keys: pos, trigger_key, trigger_value = tu_key.split('_') if self.config.get(trigger_key, '') == trigger_value: tu_value = tpl_updaters[tu_key] self.template.update(tu_value) except Exception, e: log.error('no template match your config') PRINT_EXCEPTION(e) self.template = None else: log.error('config must be a dict: %s', self.config) self.template = None return None def __repr__(self): return '<%s::%s:%s %s>' % (self.__class__.__name__, repr( self.name), repr(self.autoname), self.config) def __setitem__(self, key, value): self.config[key] = value return None def __getitem__(self, key): return self.config[key] def __contains__(self, key):
def hide(self): if self._autohide_timeout: self._autohide_timeout.stop() if self.parent: try: self.parent.children.remove(self) except Exception, e: log.error('Error while removing %s from %s.children', self, self.parent) PRINT_EXCEPTION(e) stack = pygui_globs['menustack'] try: stack.close_player(self) except ValueError: log.error("Can't hide %s !", self) PRINT_EXCEPTION() finally: self.hide_help() return None def _autohide(self): if not self.children: log.debug('%s no children: calling hide()', self) Task(self._autohide_timeout.stop).start(0) self.hide() else: log.debug('%s has children %s ! avoid autohide', self, self.children) return None
n 47(None)[from peewee._gettime import time ]: i: 0(try) o: 115() nname: 0 n 0(None)[from __future__ import absolute_import from peewee.debug import GET_LOGGER log = GET_LOGGER(__name__) ]: i: o: 47(try), 67(except) nname: 67 n 67(None)[except ImportError: log.error("Couldn't import monotonic time C module. Falling back to time.time.") from time import time ]: i: 0() o: nname: 0 n 0(None)[from __future__ import absolute_import from peewee.debug import GET_LOGGER log = GET_LOGGER(__name__) try: from peewee._gettime import time ]: i: o: 67()
il.end = il.start + nb_positions if self._bar is not None: self._bar.animate('move', vcenter=self.positions_list[il.selected - il.start]._y, duration=self.duration) return None def create_content(self): if self._initialized: pass self._initialized = True nb_items = len(self.positions_list) start = max(0, self.menu_list.selected_pos // nb_items * nb_items) GenericListing._create_content(self, start, self.style_name) try: self._pagejump_func = getattr(self, '_pagejump_' + self.style_dict['page_jump']) except: log.error('Unknown page_jump type: %s', self.style_dict['page_jump']) self._pagejump_func = self._pagejump_reset def do_reset(self, position=None, focus=None): ml = self.menu_list il = self.item_list if focus is None: focus = ml.selected_pos nb_items = len(self.positions_list) start = max(0, focus // nb_items * nb_items) end = start + nb_items selected = ml.selected if position is not None: try: menu_item = ml[position] ui_item = il[position - start]
o: self.nodes: {6: <unpyclib.structure.node instance at 0xb75e138c>} nname: 0 n 0(None)[from __future__ import absolute_import from pygui.config import plugins from .macros import MACRO_GLOBS from peewee.debug import GET_LOGGER from peewee.formatters import string_or_float log = GET_LOGGER(__name__) def in_set(*args): values_set = set(args) def _aux(value): if value in values_set: return value log.error('Invalid value %s : not in %s', value, args) return args[0] return _aux _step_type_cast = in_set('linear', 'log', 'exp', 'samples', 'easein', 'easeout', 'easeinout', 'bounce') _animation_list = ['size', 'opacity', 'move', 'color'] _att_cast_list = {'name': None, 'opacity': float, 'opacity_min': float, 'opacity_max': float, 'width': string_or_float, 'height': string_or_float, 'left': string_or_float, 'right': string_or_float, 'top': string_or_float, 'bottom': string_or_float, 'hcenter': string_or_float, 'vcenter': string_or_float, 'a': int, 'r': int, 'g': int, 'b': int, 'starting_offset': float, 'duration': float, 'step_type': _step_type_cast} def _py_macro_call(m, cast): return (lambda : cast(eval('%s' % m[3:], MACRO_GLOBS))) class Anim(object): __doc__ = '\n class used to stock informations about a certain animation.\n ' def _cast_att(self, dict): for key, val in dict.iteritems(): castor = _att_cast_list.get(key, None)
log.info('Loading players...') import pygui.config as config ]: i: o: 227(t), 273(f) nname: 1020 n 1020(None)[log.info('Players loaded!') ]: i: 227(), 971() o: nname: 971 n 971(None)[except Exception, e: WebBrowser = None log.error('Web Browser loading error: %s', str(e)) ]: i: 935() o: 1020() nname: 935 n 935(None)[try: from pygui.menu.players.web_browser import WebBrowser log.debug('Web Browser loaded') ]: i: 853() o: 971() nname: 853 n 853(None)[try: from pygui.menu.players.channelscanner import ChannelScanner log.debug('Channel Scanner loaded')
ml = self.menu_list if ml.selected is None or il.selected == position: return True nb_positions = len(self.positions_list) midpos = nb_positions >> 1 ml[position:position + midpos] if position <= midpos: start = 0 else: if position < len(ml) - midpos: start = position - midpos else: start = max(0, len(ml) - nb_positions) end = start + nb_positions if self._edited: log.error('Changing selection while editing') ts = sched.ts duration = max(0.001, min(self.duration, ts - self._last_timestamp - 0.12)) self._last_timestamp = ts il[il.selected - il.start].selected = False GenericListing._scroll(self, start - il.start, duration, None) il[position - start].selected = True il_get_focused = il.selected == -1 il.selected = position il.start = start il.end = end self._refresh_more_items() if self._bar is not None: if il_get_focused: self._bar.animate('move', vcenter=self.positions_list[position - start]._y, duration=0) self._bar.show()
title = _('Conflict with an instant recording') MessageWindow(message, title, button=None).show(timeout=5) except SchedulerConflictError, e: conflicting_rec = e.conflict.getAllRecInConflict()[0] message_pattern = _( 'The recording you are attempting to schedule conflicts with "%(name)s", starting at %(start_time)s on %(channel)s.' ) message = message_pattern % { 'name': ellipsize(conflicting_rec.name, 40), 'start_time': seconds_to_hhmm(conflicting_rec.start_time), 'channel': conflicting_rec.service_name } title = _('Recording scheduler error') MessageWindow(message, title, button=None).show(timeout=5) except SchedulerError, e: log.error("Can't start recording due to %s", e) title = _('Recording scheduler error') message = 'Unable to schedule your recording. Sorry.' MessageWindow(message, title, button=None).show(timeout=5) else: message = _('The program is over. You cannot record it.') title = _('Program already over') win = MessageWindow(message, title, button=None) win.show(timeout=5) return None # Cancel the scheduled recording of the selected program. # # TODO Factor this out, it's cut&pasted from epg_grid.py. def cancel_record_selected(self): program = self.selected
return None class NetItem(MediaItem): __doc__ = 'Network resource of some sort. Has an embedded URI that the user\n can attempt to read as any standard wymedia type (audio, video, image...).\n\n Of course, since the URI only has one type, only one of play_as_audio(),\n play_as_video() and play_as_image() will work -- the other two will display\n an error dialog.\n\n The standard play() method launches the NetPlayer (text+thumbnail+metadata\n visualization).\n\n TODO Automatically play the item as the correct type (requires extra\n metadata).\n ' player = None media_update_fields = () def __init__(self, wymedia_resource, type_='net', menu=None, **kw): MediaItem.__init__(self, wymedia_resource, type_=type_, menu=menu, **kw) if NetItem.player is None: try: from pygui.menu.players.net_player import NetPlayer NetItem.player = NetPlayer() except Exception, e: log.error('Unable to spawn NetPlayer: %r', e) return None def execute(self): items = self.parent.browse() self.player.play(self, items) def play_embedded_audio(self): forged_item = AudioItem(self.name, menu=self.menu, parent=self, uri=self['uri'], backend='dummy') forged_item.player.play(forged_item, [forged_item]) def play_embedded_video(self): forged_item = VideoItem(self.name, menu=self.menu, parent=self, uri=self['uri'], backend='dummy') forged_item.player.play(forged_item, [forged_item]) def play_embedded_image(self):