コード例 #1
0
ファイル: web_mqtt.py プロジェクト: bopopescu/PyHouse_1
 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
コード例 #2
0
 def _read_one_broker(p_xml):
     """
     @param p_xml: XML information for one Broker.
     @return: an IrrigationZone object filled in with data from the XML passed in
     """
     l_obj = MqttBrokerData()
     try:
         XmlConfigTools.read_base_object_xml(l_obj, p_xml)
         l_obj.BrokerAddress = PutGetXML.get_text_from_xml(p_xml, 'BrokerAddress')
         l_obj.BrokerPort = PutGetXML.get_int_from_xml(p_xml, 'BrokerPort')
         l_obj.UserName = PutGetXML.get_text_from_xml(p_xml, 'BrokerUser')
         l_obj.Password = PutGetXML.get_text_from_xml(p_xml, 'BrokerPassword')
     except Exception:
         pass
     return l_obj
コード例 #3
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
コード例 #4
0
ファイル: mqtt_xml.py プロジェクト: bopopescu/PyHouse_1
 def _read_one_broker(p_xml):
     """
     @param p_xml: XML information for one Broker.
     @return: an IrrigationZone object filled in with data from the XML passed in
     """
     l_obj = MqttBrokerData()
     try:
         XmlConfigTools.read_base_object_xml(l_obj, p_xml)
         l_obj.BrokerAddress = PutGetXML.get_text_from_xml(p_xml, 'BrokerAddress')
         l_obj.BrokerPort = PutGetXML.get_int_from_xml(p_xml, 'BrokerPort')
         l_obj.UserName = PutGetXML.get_text_from_xml(p_xml, 'BrokerUser')
         l_obj.Password = PutGetXML.get_text_from_xml(p_xml, 'BrokerPassword')
     except Exception:
         pass
     return l_obj
コード例 #5
0
 def setUp(self, p_root):
     self.m_pyhouse_obj = SetupPyHouseObj().BuildPyHouseObj(p_root)
     self.m_xml = SetupPyHouseObj().BuildXml(p_root)
     self.m_api = mqttAPI(self.m_pyhouse_obj)
     self.m_broker = MqttBrokerData()