コード例 #1
0
ファイル: UploadOnGrid.py プロジェクト: cmdric/dotfiles
      if not hasbeensent2[0] == "done":
        #need to be modified to have a different GUID for each file
        print "not done for GUID"
        f1l = open(full_file,'w')
        f1l.write('done'+'\n'+'on grid/castor: done'+'\n'+'number of event processed of type '+ typea[len(typea)-2]+' stripping '+ typea[len(typea)-1]+ ': '+hasbeensent2[0]+'\n'+str( datetime.datetime.now() ))
        f1l.close()
    mypfn = full_file
    dirac = Dirac()
    lfn = full_file.replace('/panasas/radiative/', '/lhcb/user/p/potterat/')
    print lfn
    metaData = dirac.getMetadata(lfn)
#    metaData = metaData['Value']['Successful'][lfn]
   # metaData2 = metaData2['Value']['Successful'][lfn2]
    print metaData
    if len(metaData['Value']['Successful']) < 1:
      test = dirac.addFile( lfn, mypfn, 'CERN-USER',  DIRAC.makeGuid(mypfn))
      print test
      if(test.has_key('Message')):
        #GUID Exists !
        test2 = test['Message'].split(" try again. ")
        print "remove the wrong path"
        rm.removeFile(test2[1])
        dirac.addFile( lfn, mypfn, 'CERN-USER',  DIRAC.makeGuid(mypfn))
     # mypfn.upload(lfn,'CERN-USER')
      print full_file,"copied to",lfn
      f1l = open('onGrid.txt','w')
      f1l.write(sent+full_file+'\n')
      f1l.close()
    else :
      if (metaData['Value']['Successful'][lfn]['Size'] == os.path.getsize(full_file)):
        print " "