Ejemplo n.º 1
0
 def read_onkyo_section_xml(p_pyhouse_obj):
     """ Get the entire OnkyoDeviceData object from the xml.
     """
     # Clear out the data sections
     l_xml = XmlConfigTools.find_section(p_pyhouse_obj, 'HouseDivision/EntertainmentSection/OnkyoSection')
     l_entry_obj = p_pyhouse_obj.House.Entertainment.Plugins[SECTION]
     l_entry_obj.Name = SECTION
     l_device_obj = OnkyoDeviceData()
     l_count = 0
     if l_xml is None:
         l_entry_obj.Name = 'Did not find xml section '
         return l_entry_obj
     try:
         l_entry_obj.Type = PutGetXML.get_text_from_xml(l_xml, 'Type')
         for l_device_xml in l_xml.iterfind('Device'):
             l_device_obj = XML._read_device(l_device_xml)
             l_device_obj.Key = l_count
             l_entry_obj.Devices[l_count] = l_device_obj
             l_entry_obj.Count += 1
             LOG.info('Loaded Onkyo Device {}'.format(l_entry_obj.Name))
             l_count += 1
     except AttributeError as e_err:
         LOG.error('ERROR if getting Onkyo Device Data - {}'.format(e_err))
     if l_count > 0:
         l_entry_obj.Active = True
     LOG.info('Loaded {} Onkyo Devices.'.format(l_count))
     return l_entry_obj
Ejemplo n.º 2
0
    def read_pandora_section_xml(p_pyhouse_obj):
        """
        This has to:
            Fill in an entry in Entertainment Plugins

        @param p_pyhouse_obj: containing an XML Element for the <PandoraSection>
        @return: a EntertainmentPluginData object filled in.
        """
        l_plugin_obj = p_pyhouse_obj.House.Entertainment.Plugins[SECTION]
        l_plugin_obj.Name = SECTION
        l_xml = XmlConfigTools.find_section(p_pyhouse_obj, 'HouseDivision/EntertainmentSection/PandoraSection')
        if l_xml is None:
            return l_plugin_obj
        l_count = 0
        try:
            l_plugin_obj.Active = PutGetXML.get_bool_from_xml(l_xml, 'Active')
            l_plugin_obj.Type = PutGetXML.get_text_from_xml(l_xml, 'Type')
            for l_device_xml in l_xml.iterfind('Device'):
                l_device_obj = XML._read_device(l_device_xml)
                l_device_obj.Key = l_count
                l_plugin_obj.Devices[l_count] = l_device_obj
                LOG.info('Loaded {} Device {}'.format(SECTION, l_plugin_obj.Name))
                l_count += 1
                l_plugin_obj.Count = l_count
        except AttributeError as e_err:
            LOG.error('ERROR if getting {} Device Data - {}'.format(SECTION, e_err))
        p_pyhouse_obj.House.Entertainment.Plugins[SECTION] = l_plugin_obj
        LOG.info('Loaded {} {} Devices.'.format(l_count, SECTION))
        return l_plugin_obj
Ejemplo n.º 3
0
 def read_samsung_section_xml(p_pyhouse_obj):
     l_xml = XmlConfigTools.find_section(p_pyhouse_obj, 'HouseDivision/EntertainmentSection/SamsungSection')
     l_entertain_obj = p_pyhouse_obj.House.Entertainment
     l_plugin_obj = l_entertain_obj.Plugins[SECTION]
     l_plugin_obj.Name = SECTION
     l_plugin_obj.Active = PutGetXML.get_bool_from_xml(l_xml, 'Active')
     l_count = 0
     if l_xml is None:
         return l_plugin_obj
     try:
         l_plugin_obj.Type = PutGetXML.get_text_from_xml(l_xml, 'Type')
         for l_device_xml in l_xml.iterfind('Device'):
             l_device_obj = XML._read_device(l_device_xml)
             l_device_obj.Key = l_count
             l_plugin_obj.Devices[l_count] = l_device_obj
             LOG.info('Loaded {} Device {}'.format(SECTION, l_plugin_obj.Name))
             l_count += 1
             l_plugin_obj.Count = l_count
     except AttributeError as e_err:
         LOG.error('ERROR if getting {} Device Data - {}'.format(SECTION, e_err))
     p_pyhouse_obj.House.Entertainment.Plugins[SECTION] = l_plugin_obj
     LOG.info('Loaded {} {} Device(s).'.format(l_count, SECTION))
     return l_plugin_obj
Ejemplo n.º 4
0
    def LoadXml(self, p_pyhouse_obj):
        """ Read the entertainment section.
        Everything present in the XML must be read into the pyhouse_obj structure.

        SubSections not active will not be loaded or instantiated.

        If a subsection is available, load its module and let it read the xml for itself.

        @return: the Entertainment object of PyHouse_obj
        """
        LOG.info("XML Loading - Version:{}".format(__version__))
        l_entertain = p_pyhouse_obj.House.Entertainment
        l_xml = XmlConfigTools.find_section(p_pyhouse_obj, 'HouseDivision/EntertainmentSection')
        if l_xml == None:
            l_entertain.Active = False
            return l_entertain
        l_count = 0
        for l_section_element in l_xml:
            self._module_load_loop(p_pyhouse_obj, l_section_element)
            l_count += 1
        l_entertain.Active = True
        l_entertain.Count = l_count
        LOG.info('XML Loaded {} Entertainment Sections'.format(l_count))
        return l_entertain