コード例 #1
0
ファイル: DIRACScript.py プロジェクト: DIRACGrid/DIRAC
    def initialize(cls,
                   script=False,
                   ignoreErrors=False,
                   initializeMonitor=False,
                   enableCommandLine=False):
        """initialization

        :param str script: script name
        :param bool ignoreErrors: ignore errors when loading configuration
        :param bool initializeMonitor: to use monitoring
        :param bool enableCommandLine: enable parse command line
        """
        # Please do not call initialize in every file
        if cls.alreadyInitialized:
            return False
        userDisabled = not cls.localCfg.isCSEnabled()
        cls.alreadyInitialized = True
        if not userDisabled:
            cls.localCfg.disableCS()

        if not enableCommandLine:
            cls.localCfg.disableParsingCommandLine()

        if script:
            cls.scriptName = script
        cls.localCfg.setConfigurationForScript(cls.scriptName)

        if not ignoreErrors:
            cls.localCfg.addMandatoryEntry("/DIRAC/Setup")
        resultDict = cls.localCfg.loadUserData()
        if not ignoreErrors and not resultDict["OK"]:
            gLogger.error("There were errors when loading configuration",
                          resultDict["Message"])
            sys.exit(1)
        if not userDisabled:
            cls.localCfg.enableCS()
        if initializeMonitor:
            gMonitor.setComponentType(gMonitor.COMPONENT_SCRIPT)
            gMonitor.setComponentName(cls.scriptName)
            gMonitor.setComponentLocation("script")
            gMonitor.initialize()
        else:
            gMonitor.disable()
        includeExtensionErrors()
        return True
コード例 #2
0
ファイル: Script.py プロジェクト: project8/DIRAC
def initialize(script=False,
               ignoreErrors=False,
               initializeMonitor=False,
               enableCommandLine=False):
    global scriptName, gIsAlreadyInitialized

    #Please do not call initialize in every file
    if gIsAlreadyInitialized:
        return False
    gIsAlreadyInitialized = True

    userDisabled = not localCfg.isCSEnabled()
    if not userDisabled:
        localCfg.disableCS()

    if not enableCommandLine:
        localCfg.disableParsingCommandLine()

    if script:
        scriptName = script
    localCfg.setConfigurationForScript(scriptName)

    if not ignoreErrors:
        localCfg.addMandatoryEntry("/DIRAC/Setup")
    resultDict = localCfg.loadUserData()
    if not ignoreErrors and not resultDict['OK']:
        gLogger.error("There were errors when loading configuration",
                      resultDict['Message'])
        sys.exit(1)

    if not userDisabled:
        localCfg.enableCS()

    if initializeMonitor:
        gMonitor.setComponentType(gMonitor.COMPONENT_SCRIPT)
        gMonitor.setComponentName(scriptName)
        gMonitor.setComponentLocation("script")
        gMonitor.initialize()
    else:
        gMonitor.disable()
    includeExtensionErrors()

    return True
コード例 #3
0
ファイル: Script.py プロジェクト: DIRACGrid/DIRAC
def initialize(script=False, ignoreErrors=False, initializeMonitor=False, enableCommandLine=False):
  global scriptName, gIsAlreadyInitialized

  # Please do not call initialize in every file
  if gIsAlreadyInitialized:
    return False
  gIsAlreadyInitialized = True

  userDisabled = not localCfg.isCSEnabled()
  if not userDisabled:
    localCfg.disableCS()

  if not enableCommandLine:
    localCfg.disableParsingCommandLine()

  if script:
    scriptName = script
  localCfg.setConfigurationForScript(scriptName)

  if not ignoreErrors:
    localCfg.addMandatoryEntry("/DIRAC/Setup")
  resultDict = localCfg.loadUserData()
  if not ignoreErrors and not resultDict['OK']:
    gLogger.error("There were errors when loading configuration", resultDict['Message'])
    sys.exit(1)

  if not userDisabled:
    localCfg.enableCS()

  if initializeMonitor:
    gMonitor.setComponentType(gMonitor.COMPONENT_SCRIPT)
    gMonitor.setComponentName(scriptName)
    gMonitor.setComponentLocation("script")
    gMonitor.initialize()
  else:
    gMonitor.disable()
  includeExtensionErrors()

  return True