#!/bin/env python ################################################################## # # Python development bootstrap script # # $Revision: #1 $ # $Change: 7988 $ # ################################################################## # load system libs import sys, os, os.path import getopt # load qb module try: import qb except ImportError: # make a guess if 'QBDIR' not in os.environ: os.environ['QBDIR'] = { 'win': 'C:/Program Files/pfx/qube', 'darwin': '/Applications/pfx/qube', 'linux': '/usr/local/pfx/qube' }[sys.platform] sys.path.append('%s/api/python' % os.environ['QB_DIR']) import qb def main(): options = 'h' longOptions = ['archive=', 'backend=', 'base=', 'frontend=', 'help', 'type='] opts, pargs = getopt.getopt(sys.argv[1:], options, longOptions) # setup some defaults archive = "job.qja" base = '.' frontend = '' backend = "execute.py" type = '' for opt in opts: if opt[0] == '--archive': archive = opt[1] if opt[0] == '--base': base = opt[1] elif opt[0] == '--backend': backend = opt[1] elif opt[0] == '--frontend': frontend = opt[1] elif opt[0] == '--type': type = opt[1] elif opt[0] == '--help' or opt[0] == '-h': usage() return if type != '': archive = os.path.join(base, type, archive) backend = os.path.join(base, type, backend) else: archive = os.path.join(base, archive) backend = os.path.join(base, backend) if not os.path.exists(backend): print 'ERROR: backend %s not found' % backend sys.exit(1) # output the archive if frontend: print 'executing %s...' % frontend os.system(frontend) if not os.path.exists(archive): print 'ERROR: archive %s not found' % archive sys.exit(1) # setup development env, load up the job archive qb._setjob(archive) # launch into the backend module print "INFO: bootstrap script loading execute module\n" execfile(backend, globals()) def usage(): print 'bootstrap.py [options]' print 'where [options] are:' print '\t--archive : path to existing job archive (job.xja)' print '\t--backend : path to backend (execute.py)' print '\t--base : path to type directory' print '\t--frontend : frontend command to create job submission archive (None)' print '\t--type : type name' print '\t-h|--help : usage message' return if __name__ == '__main__': main()