def live_catalog(self): if os.path.isfile(CACHE_FILE): f = open(CACHE_FILE, 'r') try: self.catalog = pickle.load(f) except: self.catalog = None f.close() else: self.catalog = None if self.catalog is None or self.catalog.is_old(): url = urllib.urlopen(LIVE_XML_CATALOG) catalog_xml = url.read() url.close() try: channels = etree.XML(catalog_xml) except etree.XMLSyntaxError: msg_win = MessageWindow(text=_( 'XML file is malformed !!!\nPlease wait while BeautifulSoup fix it' ), title=_('XML Error'), button=False) msg_win.show() catalog_xml = str(BeautifulStoneSoup(catalog_xml)) try: msg_win.hide() except: pass self.catalog = Catalog(catalog_xml) if not os.path.exists(CACHE_DIR): os.mkdir(CACHE_DIR) f = open(CACHE_FILE, 'w') pickle.dump(self.catalog, f) f.close() return self.catalog.catalog
def _copy_ts(ts_file, psp_path): psp_mp4_file, psp_thm_file = _get_psp_filenames(psp_path) msg = MessageWindow(_('Copying to PSP (tm) please wait...'), button=None) msg.show() mp4_cmd = '/usr/bin/ts2psp "%s" "%s"' % (ts_file, psp_mp4_file) thm_cmd = 'cp "%s" "%s"' % (thm_src_file, psp_thm_file) log.debug(mp4_cmd) os.system(mp4_cmd) log.debug(thm_cmd) os.system(thm_cmd) os.system('sync') sleep(2) msg.hide() return None
'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 rec_id = program.recording_id if rec_id: log.info('Canceling recording for %s', program) try: WyRecord().scheduler.DeleteRecording(rec_id) except SchedulerRecordingRunningError: error_title = _('Impossible to cancel recording') message = _(
exists = os.path.exists psp_prefix = os.path.join(psp_path, 'video', 'M4V') while exists(psp_prefix + '%s.MP4' % index) or exists(psp_prefix + '%s.THM' % index): index -= 1 else: _POP_TOP pass return (psp_prefix + '%s.MP4' % index, psp_prefix + '%s.THM' % index) ]: i: o: self.nodes: {0: <unpyclib.structure.node instance at 0xb7748e6c>} nname: 0 n 0(None)[psp_mp4_file, psp_thm_file = _get_psp_filenames(psp_path) msg = MessageWindow(_('Copying to PSP (tm) please wait...'), button=None) msg.show() mp4_cmd = '/usr/bin/ts2psp "%s" "%s"' % (ts_file, psp_mp4_file) thm_cmd = 'cp "%s" "%s"' % (thm_src_file, psp_thm_file) log.debug(mp4_cmd) os.system(mp4_cmd) log.debug(thm_cmd) os.system(thm_cmd) os.system('sync') sleep(2) msg.hide() return None ]: i: o: self.nodes: {0: <unpyclib.structure.node instance at 0xb7748fec>}
class RootMenu(Menu): def __init__(self): self.eventHandler = EventDispatcher(self) self._navigator = None Menu.__init__(self, 'root', type='root') self._getitems_keywords['message'] = ( lambda: _('Press Home to switch universe')) import wymedia.wmplus as w w.register_plug_callback( (lambda obj: Task(self.device_plugged, obj, True).start(0))) w.register_unplug_callback( (lambda obj: Task(self.device_plugged, obj, False).start(0))) self._controlmode_popup = None usb_mode = self._get_usb_mode() if usb_mode == 'MTP': from peewee.controlmode import ControlModeManager ctrl = ControlModeManager() ctrl.register_observer(self.control_changed) pygui_globs['controlmodemanager'] = ctrl elif usb_mode == 'PS3': self.control_changed('mtp_off', True, True) self.active_univ = None return None # USB MTP or PS3 mode def _get_usb_mode(self): import os if not os.path.exists('/wymedia/usr/etc/usbcable.conf'): return 'MTP' conf_file = os.popen('cat /wymedia/usr/etc/usbcable.conf') lines = conf_file.readlines() conf_file.close() for line in lines: line = line.replace('\n', '') if line == '': continue elif 'Mode MTP' in line: return 'MTP' elif 'Mode PS3' in line: return 'PS3' # Called when control mode change (mtp) def control_changed(self, mode, rcu, standby): from peewee.notifier import events_drop from pygui.facilities.power import PowerManager from pygui.menu.menu.bsod import BSoDMenu log.debug('Control changed: mode=%s rcu=%s standby=%s', mode, rcu, standby) msg = control_mode_popup_dict[mode] if rcu: if self._controlmode_popup: self._controlmode_popup.hide() self._controlmode_popup = None events_drop(False) plugins.discard('popup_blocker') if standby == False: stack = pygui_globs['menustack'] if not stack.is_on_firstboot(): stack.back_to_home() MessageWindow(msg, button=None).show(timeout=3) else: events_drop(True) plugins.add('popup_blocker') stack = pygui_globs['menustack'] if not stack.is_on_firstboot(): stack.back_to_home() BSoDMenu().show() self._controlmode_popup = MessageWindow(msg, button=None) self._controlmode_popup.show() return None # Called When A Device Is Plugged def device_plugged(self, obj, plugged): if not obj.get('title'): name = _('Unknown device') else: name = obj.get('title') if plugged: msg_template = _('Device "%(name)s" plugged in.') else: msg_template = _('Device "%(name)s" removed.') msg = msg_template % {'name': name} log.debug('%s / %s', msg, name) stack = pygui_globs['menustack'] # if plugged: # if 'WYDEMO' in obj['title'].upper(): # from pygui.facilities.demomode import handle_demo # handle_demo(obj) if 'popup_blocker' in plugins: stack.get_player() else: MessageWindow(msg, button=None).show(timeout=3) if 'transcode' in plugins and name.startswith("PSP"): pygui_globs['psp_path'] = obj.get(uri) nav = self._navigator if nav is not None and nav in stack: if not plugged: concerned = False try: for h in nav._history: if h['selected'] and obj['id'] == h[ 'selected'].wymedia_resource['id']: concerned = True except: pass if concerned: stack.close_player() stack.back_to_menu(nav) nav.back_to_root() from pygui.markerlist import markerlists for mlist in markerlists(): mlist._refresh() nav._update_marker() if nav is stack.get_navigator(): log.debug('calling _refresh_root()') nav._refresh_root() if nav._history: log.debug('calling build_preview()') nav.build_preview() return None def show(self, hide_previous_menu=True, timeout=None): Menu.show(self, hide_previous_menu, timeout) if 'restore_last_universe' in plugins and not user_config['advanced'][ 'last_universe']: louie_send('show_select_universe', sender=self) return None def launch_parameters(self): def _display_setup(): from pygui.menu.menu.parameters import MainSetupParametersNotebookMenu from pygui.item.parameters.generalsetup import GeneralConfigurationItem user_config['security']['parent_mode'] = True user_config.save() sm = MainSetupParametersNotebookMenu( name=_('Parameters'), type='notebook_setup_parameters', universe='parameters') sm.show(sub_to_show=GeneralConfigurationItem) return None def _display_qa(): from pygui.menu.menu.security import QuestionAnswerCheckLauncher QuestionAnswerCheckLauncher(_display_setup) return None if user_config['security']['parent_mode'] or not user_config[ 'security']['parental_control']: _display_setup() else: from .parameters import SecretCodeCheckMenu sc = SecretCodeCheckMenu(name=_('Check PIN Code'), action=_display_setup, cancel_action=_display_qa) pygui_globs['menustack'].push_menu(sc) return None # Attempt to launch the TV universe, prompting for and launching # a scan if required. def launch_tv(self): def _fullscan(): from pygui.item.parameters.tv.tvsetup import TNTAutomaticScanItem item = TNTAutomaticScanItem(parent=None, name=_('Automatic scan'), type_='setupitem') item.menu = self item.execute() return None # Prompt the user to launch a TV scan. If the user answers yes, # the TV player is launched after the scan's completion. # # If play_on_no equals True, attempt to launch the TV player # regardless of the user's answer (e.g. if the only channel # is the analog capture and the user doesn't want to scan). def prompt_tv_scan(play_on_no=False): buttons = [Button(_('Yes'), True), Button(_('No'), False)] buttons[0].connect(_fullscan) if play_on_no: buttons[1].connect(ChannelItem.player.play) messbox = ConfirmWindow( text=_('Do you want to launch a scan now?'), buttons=buttons) messbox.show() return None try: acl = TVRootItem().get_acl(menu=self) channels = acl.browse() num_channels = len(channels) except: w = MessageWindow(text=_( 'Channels are unavailable. Please try again.\nIf the problem persists, launch a scan or reset to factory defaults.' ), title=_('TV failure')) w.show(timeout=3) PRINT_EXCEPTION() return None user_config['advanced']['last_universe'] = 'tv' user_config.save() if num_channels == 0: _fullscan() elif num_channels == 1 and channels[0]['class'].endswith( 'videoCapture'): prompt_tv_scan(play_on_no=True) else: ChannelItem.player.play() return None def launch_net_services(self, name): from peewee.networkmanager import NetworkManager NM = NetworkManager() if NM.get_state() == 'disconnected': stack.back_to_home() MessageWindow(text='Please configure connection', title='Not connected', button=False).show(timeout=5) else: if name == 'net_services': from wymedia.wmplus import set_param login, password = user_config['net']['login'], user_config[ 'net']['password'] if login is not None: log.info("'user' param set for net services'") set_param('user', login) if password is not None: log.info("'pass' param set for net services'") set_param('pass', password) lang = user_config['base']['language'] log.info("'lang' param set for net services'") set_param('lang', lang) if self._navigator is None: from pygui.menu.menu import Navigator self._navigator = Navigator(name, name, [], type=name) else: self._navigator.reset(name, type=name, universe=name) self._navigator.show() user_config['advanced']['last_universe'] = name user_config.save() return None def launch_navigator(self, name): if self._navigator is None: from pygui.menu.menu import Navigator self._navigator = Navigator(name, name, [], type=name) else: self._navigator.reset(name, type=name, universe=name) self._navigator.show() user_config['advanced']['last_universe'] = name user_config.save() return None launch_multiverse, launch_audio, launch_video, launch_video_image, launch_image = launch_navigator, launch_navigator, launch_navigator, launch_navigator, launch_navigator def launch_testmenu(self): from pygui.menu.menu.test_menu import GenMenu GenMenu().show() return None def launch_hdmi(self): from .bsod import BSoDMenu hdmi_menu = BSoDMenu() pygui_globs['menustack'].push_menu(hdmi_menu) return None launch_hdmi_tv_1, launch_hdmi_tv_2, launch_hdmi_tv = launch_hdmi, launch_hdmi, launch_hdmi def launch_failsafe(self): from pygui.menu.menu import FailsafeMenu FailsafeMenu().show() return None