help(prog_name) else: print ">>> ", "unhandled option", o help(prog_name) if directory == "" or not os.path.exists(directory): print ">>> path <" + directory + "> may not exist" help(prog_name) fjrs = fp.get_fjrs(directory) for f in fjrs: if not quiet: print ">>> ", "processing fjr", f # parse fjr try: doc = fp.parse_xml(f) except: if not quiet: print ">>> ", 'FrameworkJobReport', f, 'could not be parsed and is skipped' continue # if the job finished successfully get the PFN try: if fp.is_goodfile(doc): (lfn, pfn, surl) = fp.get_filenames(doc) print pfn except: if not quiet: print ">>> ", "skipping fjr", f
help(prog_name) else: print ">>> ", "unhandled option", o help(prog_name) if directory == "" or not os.path.exists(directory): print ">>> path <" + directory + "> may not exist" help(prog_name) fjrs = fp.get_fjrs(directory) for f in fjrs: if not quiet: print ">>> ", "processing fjr", f # parse fjr try: doc = fp.parse_xml(f) except: if not quiet: print ">>> ", "FrameworkJobReport", f, "could not be parsed and is skipped" continue # if the job finished successfully get the PFN try: if fp.is_goodfile(doc): (lfn, pfn, surl) = fp.get_filenames(doc) print pfn except: if not quiet: print ">>> ", "skipping fjr", f
def copy_local_to_remote_pfn (fjr, directory): (local_lfn, local_pfn, local_surl) = fp.get_filenames(fjr) remote_filename = os.path.split(local_lfn)[1] remote_pfn = '' if copy_to_ui: path, endpoint = fp.cp_ui_target(directory) remote_pfn = endpoint + remote_filename remote_path = path + remote_filename else: remote_pfn = fp.cp_target(directory) + remote_filename if remote_pfn == '': print ">>> Failed to find remote_pfn: ", remote_pfn list_stageout.append(local_surl) if not quiet: print ">>> copying from local:", local_surl, "to remote:", remote_pfn if dryrun: return # copy lcg_cp = "lcg-cp -v " + "-D srmv2 " + local_surl + " " + remote_pfn print ">>> ", lcg_cp (lcg_cp_stat, lcg_cp_output) = fp.getstatusoutput(lcg_cp) if lcg_cp_stat != 0: print ">>> aborting retrieval, copy error:", lcg_cp_output raise RuntimeError('lcg-cp failed!') # check copied file (source) (lcg_ls_source_stat, lcg_ls_source) = fp.getstatusoutput("lcg-ls -l -D srmv2 " + local_surl) if lcg_ls_source_stat != 0: print ">>> aborting retrieval, size check error:", lcg_ls_source raise RuntimeError('lcg-ls source failed!') # destination if copy_to_ui: (lcg_ls_dest_stat, lcg_ls_dest) = fp.getstatusoutput("ls -l " + remote_path) else: (lcg_ls_dest_stat, lcg_ls_dest) = fp.getstatusoutput("lcg-ls -l -D srmv2 " + remote_pfn) if lcg_ls_dest_stat != 0: print ">>> aborting retrieval, size check error:", lcg_ls_dest raise RuntimeError('lcg-ls destination failed!') # compare file size source_size = lcg_ls_source.split()[4] dest_size = lcg_ls_dest.split()[4] if source_size != dest_size: print ">>> aborting retrieval, copy error: source size", source_size, "dest size", dest_size raise RuntimeError('source/dest filesize mis-match!') # remove original if remove_after_copy: if not quiet: print ">>> removing lcoal copy", local_surl (lcg_del_output_stat, lcg_del_output) = fp.getstatusoutput("lcg-del -D srmv2 " + local_surl) if lcg_del_output_stat != 0: print ">>> warning: could not remove local copy:", lcg_del_output # update local_pfn to the remote surl for node in doc.getElementsByTagName("PFN"): if node.parentNode.tagName == "AnalysisFile": node.attributes["Value"].value = remote_pfn