def initialize(self, systemName, cfgPath): if self.__initialized: return self.__initialized = True from DIRAC.ConfigurationSystem.Client.Config import gConfig from os import getpid # self.__printDebug( "The configuration path is %s" % cfgPath ) # Get the options for the different output backends retDict = gConfig.getOptionsDict("%s/BackendsOptions" % cfgPath) # self.__printDebug( retDict ) if not retDict['OK']: cfgBackOptsDict = { 'FileName': 'Dirac-log_%s.log' % getpid(), 'Interactive': True, 'SleepTime': 150 } else: cfgBackOptsDict = retDict['Value'] self.__backendOptions.update(cfgBackOptsDict) if 'FileName' not in self.__backendOptions: self.__backendOptions['FileName'] = 'Dirac-log_%s.log' % getpid() sleepTime = 150 try: sleepTime = int(self.__backendOptions['SleepTime']) except: pass self.__backendOptions['SleepTime'] = sleepTime self.__backendOptions['Interactive'] = gConfig.getValue( "%s/BackendsOptions/Interactive" % cfgPath, True) self.__backendOptions['Site'] = DIRAC.siteName() self.__backendOptions['Color'] = gConfig.getValue( "%s/LogColor" % cfgPath, False) # Configure outputs desiredBackends = gConfig.getValue("%s/LogBackends" % cfgPath, 'stdout') self.registerBackends(List.fromChar(desiredBackends)) # Configure verbosity defaultLevel = Logger.defaultLogLevel if "Scripts" in cfgPath: defaultLevel = gConfig.getValue('/Systems/Scripts/LogLevel', Logger.defaultLogLevel) self.setLevel(gConfig.getValue("%s/LogLevel" % cfgPath, defaultLevel)) # Configure framing self._showCallingFrame = gConfig.getValue("%s/LogShowLine" % cfgPath, self._showCallingFrame) # Get system name self._systemName = str(systemName) if not self.__backendOptions['Interactive']: ExitCallback.registerExitCallback(self.flushAllMessages)
def __init__( self ): cmd.Cmd.__init__( self ) self.do_connect( None ) self.identSpace = 20 ExitCallback.registerExitCallback( self.do_quit ) #User friendly hack self.do_exit = self.do_quit self.do_EOF = self.do_quit
def __init__(self): cmd.Cmd.__init__(self) self.do_connect(None) self.identSpace = 20 ExitCallback.registerExitCallback(self.do_quit) #User friendly hack self.do_exit = self.do_quit self.do_EOF = self.do_quit
def initialize( self, systemName, cfgPath ): if self.__initialized: return self.__initialized = True from DIRAC.ConfigurationSystem.Client.Config import gConfig from os import getpid # self.__printDebug( "The configuration path is %s" % cfgPath ) # Get the options for the different output backends retDict = gConfig.getOptionsDict( "%s/BackendsOptions" % cfgPath ) # self.__printDebug( retDict ) if not retDict[ 'OK' ]: cfgBackOptsDict = { 'FileName': 'Dirac-log_%s.log' % getpid(), 'Interactive': True, 'SleepTime': 150 } else: cfgBackOptsDict = retDict[ 'Value' ] self.__backendOptions.update( cfgBackOptsDict ) if 'FileName' not in self.__backendOptions: self.__backendOptions[ 'FileName' ] = 'Dirac-log_%s.log' % getpid() sleepTime = 150 try: sleepTime = int ( self.__backendOptions[ 'SleepTime' ] ) except: pass self.__backendOptions[ 'SleepTime' ] = sleepTime self.__backendOptions[ 'Interactive' ] = gConfig.getValue( "%s/BackendsOptions/Interactive" % cfgPath, True ) self.__backendOptions[ 'Site' ] = DIRAC.siteName() self.__backendOptions[ 'Color' ] = gConfig.getValue( "%s/LogColor" % cfgPath, False ) # Configure outputs desiredBackends = gConfig.getValue( "%s/LogBackends" % cfgPath, 'stdout' ) self.registerBackends( List.fromChar( desiredBackends ) ) # Configure verbosity defaultLevel = Logger.defaultLogLevel if "Scripts" in cfgPath: defaultLevel = gConfig.getValue( '/Systems/Scripts/LogLevel', Logger.defaultLogLevel ) self.setLevel( gConfig.getValue( "%s/LogLevel" % cfgPath, defaultLevel ) ) # Configure framing self._showCallingFrame = gConfig.getValue( "%s/LogShowLine" % cfgPath, self._showCallingFrame ) # Get system name self._systemName = str( systemName ) if not self.__backendOptions['Interactive']: ExitCallback.registerExitCallback( self.flushAllMessages )
def initialize(self, systemName, cfgPath): if self.__initialized: return self.__initialized = True from DIRAC.ConfigurationSystem.Client.Config import gConfig from os import getpid # self.__printDebug( "The configuration path is %s" % cfgPath ) # Get the options for the different output backends retDict = gConfig.getOptionsDict("%s/BackendsOptions" % cfgPath) # self.__printDebug( retDict ) if not retDict["OK"]: cfgBackOptsDict = {"FileName": "Dirac-log_%s.log" % getpid(), "Interactive": True, "SleepTime": 150} else: cfgBackOptsDict = retDict["Value"] self.__backendOptions.update(cfgBackOptsDict) if not self.__backendOptions.has_key("Filename"): self.__backendOptions["FileName"] = "Dirac-log_%s.log" % getpid() sleepTime = 150 try: sleepTime = int(self.__backendOptions["SleepTime"]) except: pass self.__backendOptions["SleepTime"] = sleepTime self.__backendOptions["Interactive"] = gConfig.getValue("%s/BackendsOptions/Interactive" % cfgPath, True) self.__backendOptions["Site"] = DIRAC.siteName() # Configure outputs desiredBackends = gConfig.getValue("%s/LogBackends" % cfgPath, "stdout") self.registerBackends(List.fromChar(desiredBackends)) # Configure verbosity defaultLevel = Logger.defaultLogLevel if "Scripts" in cfgPath: defaultLevel = gConfig.getValue("/Systems/Scripts/LogLevel", Logger.defaultLogLevel) self.setLevel(gConfig.getValue("%s/LogLevel" % cfgPath, defaultLevel)) # Configure framing self._showCallingFrame = gConfig.getValue("%s/LogShowLine" % cfgPath, self._showCallingFrame) # Get system name self._systemName = str(systemName) if not self.__backendOptions["Interactive"]: ExitCallback.registerExitCallback(self.flushAllMessages)
def __init__( self ): CLI.__init__( self ) self.do_connect( None ) ExitCallback.registerExitCallback( self.do_quit )
def exit(exitCode=0): """ Finish execution using callbacks """ ExitCallback.execute(exitCode, []) sys.exit(exitCode)
# for err in getattr( extraErrorModule, 'extra_compatErrorString', [] ) : # DErrno.compatErrorString.setdefault( err, [] ).extend( extraErrorModule.extra_compatErrorString[err] ) def siteName(): """ Determine and return DIRAC name for current site """ global __siteName if not __siteName: __siteName = gConfig.getValue('/LocalSite/Site', _siteName) return __siteName # Callbacks ExitCallback.registerSignals() # platform detection from DIRAC.Core.Utilities.Platform import getPlatformString, getPlatform, getPlatformTuple def exit(exitCode=0): """ Finish execution using callbacks """ ExitCallback.execute(exitCode, []) sys.exit(exitCode) def abort(exitCode, *args, **kwargs): """
def __init__(self): CLI.__init__(self) self.do_connect(None) ExitCallback.registerExitCallback(self.do_quit)