get_files.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 
5 # Creation Date : 2013-10-28, Qizhong Li
6 # upgraded to be python2 and python 3 compatible by Tom Junk. Only modified print statements
7 
8 import os, sys
9 import samweb_client
10 
11 Project = sys.argv[1]
12 Destination = sys.argv[2]
13 
14 samweb = samweb_client.SAMWebClient(experiment='lbne')
15 
16 def testProject(defname="project", appFamily="demo", appName="demo", appVersion="demo"):
17 
18  projectname = samweb.makeProjectName(defname)
19  projectinfo = samweb.startProject(projectname, defname)
20  projecturl = projectinfo["projectURL"]
21  print ("Project name is %s" % projectinfo["project"])
22  print ("Project URL is %s" % projecturl)
23 
24  deliveryLocation = None # set this to a specific hostname if you want - default is the local hostname
25  cpid = samweb.startProcess(projecturl, appFamily, appName, appVersion, deliveryLocation)
26  print ("Consumer process id %s" % cpid)
27  processurl = samweb.makeProcessUrl(projecturl, cpid)
28  print ("Process URL is %s" % processurl)
29 
30  while True:
31  try:
32  newfile = samweb.getNextFile(processurl)['url']
33  print ("Got file %s" % newfile)
34  print ("Attempting globus-url-copy to scratch...")
35  stat = os.system('globus-url-copy %s %s' % (newfile,Destination))
36  except samweb_client.NoMoreFiles:
37  print ("No more files available")
38  break
39 
40  samweb.releaseFile(processurl, newfile)
41  print ("Released file %s" % newfile)
42 
43  samweb.stopProject(projecturl)
44  print samweb.projectSummaryText(projecturl)
45  print ("Project ended")
46 
47 if __name__ == '__main__':
48 
49  testProject(defname=Project)
50 
51 
52 
53 # vim 73
def testProject(defname="project", appFamily="demo", appName="demo", appVersion="demo")
Definition: get_files.py:16