#!/usr/bin/python
#######################################################################
#
#    Example:  qb.submit
#
#	Demonstrates usage of the qb.submit routine to submit
#       a single job.
#
#######################################################################
#
# Licensed Materials - Property of PipelineFX L.L.C.
# 
#  (C) COPYRIGHT PipelineFX Limited Liability Corporation. 2007
#  All Rights Reserved.
#  				
#  US Government Users Restricted Rights - Use, duplication or
#  disclosure restricted by GSA ADP Schedule Contract with 
#  PipelineFX L.L.C.
# 
#######################################################################

import os, sys

#
#  Setup the module path
#
if 'QBDIR' in os.environ:
	sys.path.append('%s/api/python' % os.environ['QBDIR']);
elif os.uname()[0] == 'Darwin':
	sys.path.append('/Applications/pfx/qube/api/python');
elif os.uname()[0] == 'Linux':
	sys.path.append('/usr/local/pfx/qube/api/python');
else:
	sys.path.append('c:/program files/pfx/qube/api/python');
sys.path.append('../../api/python');

#
#  Import the qb module
#
import qb

#######################################################################

def main():
    #
    #   Create Job object to be submitted into the farm.
    #
    job = qb.Job()
    job.name('hello')
    job.cpus(1);
    job.prototype('cmdline')
    job.requirements('host.os=linux')
    
    #
    #  Setup generic package data
    #
    package = {}  # we use a dict because it is cross portable with other scripting languages
    package['cmdline'] = 'sleep 10'

    job.package(package)

    listOfJobsToSubmit = []
    listOfJobsToSubmit.append(job)

    listOfSubmittedJobs = qb.submit(listOfJobsToSubmit)
    for job in listOfSubmittedJobs:
        print 'id: %d' % job['id']

#######################################################################

if __name__ == "__main__":
    main()
    sys.exit(0)




