def main(argv):
parser = OptionParser(helpString)<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store>", type="<STR_LIT:int>", default=None,<EOL>help="<STR_LIT>")<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store>", type="<STR_LIT:str>", default=None,<EOL>help=("<STR_LIT>"<EOL>"<STR_LIT>"))<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store>", type="<STR_LIT:str>", default=None,<EOL>help=("<STR_LIT>"<EOL>"<STR_LIT>"))<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store>", default=None,<EOL>help="<STR_LIT>""<STR_LIT>""<STR_LIT>")<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store_true>", default=False,<EOL>help="<STR_LIT>")<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store_true>", default=False,<EOL>help="<STR_LIT>")<EOL>parser.add_option("<STR_LIT>", action="<STR_LIT:store>", type="<STR_LIT:int>", default=None,<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL>(options, args) = parser.parse_args(argv[<NUM_LIT:1>:])<EOL>if len(args) != <NUM_LIT:0>:<EOL><INDENT>raise RuntimeError("<STR_LIT>" %(args))<EOL><DEDENT>if (options.jobID and options.params):<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if (options.jobID is None and options.params is None):<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>initLogging(verbose=True)<EOL>hst = HypersearchWorker(options, argv[<NUM_LIT:1>:])<EOL>if options.params is None:<EOL><INDENT>try:<EOL><INDENT>jobID = hst.run()<EOL><DEDENT>except Exception as e:<EOL><INDENT>jobID = options.jobID<EOL>msg = io.StringIO()<EOL>print("<STR_LIT>" %(ErrorCodes.hypersearchLogicErr, e), file=msg)<EOL>traceback.print_exc(None, msg)<EOL>completionReason = ClientJobsDAO.CMPL_REASON_ERROR<EOL>completionMsg = msg.getvalue()<EOL>hst.logger.error(completionMsg)<EOL>jobsDAO = ClientJobsDAO.get()<EOL>workerCmpReason = jobsDAO.jobGetFields(options.jobID,<EOL>['<STR_LIT>'])[<NUM_LIT:0>]<EOL>if workerCmpReason == ClientJobsDAO.CMPL_REASON_SUCCESS:<EOL><INDENT>jobsDAO.jobSetFields(options.jobID, fields=dict(<EOL>cancel=True,<EOL>workerCompletionReason = ClientJobsDAO.CMPL_REASON_ERROR,<EOL>workerCompletionMsg = completionMsg),<EOL>useConnectionID=False,<EOL>ignoreUnchanged=True)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>jobID = None<EOL>completionReason = ClientJobsDAO.CMPL_REASON_SUCCESS<EOL>completionMsg = "<STR_LIT>"<EOL>try:<EOL><INDENT>jobID = hst.run()<EOL><DEDENT>except Exception as e:<EOL><INDENT>jobID = hst._options.jobID<EOL>completionReason = ClientJobsDAO.CMPL_REASON_ERROR<EOL>completionMsg = "<STR_LIT>" % (e,)<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>if jobID is not None:<EOL><INDENT>cjDAO = ClientJobsDAO.get()<EOL>cjDAO.jobSetCompleted(jobID=jobID,<EOL>completionReason=completionReason,<EOL>completionMsg=completionMsg)<EOL><DEDENT><DEDENT><DEDENT>return jobID<EOL>
The main function of the HypersearchWorker script. This parses the command
line arguments, instantiates a HypersearchWorker instance, and then
runs it.

Parameters:
----------------------------------------------------------------------
retval:     jobID of the job we ran. This is used by unit test code
              when calling this working using the --params command
              line option (which tells this worker to insert the job
              itself).