~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty-proposed

« back to all changes in this revision

Viewing changes to python/examples/job_status.py

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2013-05-08 13:48:03 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20130508134803-mrhc5w4d5y7ubyj4
Tags: 3.0.1-1
3.0.1 Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
    # Create a new job object with a given JobID
 
14
    job = arc.Job()
 
15
    job.JobID = "https://piff.hep.lu.se:443/arex/1QuMDmRwvUfn5h5iWqkutBwoABFKDmABFKDmIpHKDmXBFKDmIuAean"
 
16
    job.Flavour = "ARC1"
 
17
    job.JobManagementURL = arc.URL("https://piff.hep.lu.se:443/arex")
 
18
    job.JobStatusURL = arc.URL("https://piff.hep.lu.se:443/arex")
 
19
    
 
20
    print "Job object before update:"
 
21
    job.SaveToStream(arc.CPyOstream(sys.stdout), True)
 
22
    
 
23
    job_supervisor = arc.JobSupervisor(uc, [job])
 
24
 
 
25
    # Update the states of jobs within this JobSupervisor
 
26
    job_supervisor.Update()
 
27
    
 
28
    # Get our updated job from the JobSupervisor
 
29
    jobs = job_supervisor.GetAllJobs()
 
30
    job = jobs[0]
 
31
    
 
32
    print "Job object after update:"
 
33
    job.SaveToStream(arc.CPyOstream(sys.stdout), True)
 
34
    
 
35
# wait for all the background threads to finish before we destroy the objects they may use
 
36
import atexit
 
37
@atexit.register
 
38
def wait_exit():
 
39
    arc.ThreadInitializer().waitExit()
 
40
 
 
41
# arc.Logger.getRootLogger().addDestination(arc.LogStream(sys.stderr))
 
42
# arc.Logger.getRootLogger().setThreshold(arc.DEBUG)
 
43
 
 
44
# run the example
 
45
example()