예제 #1
0
	def Add(self, newRule):

		try:
			if (isinstance(newRule, BaseRule)==False):
				#getLogger().error(u"Configuration '{}' is instance of '{}', it should be instance of class that inherits from 'BaseConfig'".format(newRule.getName().decode('utf8'), getClassName(newRule)))
				getLogger().error("Configuration '{}' is instance of '{}', it should be instance of class that inherits from 'BaseConfig'".format(newRule.getName(), getClassName(newRule)))
				return False

			getLogger().debug(("Adding Rule Type='{}',  ConfigName='{}', OutputItems='{}'").format(newRule.__class__.__name__, newRule.getName(), str(newRule.getOutputItems())))
						
			# Initialize rule 
			newRule.InitializeConfig(self)
			
			if (newRule.RequiresService(RequiredServiceEnum.ASTRO)):
				getLogger().debug("Rule '{}' requires 'Astro' service".format(newRule.getName()))
				self.astroUseCount = self.astroUseCount + 1
				
			getLogger().debug(("Adding Rule '{}' to dictionary (Id='{}')").format(newRule.getName(), newRule.getId()))
			self.dictRules[newRule.getId()] = newRule
			if (self.dictRules.has_key(newRule.getId())):
				getLogger().debug("Rule '{}' was added successfully (Id='{}')".format(newRule.getName(), newRule.getId()))
			else:
				getLogger().error("Rule '{}' was not added to dictionary (Id='{}')".format(newRule.getName(), newRule.getId()))
		except:
			LogException()
			return False	
예제 #2
0
 def getName(self):
     return getClassName(self)
예제 #3
0
	def __init__(self, name, physicalDevice, eventCallback):
		try:
			
			BaseCore.__init__(self, name)
			
			#Initialization
			self._activated = False
			self._physicalDevice = None
			self._eventCallback = eventCallback
			#Validation
			if (physicalDevice is not None):
				if (isinstance(physicalDevice, PhysicalDevice)==False):
					getLogger().error("Instance of PhysicalDevice not instance of class 'PhysicalDevice'. Actual instance is '" + getClassName(physicalDevice) + "'")
					#TODO:: Raise Exception
				
				self._physicalDevice = physicalDevice
		except:
			LogException()
 def __repr__(self):
     if (self.getName() is None) or (self.getName() == ""):
         return getClassName(self)
     return str(self.getName())