Beispiel #1
0
def main():
    Script.parseCommandLine(ignoreErrors=True)
    args = Script.getPositionalArgs()

    # pylint: disable=wrong-import-position
    from DIRAC.Interfaces.API.Dirac import Dirac

    if len(args) < 2:
        Script.showHelp(exitCode=1)

    if len(args) > 3:
        print('Only one LFN SE pair will be considered')

    dirac = Dirac()
    exitCode = 0

    lfn = args[0]
    seName = args[1]
    proto = False
    if len(args) > 2:
        proto = args[2]

    try:
        with open(lfn, 'r') as f:
            lfns = f.read().splitlines()
    except IOError:
        lfns = [lfn]

    for lfn in lfns:
        result = dirac.getAccessURL(lfn,
                                    seName,
                                    protocol=proto,
                                    printOutput=True)
        if not result['OK']:
            print('ERROR: ', result['Message'])
            exitCode = 2

    DIRAC.exit(exitCode)
Beispiel #2
0
def main():
    # Registering arguments will automatically add their description to the help menu
    Script.registerArgument(
        "LFN:      Logical File Name or file containing LFNs")
    Script.registerArgument("SE:       Valid DIRAC SE")
    Script.registerArgument("PROTO:    Optional protocol for accessURL",
                            default=False,
                            mandatory=False)
    _, args = Script.parseCommandLine(ignoreErrors=True)
    lfn, seName, proto = Script.getPositionalArgs(group=True)

    # pylint: disable=wrong-import-position
    from DIRAC.Interfaces.API.Dirac import Dirac

    if len(args) > 3:
        print("Only one LFN SE pair will be considered")

    dirac = Dirac()
    exitCode = 0

    try:
        with open(lfn, "r") as f:
            lfns = f.read().splitlines()
    except IOError:
        lfns = [lfn]

    for lfn in lfns:
        result = dirac.getAccessURL(lfn,
                                    seName,
                                    protocol=proto,
                                    printOutput=True)
        if not result["OK"]:
            print("ERROR: ", result["Message"])
            exitCode = 2

    DIRAC.exit(exitCode)
args = Script.getPositionalArgs()

if len(args) < 2:
    Script.showHelp()

if len(args) > 2:
    print "Only one LFN SE pair will be considered"

from DIRAC.Interfaces.API.Dirac import Dirac

dirac = Dirac()
exitCode = 0

lfn = args[0]
seName = args[1]

try:
    f = open(lfn, "r")
    lfns = f.read().splitlines()
    f.close()
except:
    lfns = [lfn]

for lfn in lfns:
    result = dirac.getAccessURL(lfn, seName, printOutput=True)
    if not result["OK"]:
        print "ERROR: ", result["Message"]
        exitCode = 2

DIRAC.exit(exitCode)
Beispiel #4
0
from DIRAC.Interfaces.API.Dirac import Dirac

if len(args) < 2:
  Script.showHelp(exitCode=1)

if len(args) > 3:
  print('Only one LFN SE pair will be considered')

dirac = Dirac()
exitCode = 0

lfn = args[0]
seName = args[1]
proto = False
if len(args) > 2:
  proto = args[2]

try:
  with open(lfn, 'r') as f:
    lfns = f.read().splitlines()
except IOError:
  lfns = [lfn]

for lfn in lfns:
  result = dirac.getAccessURL(lfn, seName, protocol=proto, printOutput=True)
  if not result['OK']:
    print('ERROR: ', result['Message'])
    exitCode = 2

DIRAC.exit(exitCode)
if not files:
  Script.showHelp()
  DIRAC.exit(0)
existFiles = {}
nonExisting = []
dirac = Dirac()

for localFile in files:
  if os.path.exists(localFile):
    existFiles[os.path.realpath(localFile)] = localFile
  elif localFile.startswith('/lhcb'):
    res = dirac.getReplicas(localFile, active=True, preferDisk=True)
    if res['OK'] and localFile in res['Value']['Successful']:
      ses = res['Value']['Successful'][localFile].keys()
      for se in ses:
        res = dirac.getAccessURL(localFile, se, protocol=['root', 'xroot'])
        if res['OK'] and localFile in res['Value']['Successful']:
          existFiles[res['Value']['Successful'][localFile]] = "%s @ %s" % (localFile, se)
    else:
      nonExisting.append(localFile)
  elif localFile.startswith('root:'):
    existFiles[localFile] = localFile
  else:
    nonExisting.append(localFile)

fileGUIDs = getRootFileGUIDs(existFiles.keys())
for status in ('Successful', 'Failed'):
  for file in fileGUIDs.get('Value', {}).get(status, {}):
    fileGUIDs['Value'][status][existFiles.get(file, file)] = fileGUIDs['Value'][status].pop(file)
if nonExisting:
  fileGUIDs['Value']['Failed'].update(dict.fromkeys(nonExisting, 'Non existing file'))