import sys class ServiceBase : config = {} namespace = {} data = {} error = [] warn = [] _status = "Ready" _subjects = [] def __init__(self,config,namespace,subjects,dossiercopy): if not config or config == {} : self._status = "Error" else : self.config = config # The following lines indicate a problem in my understanding of Python's class structure. # Why do new instances of subclasses inherit the written values of their superclass instance? self.error = [] self.warn = [] self.data = dossiercopy self.namespace = namespace self._subjects = subjects pass def _lookup_subjects(self) : args = self.get_arguments() if args : args = args[1][2:] if getattr(self.namespace,args) == False and getattr(self.namespace,'all') == False : return None finaldictionary = {} self.startup() for item in self._subjects : finaldictionary.update({item:self.perform_lookup(item)}) self.shutdown() return finaldictionary def debug(self,message,verbosity_level) : if self.namespace.debug and self.namespace.debug >= verbosity_level : print(message,file=sys.stderr) @classmethod def get_arguments(cls) : """Returns an array of information used to construct an argumentparser argument.""" # [ ,,, ] # Example return: [ '-n', '--net', 'store_true', "Output network information about the subject" ] return None def startup(self) : """Perform any setup that is needed to perform lookups, such as logging in or obtaining auth sessions.""" pass def perform_lookup(self,host_tuple) : """Returns a dictionary with lookup information about the given IP or Hostname.""" # host_tuple is a socket triple (hostname, aliaslist, ipaddrlist) where hostname is # the primary host name responding to the given ip_address, aliaslist is a (possibly # empty) tuple of alternative host names for the same address, and ipaddrlist is a tuple # of IPv4/v6 addresses for the same interface on the same host (most likely containing # only a single address). # Note: You should only return arrays and dictionaries with strings as keys so the information # serializes correctly. return None def shutdown(self) : """Perform any cleanup that is needed, such as logging out of auth sessions.""" pass