def loadModules(self, modulesList, hideExceptions=False): """ Load all modules required in moduleList """ for modName in modulesList: gLogger.verbose("Checking %s" % modName) # if it's a executor modName name just load it and be done with it if "/" in modName: gLogger.verbose( "Module %s seems to be a valid name. Try to load it!" % modName) result = self.loadModule(modName, hideExceptions=hideExceptions) if not result["OK"]: return result continue # Check if it's a system name # Look in the CS system = modName # Can this be generated with sectionFinder? csPath = "%s/Executors" % PathFinder.getSystemSection(system) gLogger.verbose("Exploring %s to discover modules" % csPath) result = gConfig.getSections(csPath) if result["OK"]: # Add all modules in the CS :P for modName in result["Value"]: result = self.loadModule("%s/%s" % (system, modName), hideExceptions=hideExceptions) if not result["OK"]: return result # Look what is installed parentModule = None for rootModule in extensionsByPriority(): if not system.endswith("System"): system += "System" parentImport = "%s.%s.%s" % (rootModule, system, self.__csSuffix) # HERE! result = recurseImport(parentImport) if not result["OK"]: return result parentModule = result["Value"] if parentModule: break if not parentModule: continue parentPath = parentModule.__path__[0] gLogger.notice("Found modules path at %s" % parentImport) for entry in os.listdir(parentPath): if entry == "__init__.py" or not entry.endswith(".py"): continue if not os.path.isfile(os.path.join(parentPath, entry)): continue modName = "%s/%s" % (system, entry[:-3]) gLogger.verbose("Trying to import %s" % modName) result = self.loadModule(modName, hideExceptions=hideExceptions, parentModule=parentModule) return S_OK()
def loadModules( self, modulesList, hideExceptions = False ): """ Load all modules required in moduleList """ for modName in modulesList: gLogger.verbose( "Checking %s" % modName ) #if it's a executor modName name just load it and be done with it if modName.find( "/" ) > -1: gLogger.verbose( "Module %s seems to be a valid name. Try to load it!" % modName ) result = self.loadModule( modName, hideExceptions = hideExceptions ) if not result[ 'OK' ]: return result continue #Check if it's a system name #Look in the CS system = modName #Can this be generated with sectionFinder? csPath = "%s/Executors" % PathFinder.getSystemSection ( system, ( system, ) ) gLogger.verbose( "Exploring %s to discover modules" % csPath ) result = gConfig.getSections( csPath ) if result[ 'OK' ]: #Add all modules in the CS :P for modName in result[ 'Value' ]: result = self.loadModule( "%s/%s" % ( system, modName ), hideExceptions = hideExceptions ) if not result[ 'OK' ]: return result #Look what is installed parentModule = None for rootModule in getInstalledExtensions(): if system.find( "System" ) != len( system ) - 6: parentImport = "%s.%sSystem.%s" % ( rootModule, system, self.__csSuffix ) else: parentImport = "%s.%s.%s" % ( rootModule, system, self.__csSuffix ) #HERE! result = self.__recurseImport( parentImport ) if not result[ 'OK' ]: return result parentModule = result[ 'Value' ] if parentModule: break if not parentModule: continue parentPath = parentModule.__path__[0] gLogger.notice( "Found modules path at %s" % parentImport ) for entry in os.listdir( parentPath ): if entry[-3:] != ".py" or entry == "__init__.py": continue if not os.path.isfile( os.path.join( parentPath, entry ) ): continue modName = "%s/%s" % ( system, entry[:-3] ) gLogger.verbose( "Trying to import %s" % modName ) result = self.loadModule( modName, hideExceptions = hideExceptions, parentModule = parentModule ) return S_OK()
def initialize( self ): self.logger = gLogger.getSubLogger( "Monitoring" ) self.logger.debug( "Initializing Monitoring Client" ) self.sourceDict[ 'setup' ] = gConfig.getValue( "/DIRAC/Setup" ) self.sourceDict[ 'site' ] = DIRAC.siteName() if self.sourceDict[ 'componentType' ] == self.COMPONENT_SERVICE: self.cfgSection = PathFinder.getSystemSection( self.sourceDict[ 'componentName' ] ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_AGENT: self.cfgSection = PathFinder.getAgentSection( self.sourceDict[ 'componentName' ] ) self.setComponentLocation( Network.getFQDN() ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_WEB: self.cfgSection = "/WebApp" self.setComponentLocation( 'http://%s' % Network.getFQDN() ) self.setComponentName( 'WebApp' ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_SCRIPT: self.cfgSection = "/Script" else: raise Exception( "Component type has not been defined" ) gMonitoringFlusher.registerMonitoringClient( self ) # ExitCallback.registerExitCallback( self.forceFlush ) self.__initialized = True
def initialize( self ): self.logger = gLogger.getSubLogger( "Monitoring" ) self.logger.debug( "Initializing Monitoring Client" ) self.sourceDict[ 'setup' ] = gConfig.getValue( "/DIRAC/Setup" ) self.sourceDict[ 'site' ] = DIRAC.siteName() if self.sourceDict[ 'componentType' ] == self.COMPONENT_SERVICE: self.cfgSection = PathFinder.getSystemSection( self.sourceDict[ 'componentName' ] ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_AGENT: self.cfgSection = PathFinder.getAgentSection( self.sourceDict[ 'componentName' ] ) self.setComponentLocation( Network.getFQDN() ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_WEB: self.cfgSection = "/Website" self.setComponentLocation( 'http://%s' % Network.getFQDN() ) self.setComponentName( 'Web' ) elif self.sourceDict[ 'componentType' ] == self.COMPONENT_SCRIPT: self.cfgSection = "/Script" else: raise Exception( "Component type has not been defined" ) gMonitoringFlusher.registerMonitoringClient( self ) #ExitCallback.registerExitCallback( self.forceFlush ) self.__initialized = True
def initialize(self): self.logger = gLogger.getSubLogger("Monitoring") self.logger.debug("Initializing Monitoring Client") self.sourceDict["setup"] = gConfig.getValue("/DIRAC/Setup") self.sourceDict["site"] = DIRAC.siteName() if self.sourceDict["componentType"] == self.COMPONENT_SERVICE: self.cfgSection = PathFinder.getSystemSection( self.sourceDict["componentName"]) elif self.sourceDict["componentType"] == self.COMPONENT_AGENT: self.cfgSection = PathFinder.getAgentSection( self.sourceDict["componentName"]) self.setComponentLocation(Network.getFQDN()) elif self.sourceDict["componentType"] == self.COMPONENT_WEB: self.cfgSection = "/WebApp" self.setComponentLocation("http://%s" % Network.getFQDN()) self.setComponentName("WebApp") elif self.sourceDict["componentType"] == self.COMPONENT_SCRIPT: self.cfgSection = "/Script" elif self.sourceDict["componentType"] == self.COMPONENT_TORNADO: self.cfgSection = "/Tornado" else: raise Exception("Component type has not been defined") gMonitoringFlusher.registerMonitoringClient(self) self.__initialized = True