def read_property(self, property_key, critical=True): """ Returns the value of the provided property :param str property_key: the name of the property to be read :return: Value of the property, :rtype: str :exception: ParameterNotFoundException if the provided property cannot be found """ if self.__properties.has_option("agent", property_key): temp_str = self.__properties.get("agent", property_key) self.log.debug("Reading property: %s = %s", property_key, temp_str) if temp_str is not None and temp_str.strip( ) != "" and temp_str.strip().lower() != "null": return str(temp_str).strip() if property_key in self.__payload_params: temp_str = self.__payload_params[property_key] self.log.debug("Reading payload parameter: %s = %s", property_key, temp_str) if temp_str is not None and temp_str != "" and temp_str.strip( ).lower() != "null": return str(temp_str).strip() if critical: raise ParameterNotFoundException( "Cannot find the value of required parameter: %r" % property_key) else: return None
def read_property(property_key, mandatory=True): """ Returns the value of the provided property :param mandatory: If absence of this value should throw an error :param str property_key: the name of the property to be read :return: Value of the property :exception: ParameterNotFoundException if the provided property cannot be found """ if Config.properties.has_option("agent", property_key): temp_str = Config.properties.get("agent", property_key) Config.log.debug("Reading property: %s = %s", property_key, temp_str) real_value = Config.convert_to_type(temp_str) if real_value is not None: return real_value if property_key in Config.payload_params: temp_str = Config.payload_params[property_key] Config.log.debug("Reading payload parameter: %s = %s", property_key, temp_str) real_value = Config.convert_to_type(temp_str) if real_value is not None: return real_value # real value is None if mandatory: raise ParameterNotFoundException( "Cannot find the value of required parameter: %r" % property_key) else: return None
def read_property(property_key, critical=True): """ Returns the value of the provided property :param str property_key: the name of the property to be read :return: Value of the property :exception: ParameterNotFoundException if the provided property cannot be found """ if Config.properties is None or Config.payload_params == {}: Config.initialize_config() if Config.properties.has_option("agent", property_key): temp_str = Config.properties.get("agent", property_key) Config.log.debug("Reading property: %s = %s", property_key, temp_str) real_value = Config.convert_to_type(temp_str) if real_value is not None: return real_value if property_key in Config.payload_params: temp_str = Config.payload_params[property_key] Config.log.debug("Reading payload parameter: %s = %s", property_key, temp_str) real_value = Config.convert_to_type(temp_str) if real_value is not None: return real_value # real value is None if critical: raise ParameterNotFoundException( "Cannot find the value of required parameter: %r" % property_key) else: return None