ARC SDK
Job List Retrieval
1 #! /usr/bin/env python
2 import arc
3 import sys
4 import os
5 
6 def example():
7  # Creating a UserConfig object with the user's proxy
8  # and the path of the trusted CA certificates
9  uc = arc.UserConfig()
10  uc.ProxyPath("/tmp/x509up_u%s" % os.getuid())
11  uc.CACertificatesDirectory("/etc/grid-security/certificates")
12 
13  # Creating an endpoint for a Computing Element
14  endpoint = arc.Endpoint("piff.hep.lu.se:443/arex", arc.Endpoint.COMPUTINGINFO)
15 
16  # Creating a container which will store the retrieved jobs
17  jobs = arc.JobContainer()
18 
19  # Create a job list retriever
20  retriever = arc.JobListRetriever(uc)
21  # Add our container as the consumer of this retriever, so it will get the results
22  retriever.addConsumer(jobs)
23 
24  # Add our endpoint to the retriever, which starts querying it
25  retriever.addEndpoint(endpoint)
26 
27  # Wait until it finishes
28  retriever.wait()
29 
30  # Get the status of the retrieval
31  print retriever.getStatusOfEndpoint(endpoint).str()
32 
33  print "Number of jobs found:", len(jobs)
34  for job in jobs:
35  job.SaveToStream(arc.CPyOstream(sys.stdout), True)
36 
37 # wait for all the background threads to finish before we destroy the objects they may use
38 import atexit
39 @atexit.register
40 def wait_exit():
41  arc.ThreadInitializer().waitExit()
42 
43 # arc.Logger.getRootLogger().addDestination(arc.LogStream(sys.stderr))
44 # arc.Logger.getRootLogger().setThreshold(arc.DEBUG)
45 
46 # run the example
47 example()