Exemplo n.º 1
0

if __name__ == '__main__':

  # Script initialization
  from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

  Script.registerSwitch('', 'FixIt', '   Take action to fix the catalogs')
  Script.setUsageMessage('\n'.join([__doc__,
                                    'Usage:',
                                    '  %s [option|cfgfile] [values]' % Script.scriptName, ]))
  dmScript = DMScript()
  dmScript.registerDMSwitches()  # Directory
  Script.parseCommandLine(ignoreErrors=True)
  fixIt = False
  for opt, val in Script.getUnprocessedSwitches():
    if opt == 'FixIt':
      fixIt = True

  # imports
  from DIRAC import gLogger
  from LHCbDIRAC.DataManagementSystem.Client.ConsistencyChecks import ConsistencyChecks
  cc = ConsistencyChecks()
  cc.directories = dmScript.getOption('Directory', [])
  cc.lfns = dmScript.getOption('LFNs', []) + [lfn for arg in Script.getPositionalArgs() for lfn in arg.split(',')]
  bkQuery = dmScript.getBKQuery(visible='All')
  if bkQuery.getQueryDict() != {'Visible': 'All'}:
    bkQuery.setOption('ReplicaFlag', 'All')
    cc.bkQuery = bkQuery
  seList = dmScript.getOption('SEs', [])
  if not seList:
Exemplo n.º 2
0
  dmScript.registerDMSwitches()
  maxFiles = 20
  Script.registerSwitch('', 'FixIt', '   Take action to fix the catalogs and storage')
  Script.registerSwitch('', 'Replace', '   Replace bad or missing replicas (default=False)')
  Script.registerSwitch('', 'NoBK', '   Do not check with BK')
  Script.registerSwitch('', 'Verbose', '   Set logging mode to INFO')
  Script.registerSwitch('', 'MaxFiles=', '   Set maximum number of files to be printed (default %d)' % maxFiles)
  Script.parseCommandLine(ignoreErrors=True)

  from DIRAC import gLogger

  fixIt = False
  bkCheck = True
  replace = False
  verbose = False
  for switch in Script.getUnprocessedSwitches():
    if switch[0] == 'FixIt':
      fixIt = True
    elif switch[0] == 'NoBK':
      bkCheck = False
    elif switch[0] == 'Replace':
      replace = True
    elif switch[0] == 'Verbose':
      verbose = True
    elif switch[0] == 'MaxFiles':
      try:
        maxFiles = int(switch[1])
      except Exception as e:
        gLogger.exception("Invalid value for MaxFiles", lException=e)
        pass