def prepareOutFiles(outFiles, logFile, workdir): """ verify and prepare and the output files for transfer """ ec = 0 pilotErrorDiag = "" outs = [] modt = [] from SiteMover import SiteMover for outf in outFiles: if outf and outf != 'NULL': # non-empty string and not NULL if not os.path.isfile("%s/%s" % (workdir, outf)): # expected output file is missing pilotErrorDiag = "Expected output file %s does not exist" % (outf) tolog("!!FAILED!!3000!! %s" % (pilotErrorDiag)) error = PilotErrors() ec = error.ERR_MISSINGOUTPUTFILE break else: outs.append(outf) # get the modification time for the file (needed by NG) modt.append(SiteMover.getModTime(workdir, outf)) tolog("Output file(s):") try: _ec, _rs = commands.getstatusoutput("ls -l %s/%s" % (workdir, outf)) except Exception, e: tolog(str(e)) else: tolog(_rs)
def prepareOutFiles(outFiles, logFile, workdir, fullpath=False): """ verify and prepare the output files for transfer """ # fullpath = True means that the file in outFiles already has a full path, adding it to workdir is then not needed ec = 0 pilotErrorDiag = "" outs = [] modt = [] from SiteMover import SiteMover for outf in outFiles: if outf and outf != 'NULL': # non-empty string and not NULL path = os.path.join(workdir, outf) if (not os.path.isfile(path) and not fullpath) or (not os.path.isfile(outf) and fullpath): pilotErrorDiag = "Expected output file %s does not exist" % ( path) tolog("!!FAILED!!3000!! %s" % (pilotErrorDiag)) error = PilotErrors() ec = error.ERR_MISSINGOUTPUTFILE break else: tolog("outf = %s" % (outf)) if fullpath: # remove the full path here from outf workdir = os.path.dirname(outf) outf = os.path.basename(outf) outs.append(outf) # get the modification time for the file (needed by NG) modt.append(SiteMover.getModTime(workdir, outf)) tolog("Output file(s):") try: _ec, _rs = commands.getstatusoutput("ls -l %s/%s" % (workdir, outf)) except Exception, e: tolog(str(e)) else: tolog(_rs)
def prepareOutFiles(outFiles, logFile, workdir, fullpath=False): """ verify and prepare the output files for transfer """ # fullpath = True means that the file in outFiles already has a full path, adding it to workdir is then not needed ec = 0 pilotErrorDiag = "" outs = [] modt = [] from SiteMover import SiteMover for outf in outFiles: if outf and outf != 'NULL': # non-empty string and not NULL path = os.path.join(workdir, outf) if (not os.path.isfile(path) and not fullpath) or (not os.path.isfile(outf) and fullpath): pilotErrorDiag = "Expected output file %s does not exist" % (path) tolog("!!FAILED!!3000!! %s" % (pilotErrorDiag)) error = PilotErrors() ec = error.ERR_MISSINGOUTPUTFILE break else: tolog("outf = %s" % (outf)) if fullpath: # remove the full path here from outf workdir = os.path.dirname(outf) outf = os.path.basename(outf) outs.append(outf) # get the modification time for the file (needed by NG) modt.append(SiteMover.getModTime(workdir, outf)) tolog("Output file(s):") try: _ec, _rs = commands.getstatusoutput("ls -l %s/%s" % (workdir, outf)) except Exception, e: tolog(str(e)) else: tolog(_rs)