Exemple #1
0
 def saveMqttData(self, p_json):
     """Mqtt data is returned, so update the info.
     """
     l_json = JsonUnicode().decode_json(p_json)
     l_delete = l_json['Delete']
     l_ix = int(l_json['Key'])
     if l_delete:
         try:
             del self.m_pyhouse_obj.Computer.Mqtt.Brokers
         except AttributeError:
             LOG.error(
                 "web_mqtt - Failed to delete - JSON: {0:}".format(l_json))
         return
     try:
         l_obj = self.m_pyhouse_obj.Computer.Mqtt.Brokers[l_ix]
     except KeyError:
         LOG.warning('Creating a new Mqtt Broker Key: {}'.format(l_ix))
         l_obj = MqttBrokerData()
     #
     LOG.info('JSON {}'.format(l_json))
     l_obj.Name = l_json['Name']
     l_obj.Active = l_json['Active']
     l_obj.Key = l_ix
     l_obj.UUID = Uuid.make_valid(l_json['UUID'])
     l_obj.BrokerAddress = l_json['BrokerAddress']
     l_obj.BrokerPort = l_json['BrokerPort']
     self.m_pyhouse_obj.Computer.Mqtt.Brokers[l_obj.Key] = l_obj
Exemple #2
0
 def saveMqttData(self, p_json):
     """Mqtt data is returned, so update the info.
     """
     l_json = JsonUnicode().decode_json(p_json)
     l_delete = l_json['Delete']
     l_ix = int(l_json['Key'])
     if l_delete:
         try:
             del self.m_pyhouse_obj.Computer.Mqtt.Brokers
         except AttributeError:
             LOG.error("web_mqtt - Failed to delete - JSON: {0:}".format(l_json))
         return
     try:
         l_obj = self.m_pyhouse_obj.Computer.Mqtt.Brokers[l_ix]
     except KeyError:
         LOG.warning('Creating a new Mqtt Broker Key: {}'.format(l_ix))
         l_obj = MqttBrokerData()
     #
     LOG.info('JSON {}'.format(l_json))
     l_obj.Name = l_json['Name']
     l_obj.Active = l_json['Active']
     l_obj.Key = l_ix
     l_obj.UUID = Uuid.make_valid(l_json['UUID'])
     l_obj.BrokerAddress = l_json['BrokerAddress']
     l_obj.BrokerPort = l_json['BrokerPort']
     self.m_pyhouse_obj.Computer.Mqtt.Brokers[l_obj.Key] = l_obj
Exemple #3
0
 def write_base_object_xml(p_element_name, p_object):
     """
     Note that UUID is optional.
     @param p_element_name: is the name of the XML element (Light, Button, etc.)
     @param p_object: is the device object that contains the info to be written.
     @return: An Element with Attributes filled in and perhaps sub-elements attached
     """
     l_elem = ET.Element(p_element_name)
     try:
         PutGetXML.put_text_attribute(l_elem, 'Name', p_object.Name)
         PutGetXML.put_int_attribute(l_elem, 'Key', p_object.Key)
         PutGetXML.put_bool_attribute(l_elem, 'Active', p_object.Active)
     except AttributeError as e_err:
         PutGetXML.put_text_attribute(l_elem, 'Error: ', e_err)
     try:
         PutGetXML.put_uuid_element(l_elem, 'UUID', p_object.UUID)
     except AttributeError:
         PutGetXML.put_uuid_element(l_elem, 'UUID', 'No UUID Given')
         LOG.error('UUID missing for {}'.format(p_object.Name))
         l_UUID = Uuid.make_valid('246')
         PutGetXML.put_uuid_element(l_elem, 'UUID', l_UUID)
     return l_elem
Exemple #4
0
 def test_03_Valid(self):
     l_test = '12345678-dead-beef-dead-fedcba987654'
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertEqual(l_uuid, l_test)
Exemple #5
0
 def test_02_Invalid(self):
     l_test = '123456'
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertNotEqual(l_uuid, l_test)
Exemple #6
0
 def test_01_None(self):
     l_test = None
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertNotEqual(l_uuid, l_test)
 def test_03_Valid(self):
     l_test = '12345678-dead-beef-dead-fedcba987654'
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertEqual(l_uuid, l_test)
 def test_02_Invalid(self):
     l_test = '123456'
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertNotEqual(l_uuid, l_test)
 def test_01_None(self):
     l_test = None
     l_uuid = Uuid.make_valid(l_test)
     #  print('UUID = {}'.format(l_uuid))
     self.assertNotEqual(l_uuid, l_test)