Ejemplo n.º 1
0
class TNTScanMenuSetupItem(ParametersSetupItem):

    depth = 2

    def __init__(self, *args, **kw):
        ParametersSetupItem.__init__(self, *args, **kw)
        self.include_scrambled = user_config['tv']['scan_with_scrambled']
        self.all_channels_item = ActionItem(
            _('Free and pay channels'),
            type_='setupitem',
            display_type=('checked'
                          if self.include_scrambled else 'not_checked'),
            action=self.set_include_scrambled,
            args=(True, ))
        self.free_channels_only_item = ActionItem(
            _('Free channels only'),
            type_='setupitem',
            display_type=('not_checked'
                          if self.include_scrambled else 'checked'),
            action=self.set_include_scrambled,
            args=(False, ))
        self.preview_list = [
            self.all_channels_item, self.free_channels_only_item,
            TNTAutomaticScanItem(parent=self,
                                 name='Start scan',
                                 type_='setupitem')
        ]
        return None

    # Set whether to include scrambled channels in the scan, and
    # update the display accordingly.
    #
    # Note: Canal+, being scrambled only part of the time, is considered
    # a free (not scrambled) channel for the purposes of the scan.
    def set_include_scrambled(self, value):
        self.include_scrambled = value
        self.all_channels_item.display_type = ('checked'
                                               if value else 'not_checked')
        self.free_channels_only_item.display_type = ('not_checked'
                                                     if value else 'checked')
        self.all_channels_item.reset_view()
        self.free_channels_only_item.reset_view()
        return None
Ejemplo n.º 2
0
class ExtraSetupItem(ParametersSetupItem):
    def __init__(self, extra_num, *args, **kw):
        ParametersSetupItem.__init__(self, *args, **kw)
        self.extra_num = extra_num
        self.Start_Extra_Item = ActionItem(_('Start Extra'),
                                           type_='setupitem',
                                           display_type=self._get_extra_status(
                                               'yes', 1),
                                           action=self._start_extra,
                                           args=[])
        self.Stop_Extra_Item = ActionItem(_('Stop Extra'),
                                          type_='setupitem',
                                          display_type=self._get_extra_status(
                                              'no', 1),
                                          action=self._stop_extra,
                                          args=[])
        self.Enable_Extra_Item = ActionItem(
            _('Enable Extra'),
            type_='setupitem',
            display_type=self._get_extra_status('running', 2),
            action=self._enable_extra,
            args=[])
        self.Disable_Extra_Item = ActionItem(
            _('Disable Extra'),
            type_='setupitem',
            display_type=self._get_extra_status('stopped', 2),
            action=self._disable_extra,
            args=[])
        self.preview_list = [
            self.Start_Extra_Item, self.Stop_Extra_Item,
            self.Enable_Extra_Item, self.Disable_Extra_Item
        ]

    def _get_extra_status(self, val, key):
        global global_extras_status
        ret_status = 'not_checked'
        if val in global_extras_status[self.extra_num][key]:
            ret_status = 'checked'
        return ret_status

    def _start_extra(self):
        global global_extras_status
        os.system("/wymedia/usr/bin/extras start %s" %
                  (global_extras_status[self.extra_num][0]))
        self.Start_Extra_Item.display_type = 'checked'
        self.Stop_Extra_Item.display_type = 'not_checked'
        self.Start_Extra_Item.reset_view()
        self.Stop_Extra_Item.reset_view()

    def _stop_extra(self):
        global global_extras_status
        os.system("/wymedia/usr/bin/extras stop %s" %
                  (global_extras_status[self.extra_num][0]))
        self.Start_Extra_Item.display_type = 'not_checked'
        self.Stop_Extra_Item.display_type = 'checked'
        self.Start_Extra_Item.reset_view()
        self.Stop_Extra_Item.reset_view()

    def _enable_extra(self):
        global global_extras_status
        os.system("/wymedia/usr/bin/extras enable %s" %
                  (global_extras_status[self.extra_num][0]))
        self.Enable_Extra_Item.display_type = 'checked'
        self.Disable_Extra_Item.display_type = 'not_checked'
        self.Enable_Extra_Item.reset_view()
        self.Disable_Extra_Item.reset_view()

    def _disable_extra(self):
        global global_extras_status
        os.system("/wymedia/usr/bin/extras disable %s" %
                  (global_extras_status[self.extra_num][0]))
        self.Enable_Extra_Item.display_type = 'not_checked'
        self.Disable_Extra_Item.display_type = 'checked'
        self.Enable_Extra_Item.reset_view()
        self.Disable_Extra_Item.reset_view()

    def reset_view(self):
        self.preview_list[0].display_type = self._get_extra_status('yes', 1)
        self.preview_list[1].display_type = self._get_extra_status('no', 1)
        self.preview_list[2].display_type = self._get_extra_status(
            'running', 2)
        self.preview_list[3].display_type = self._get_extra_status(
            'stopped', 2)
        for i in range(len(self.preview_list)):
            self.preview_list[i].reset_view()
        ParametersSetupItem.reset_view(self)