#!/usr/bin/env python # import test_lib as lib import lib import sys import os import getopt def main(argv=None): """ Usage is: delete.py -j jobid [-u url] Returns 0 with "jobid=" on stdout if job submitted ok Returns 1 with multiline error message on stdout if error. Returns 2 for the specific error of queue limit exceeded. """ if argv is None: argv=sys.argv jobid = url = None options, remainder = getopt.getopt(argv[1:], "-j:-u:") for opt, arg in options: if opt in ("-j"): jobid = int(arg) elif opt in ("-u"): url = arg try: if not jobid: raise SystemError("Internal error, delete.py invoked without jobid.") lib.deleteJob(jobid) except SystemError, theException: print >> sys.stderr, "Caught exception:", theException return 1 if __name__ == "__main__": sys.exit(main())