def __init__(self, name="Python Client"): ''' Initialize the client. Parameters: - name is what manager will refer to this client instance as - runAsSingleton True if the client is a singleton Returns: Nothing Raises: CORBAProblemExImpl ''' loginName = "UNKNOWN_USER" try: loginName = pwd.getpwuid(os.getuid())[0] except: print_exc() print "Error getting the user name!" hostName = "UNKNOWN_HOST" try: hostName = socket.gethostname().split('.')[0] except: print_exc() print "Error getting the host name!" #just to be sure name = name + " initialized by " + loginName + "@" + hostName name = str(name) BaseClient.__init__(self, name) if _DEBUG: # pragma: NO COVER print "Got past BaseClient in SimpleClient" #call superclass constructors ContainerServices.__init__(self) if _DEBUG: # pragma: NO COVER print "Got past ContainerServices in SimpleClient" #set some things to make ContainerServices happy self.setAll(self.name, self.token, self.token.h, self.__activateOffShoot) if _DEBUG: # pragma: NO COVER print "Got past Constructor in SimpleClient" # Ensure that disconnect is called when python exit register(self.disconnect) global _instance #If there is no singleton yet; create one if _instance == None: _instance = self
def __init__(self, name="Python Client"): ''' Initialize the client. Parameters: - name is what manager will refer to this client instance as - runAsSingleton True if the client is a singleton Returns: Nothing Raises: CORBAProblemExImpl ''' loginName = "UNKNOWN_USER" try: loginName = pwd.getpwuid(os.getuid())[0] except: print_exc() print "Error getting the user name!" hostName = "UNKNOWN_HOST" try: hostName = socket.gethostname() except: print_exc() print "Error getting the host name!" #just to be sure name = name + ": initialized by " + loginName + "@" + hostName name = str(name) BaseClient.__init__(self, name) if _DEBUG: # pragma: NO COVER print "Got past BaseClient in SimpleClient" #call superclass constructors ContainerServices.__init__(self) if _DEBUG: # pragma: NO COVER print "Got past ContainerServices in SimpleClient" #set some things to make ContainerServices happy self.setAll(self.name, self.token, self.token.h, self.__activateOffShoot) if _DEBUG: # pragma: NO COVER print "Got past Constructor in SimpleClient" # Ensure that disconnect is called when python exit register(self.disconnect) global _instance #If there is no singleton yet; create one if _instance == None: _instance = self
def disconnect(self): ''' Overridden from the BaseClient class. If singletons are not being utilized (see the getInstance method), the baseclass method is called. Otherwise if the reference counting falls to 0, the client will really be disconnected from manager and the singleton client in the AcsCORBA class is also destroyed. This implies when the baseclass disconnect method is called the getInstance method of this class will cease to function! ''' global _myInstanceCount, _instance _myInstanceCount = _myInstanceCount - 1 if _myInstanceCount == 0: BaseClient.disconnect(self) _instance = None
def __init__(self, name="Python Client"): ''' Initialize the client. Parameters: - name is what manager will refer to this client instance as Returns: Nothing Raises: CORBAProblemExImpl ''' global _myInstanceCount #increment our own reference counter _myInstanceCount = _myInstanceCount + 1 #just to be sure try: name = name + ": " + os.getlogin() + " at " + socket.gethostname() except: name = name name = str(name) #call superclass constructors ContainerServices.__init__(self) if _DEBUG: # pragma: NO COVER print "Got past ContainerServices in SimpleClient" BaseClient.__init__(self, name) if _DEBUG: # pragma: NO COVER print "Got past BaseClient in SimpleClient" #set some things to make ContainerServices happy self.setAll(self.name, self.token, self.token.h, self.__activateOffShoot) if _DEBUG: # pragma: NO COVER print "Got past Constructor in SimpleClient" register(self.disconnect)
def __init__ (self, name): ''' Constructor. Initializes member variables and CORBA Parameters: name is the stringified name of this container. Raises: ??? ''' print maci.Container.ContainerStatusStartupBeginMsg #Member variables self.isReady = Event() self.running = 1 #As long as this is true, container is not shutdown self.name = name #Container Name self.canRecover = True #Whether this container is capable of recovery self.components = {} #A dict where components are referenced by name self.compHandles = {} #A dict where comp names are referenced by handles self.shutdownHandles = [] self.containerPOA = None #POA to activate this container self.componentPOA = None #POA to create POAs for components self.compPolicies = [] #Policy[] for components self.offShootPolicies = [] #Policy[] for offshoots self.corbaRef = None #reference to this object's CORBA reference self.logger = Log.getLogger(name) # Container's logger self.client_type = maci.CONTAINER_TYPE self.cdbContainerInfo = {} self.autoLoadPackages = [] #dictionary which maps package names to the number of active components #using said package self.compModuleCount = {} # Initialize the alarm factory Acsalarmpy.AlarmSystemInterfaceFactory.init(ACSCorba.getManager()) # The alarm source self.alarmSource = None # The interface to receive notification from the LogThrottle # for sending alarms self.clta=ContainerLogThrottleAlarmer(self) #Configure CORBA print maci.Container.ContainerStatusORBInitBeginMsg self.configCORBA() print maci.Container.ContainerStatusORBInitEndMsg #call superclass constructor print maci.Container.ContainerStatusMgrInitBeginMsg BaseClient.__init__(self, self.name) print maci.Container.ContainerStatusMgrInitEndMsg self.logger.logTrace('CORBA configured for Container: ' + self.name) self.cdbAccess = CDBaccess() self.logger.logTrace('Starting Container: ' + self.name) #get info from the CDB self.getCDBInfo() self.refresh_logging_config() self.configureComponentLogger(name) #Run everything self.logger.logInfo('Container ' + self.name + ' waiting for requests') self.isReady.set() print maci.Container.ContainerStatusStartupEndMsg sys.stdout.flush()