def which(cmd): command = ['which', cmd] runner = cmsIO.cmsFileManip() out, _, _ = runner.runCommand(command) lines = [line for line in out.split('\n') if line] if len(lines) == 1: return lines[0] elif len(lines) == 2: return lines[1] else: return lines
def runXRDCommand(path, cmd, *args): """Run an xrd command. """ lfn = eosToLFN(path) #print "lfn:", lfn, cmd tokens = cmsIO.splitPFN(lfnToPFN(lfn)) command = ['xrd', tokens[1], cmd, tokens[2]] command.extend(args) runner = cmsIO.cmsFileManip() # print ' '.join(command) return runner.runCommand(command)
def runXRDCommand(path, cmd, *args): """Run an xrd command. !!! Will, what is happening in case of problem? ??? At some point, should return a list of lines instead of a string.""" lfn = eosToLFN(path) tokens = cmsIO.splitPFN(lfnToPFN(lfn)) command = ['xrd', tokens[1], cmd, tokens[2]] command.extend(args) runner = cmsIO.cmsFileManip() # print ' '.join(command) return runner.runCommand(command)
def _xrdcpSingleFile(pfn_src, pfn_dest): """Copies a single file using xrd.""" command = ['xrdcp', '-force'] command.append(pfn_src) command.append(pfn_dest) # print ' '.join(command) run = True if run: runner = cmsIO.cmsFileManip() out, err, ret = runner.runCommand(command) if err: print >> sys.stderr, out print >> sys.stderr, err return ret
def _xrdcpSingleFile( pfn_src, pfn_dest): """Copies a single file using xrd.""" command = ['xrdcp'] command.append(pfn_src) command.append(pfn_dest) # print ' '.join(command) run = True if run: runner = cmsIO.cmsFileManip() out, err, ret = runner.runCommand(command) if err: print >> sys.stderr, out print >> sys.stderr, err return ret
def cmsStage(absDestDir, files, force): """Runs cmsStage with LFNs if possible""" destIsEOSDir = isEOSDir(absDestDir) if destIsEOSDir: createEOSDir(absDestDir) for fname in files: command = ['cmsStage'] if force: command.append('-f') command.append(eosToLFN(fname)) command.append(eosToLFN(absDestDir)) print ' '.join(command) runner = cmsIO.cmsFileManip() runner.runCommand(command)
def cmsStage( absDestDir, files, force): """Runs cmsStage with LFNs if possible""" destIsEOSDir = isEOSDir(absDestDir) if destIsEOSDir: createEOSDir( absDestDir ) for fname in files: command = ['cmsStage'] if force: command.append('-f') command.append(eosToLFN(fname)) command.append(eosToLFN(absDestDir)) print ' '.join(command) runner = cmsIO.cmsFileManip() runner.runCommand(command)
def runEOSCommand(path, cmd, *args): """Run an eos command. !!! Will, when the EOS command fails, it passes silently... I think we should really try and raise an exception in case of problems. should be possible as the return code is provided in the tuple returned by runner.""" lfn = eosToLFN(path) pfn = lfnToPFN(lfn) tokens = cmsIO.splitPFN(pfn) #obviously, this is not nice command = ['/afs/cern.ch/project/eos/installation/pro/bin/eos.select', cmd] command.extend(args) command.append(tokens[2]) runner = cmsIO.cmsFileManip() return runner.runCommand(command)
def runDBS(dataset): cmd = 'file dataset='+dataset command = ['das_client.py', '--limit=0', '--query', cmd] runner = cmsIO.cmsFileManip() # print ' '.join(command) return runner.runCommand(command)
def runDBS(dataset): cmd = 'file dataset=' + dataset command = ['das_client.py', '--limit=0', '--query', cmd] runner = cmsIO.cmsFileManip() # print ' '.join(command) return runner.runCommand(command)