Example #1
0
    for o, a in opts:
        if o == "-c":
            directory = a
        elif o in ("-q", "--quiet"):
            quiet = True
        elif o in ("-h", "--help"):
            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):
Example #2
0
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
Example #3
0
    for o, a in opts:
        if o == "-c":
            directory = a
        elif o in ("-q", "--quiet"):
            quiet = True
        elif o in ("-h", "--help"):
            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):
Example #4
0
    elif o in ("-h", "--help"):
      help(prog_name)
    elif o == "-c":
      directory = a
    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)

  list_stageout = []
  list_not_stageout = []
    
  fjrs = fp.get_fjrs(directory)
  for j in fjrs:
    if not quiet:
      print ">>> processing fjr", j

    try:
      doc = fp.parse_xml(j) # read xml file to see if the job failed
    except Exception, err:
      print ">>> skipping fjr " + j + '; error: ' + str(err)
      continue

    try:
      if fp.has_local_stageout(doc) : 
        if not quiet:
          print ">>> fjr <" + j + "> indicates remote stageout failure with local copy"
        copy_local_to_remote_pfn(doc, directory)