/usr/share/arc/examples/sdk/job_submission.py is in nordugrid-arc-python 5.0.5-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #! /usr/bin/env python
import arc
import sys
import os
import random
def example():
# Creating a UserConfig object with the user's proxy
# and the path of the trusted CA certificates
uc = arc.UserConfig()
uc.ProxyPath("/tmp/x509up_u%s" % os.getuid())
uc.CACertificatesDirectory("/etc/grid-security/certificates")
# Creating an endpoint for a Computing Element
endpoint = arc.Endpoint("piff.hep.lu.se", arc.Endpoint.COMPUTINGINFO, "org.nordugrid.ldapglue2")
# Get the ExecutionTargets of this ComputingElement
retriever = arc.ComputingServiceRetriever(uc, [endpoint])
retriever.wait()
targets = retriever.GetExecutionTargets()
# Shuffle the targets to simulate a random broker
targets = list(targets)
random.shuffle(targets)
# Create a JobDescription
jobdesc = arc.JobDescription()
jobdesc.Application.Executable.Path = "/bin/hostname"
jobdesc.Application.Output = "stdout.txt"
# create an empty job object which will contain our submitted job
job = arc.Job()
success = False
# Submit job directly to the execution targets, without a broker
for target in targets:
sys.stdout.write("Trying to submit to %s (%s) ... "%(target.ComputingEndpoint.URLString, target.ComputingEndpoint.InterfaceName))
sys.stdout.flush()
success = target.Submit(uc, jobdesc, job)
if success:
sys.stdout.write("succeeded!\n")
break
else:
sys.stdout.write("failed!\n")
if success:
sys.stdout.write("Job was submitted:\n")
job.SaveToStream(arc.CPyOstream(sys.stdout), False)
else:
sys.stdout.write("Job submission failed\n")
# wait for all the background threads to finish before we destroy the objects they may use
import atexit
@atexit.register
def wait_exit():
arc.ThreadInitializer().waitExit()
# arc.Logger.getRootLogger().addDestination(arc.LogStream(sys.stderr))
# arc.Logger.getRootLogger().setThreshold(arc.DEBUG)
# run the example
example()
|