daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 68 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. #!/usr/bin/env python
  2.  
  3. from samweb_client.client import SAMWebClient
  4. from ifdh import ifdh
  5. import datetime
  6. import os
  7. import os.path
  8.  
  9. #help(SAMWebClient)
  10. #help(ifdh)
  11.  
  12. IFDH = ifdh()
  13.  
  14. #query="defname: np04_hit-reconstructed_v07_06_00_physics and data_stream physics and data_quality.online_good_run_list 1 and file_name = %_0002_%"
  15. query="defname: mcc11_protoDUNE_reco"
  16. destdir="/cshare/vol2/users/jhugon/np04_mc/mcc11"
  17.  
  18. try:
  19.   os.makedirs(destdir,0o0755)
  20. except OSError:
  21.   pass
  22.  
  23. sam = SAMWebClient()
  24. filenames = sam.listFiles(query)
  25. filenames.sort()
  26. for fn in filenames:
  27.   outfn = os.path.join(destdir,fn)
  28.   if os.path.exists(outfn):
  29.     print "File already exists: "+fn+" skipping"
  30.   else:
  31.     metadata = sam.getMetadata(fn)
  32.     event_count = int(metadata["event_count"])
  33.     file_size = int(metadata["file_size"])
  34.     startTime = datetime.datetime.now()
  35.     print "{} Downloading {} {:.2f} GiB {} Events ...".format(datetime.datetime.now().replace(microsecond=0).isoformat(' '),fn,float(file_size)/1024**3,event_count)
  36.     url = sam.getFileAccessUrls(fn,"gsiftp")
  37.     cpArgs = ["-D"] + url + [destdir]
  38.     print  " running: ifdh cp " + ' '.join(cpArgs)
  39.     IFDH.cp(cpArgs)
  40.     endTime = datetime.datetime.now()
  41.     #fileSize = os.path.getsize(outfn)
  42.     transferSpeed = float(file_size)/1024**2 / (endTime-startTime).total_seconds()
  43.     print "  Took {0} to download, averaging {1:.2f} MiB".format(endTime-startTime,transferSpeed)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top