Exemple #1
0
 def _read_one_schedule(p_schedule_element):
     l_obj = Xml._read_one_base_schedule(p_schedule_element)
     if l_obj.ScheduleType == 'Lighting':
         l_type = Xml._read_one_lighting_schedule(p_schedule_element)
     else:
         LOG.error('ERROR - invalid device found - {} for {}'.format(l_obj.ScheduleType, l_obj.Name))
         l_type = {}
     stuff_new_attrs(l_obj, l_type)
     return l_obj
Exemple #2
0
 def _read_one_schedule(p_schedule_element):
     l_obj = Xml._read_one_base_schedule(p_schedule_element)
     if l_obj.ScheduleType == 'Lighting':
         l_type = Xml._read_one_lighting_schedule(p_schedule_element)
     else:
         LOG.error('ERROR - invalid device found - {} for {}'.format(
             l_obj.ScheduleType, l_obj.Name))
         l_type = {}
     stuff_new_attrs(l_obj, l_type)
     return l_obj
Exemple #3
0
 def test_01_StuffAttrs(self):
     l_objA = CoreLightingData()
     l_objA.Name = 'Test 1A'
     # print(PrettyFormatAny.form(l_objA, 'Obj A'))
     l_objB = LocationData()
     l_objB.Street = 'Some road'
     # print(PrettyFormatAny.form(l_objB, 'Obj B', 120))
     #
     stuff_new_attrs(l_objA, l_objB)
     # print(PrettyFormatAny.form(l_objA, 'Result B stuffed into A', 120))
     self.assertEqual(l_objA.Street, 'Some road')
 def test_01_StuffAttrs(self):
     l_objA = CoreLightingData()
     l_objA.Name = 'Test 1A'
     # print(PrettyFormatAny.form(l_objA, 'Obj A'))
     l_objB = LocationData()
     l_objB.Street = 'Some road'
     # print(PrettyFormatAny.form(l_objB, 'Obj B', 120))
     #
     stuff_new_attrs(l_objA, l_objB)
     # print(PrettyFormatAny.form(l_objA, 'Result B stuffed into A', 120))
     self.assertEqual(l_objA.Street, 'Some road')
Exemple #5
0
 def ReadXml(p_device_obj, p_in_xml):
     """
     @param p_in_xml: is the e-tree XML house object
     @param p_house: is the text name of the House.
     @return: a dict of the entry to be attached to a house object.
     """
     l_obj = UPBData()
     l_obj.UPBAddress = PutGetXML.get_int_from_xml(p_in_xml, 'UPBAddress', 255)
     l_obj.UPBNetworkID = PutGetXML.get_int_from_xml(p_in_xml, 'UPBNetworkID')
     l_obj.UPBPassword = PutGetXML.get_int_from_xml(p_in_xml, 'UPBPassword')
     stuff_new_attrs(p_device_obj, l_obj)
     return l_obj  # for testing
Exemple #6
0
    def ReadXml(p_device_obj, p_in_xml):
        """
        A method to extract Insteon specific elements and insert them into an Insteon data object.

        We do this to keep the Insteon Data encapsulated.

        @param p_in_xml: is the device's XML element
        @param p_device_obj : is the Basic Object that will have the extracted elements inserted into.
        @return: a dict of the extracted Insteon Specific data.
        """
        l_insteon_obj = Xml._read_insteon(p_in_xml)
        stuff_new_attrs(p_device_obj, l_insteon_obj)
        return l_insteon_obj  #  For testing only
Exemple #7
0
 def ReadXml(p_device_obj, p_in_xml):
     """
     @param p_in_xml: is the e-tree XML house object
     @param p_house: is the text name of the House.
     @return: a dict of the entry to be attached to a house object.
     """
     l_obj = UPBData()
     l_obj.UPBAddress = PutGetXML.get_int_from_xml(p_in_xml, 'UPBAddress',
                                                   255)
     l_obj.UPBNetworkID = PutGetXML.get_int_from_xml(
         p_in_xml, 'UPBNetworkID')
     l_obj.UPBPassword = PutGetXML.get_int_from_xml(p_in_xml, 'UPBPassword')
     stuff_new_attrs(p_device_obj, l_obj)
     return l_obj  # for testing
Exemple #8
0
 def read_interface_xml(p_controller_obj, p_controller_xml):
     """Update the controller object by extracting the passed in XML.
     """
     if p_controller_obj.InterfaceType == 'Ethernet':
         l_interface = ethernetXML.read_interface_xml(p_controller_xml)
     elif p_controller_obj.InterfaceType == 'Serial':
         l_interface = serialXML.read_interface_xml(p_controller_xml)
     elif p_controller_obj.InterfaceType == 'USB':
         l_interface = usbXML.read_interface_xml(p_controller_xml)
     else:
         LOG.error('Reading a controller driver interface section  For {} - Unknown InterfaceType - {}'.format(p_controller_obj.Name, p_controller_obj.InterfaceType))
         l_interface = None
     stuff_new_attrs(p_controller_obj, l_interface)
     return l_interface  # for testing
Exemple #9
0
 def test_01_WriteSerialXml(self):
     l_interface = serialXML.read_interface_xml(self.m_xml.controller)
     stuff_new_attrs(self.m_controller_obj, l_interface)
     l_xml = ET.Element('TestOutput')
     l_xml = serialXML.write_interface_xml(l_xml, self.m_controller_obj)
     # print(PrettyFormatAny.form(l_xml, "Interface"))
     self.assertEqual(l_xml.find('BaudRate').text, TESTING_SERIAL_BAUD_RATE)
     self.assertEqual(l_xml.find('ByteSize').text, TESTING_SERIAL_BYTE_SIZE)
     self.assertEqual(l_xml.find('DsrDtr').text, TESTING_SERIAL_DSR_DTR)
     self.assertEqual(l_xml.find('Parity').text, TESTING_SERIAL_PARITY)
     self.assertEqual(l_xml.find('RtsCts').text, TESTING_SERIAL_RTS_CTS)
     self.assertEqual(l_xml.find('StopBits').text, TESTING_SERIAL_STOP_BITS)
     self.assertEqual(l_xml.find('Timeout').text, TESTING_SERIAL_TIMEOUT)
     self.assertEqual(l_xml.find('XonXoff').text, TESTING_SERIAL_XON_XOFF)
Exemple #10
0
 def read_interface_xml(p_controller_obj, p_controller_xml):
     """Update the controller object by extracting the passed in XML.
     """
     if p_controller_obj.InterfaceType == 'Ethernet':
         l_interface = ethernetXML.read_interface_xml(p_controller_xml)
     elif p_controller_obj.InterfaceType == 'Serial':
         l_interface = serialXML.read_interface_xml(p_controller_xml)
     elif p_controller_obj.InterfaceType == 'USB':
         l_interface = usbXML.read_interface_xml(p_controller_xml)
     else:
         LOG.error(
             'Reading a controller driver interface section  For {} - Unknown InterfaceType - {}'
             .format(p_controller_obj.Name, p_controller_obj.InterfaceType))
         l_interface = None
     stuff_new_attrs(p_controller_obj, l_interface)
     return l_interface  # for testing
Exemple #11
0
 def _make_message(p_pyhouse_obj, p_message=None):
     """
     @param p_pyhouse_obj: is the entire PyHouse Data tree.
     @param message_json: is message that is already json encoded\
     @param message_obj: is additional object that will be added into the meddage as Json.
     """
     l_message = MqttJson()
     l_message.Sender = p_pyhouse_obj.Computer.Name
     l_message.DateTime = datetime.datetime.now()
     if p_message is None:
         pass
     elif isinstance(p_message, object):
         xml_tools.stuff_new_attrs(l_message, p_message)
     else:
         xml_tools.stuff_new_attrs(l_message, p_message)
     #  print(PrettyFormatAny.form(l_message, 'Mqtt Client - Message'))
     l_json = json_tools.encode_json(l_message)
     return l_json
Exemple #12
0
 def _make_message(p_pyhouse_obj, p_message = None):
     """
     @param p_pyhouse_obj: is the entire PyHouse Data tree.
     @param message_json: is message that is already json encoded\
     @param message_obj: is additional object that will be added into the meddage as Json.
     """
     l_message = MqttJson()
     l_message.Sender = p_pyhouse_obj.Computer.Name
     l_message.DateTime = datetime.datetime.now()
     if p_message == None:
         pass
     elif isinstance(p_message, object):
         xml_tools.stuff_new_attrs(l_message, p_message)
     else:
         xml_tools.stuff_new_attrs(l_message, p_message)
     #  print(PrettyFormatAny.form(l_message, 'Mqtt Client - Message'))
     l_json = json_tools.encode_json(l_message)
     return l_json
Exemple #13
0
 def test_01_WriteSerialXml(self):
     l_interface = serialXML.read_interface_xml(self.m_xml.controller)
     stuff_new_attrs(self.m_controller_obj, l_interface)
     l_xml = ET.Element('TestOutput')
     l_xml = serialXML.write_interface_xml(l_xml, self.m_controller_obj)