def main(): Script.parseCommandLine(ignoreErrors=True) lfns = Script.getPositionalArgs() if len(lfns) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac dirac = Dirac() exitCode = 0 errorList = [] if len(lfns) == 1: try: with open(lfns[0], 'r') as f: lfns = f.read().splitlines() except BaseException: pass result = dirac.getLfnMetadata(lfns, printOutput=True) if not result['OK']: print('ERROR: ', result['Message']) exitCode = 2 DIRAC.exit(exitCode)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument( ["LFN: Logical File Name or file containing LFNs"]) _, lfns = Script.parseCommandLine(ignoreErrors=True) from DIRAC.Interfaces.API.Dirac import Dirac dirac = Dirac() exitCode = 0 errorList = [] if len(lfns) == 1: try: with open(lfns[0], "r") as f: lfns = f.read().splitlines() except Exception: pass result = dirac.getLfnMetadata(lfns, printOutput=True) if not result["OK"]: print("ERROR: ", result["Message"]) exitCode = 2 DIRAC.exit(exitCode)
Script.setUsageMessage('\n'.join([ __doc__.split('\n')[1], 'Usage:', ' %s [option|cfgfile] ... LFN ...' % Script.scriptName, 'Arguments:', ' LFN: Logical File Name or file containing LFNs' ])) Script.parseCommandLine(ignoreErrors=True) lfns = Script.getPositionalArgs() if len(lfns) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac dirac = Dirac() exitCode = 0 errorList = [] if len(lfns) == 1: try: f = open(lfns[0], 'r') lfns = f.read().splitlines() f.close() except BaseException: pass result = dirac.getLfnMetadata(lfns, printOutput=True) if not result['OK']: print 'ERROR: ', result['Message'] exitCode = 2 DIRAC.exit(exitCode)
gLogger.verbose('Directory for downloading file is set to %s' % directory) replicaInfo = dirac.getReplicas(oldLFN) if not replicaInfo['OK'] or replicaInfo['Value']['Failed']: leave('Could not get replica information for %s' % oldLFN, replicaInfo, exitCode=2) replicas = replicaInfo['Value']['Successful'][oldLFN] storageElements = replicas.keys() if not storageElements: leave('Could not determine SEs for replicas of %s' % oldLFN, exitCode=2) gLogger.info('Existing LFN has replicas at: %s' % ', '.join(storageElements)) oldGUID = dirac.getLfnMetadata(oldLFN) if not oldGUID['OK'] or oldGUID['Value']['Failed']: leave('Could not obtain GUID from LFC for %s - %s' % oldLFN, oldGUID, exitCode=2) oldGUID = oldGUID['Value']['Successful'][oldLFN]['GUID'] gLogger.verbose('Existing GUID is %s' % oldGUID) # retrieve original file localFile = os.path.join(directory, os.path.basename(oldLFN)) if not os.path.exists(localFile): download = dirac.getFile(oldLFN, directory) if not download['OK'] or download['Value']['Failed']: leave('Could not download file with message - %s' % download['Message'], download,
Script.setUsageMessage('\n'.join([__doc__.split('\n')[1], 'Usage:', ' %s [option|cfgfile] ... LFN ...' % Script.scriptName, 'Arguments:', ' LFN: Logical File Name or file containing LFNs'])) Script.parseCommandLine(ignoreErrors=True) lfns = Script.getPositionalArgs() if len(lfns) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac dirac = Dirac() exitCode = 0 errorList = [] if len(lfns) == 1: try: f = open(lfns[0], 'r') lfns = f.read().splitlines() f.close() except BaseException: pass result = dirac.getLfnMetadata(lfns, printOutput=True) if not result['OK']: print 'ERROR: ', result['Message'] exitCode = 2 DIRAC.exit(exitCode)