def main(): # first options needed for this script itself (the rest will be ignored for now) option_list = ( make_option('--pythonpath', action='append', help='A directory to add to the Python path, e.g. --pythonpath=/my/module'), make_option('--worker-config', dest='worker_config', help='The worker config class to use, e.g. --worker-config=my.module.MyWorkerConfig, ' 'default to limpyd_jobs.workers.WorkerConfig') ) # create a light option parser that ignore everything but basic options # defined below parser = LaxOptionParser(usage="%prog [options]", option_list=option_list) options, args = parser.parse_args(sys.argv[:]) # if we have some pythonpaths, add them if options.pythonpath: sys.path[0:0] = parser.parse_python_paths(sys.argv[:]) try: # still load the defaut config, needed to parse the worker_config option from limpyd_jobs.workers import WorkerConfig # by default use the default worker config worker_config_class = WorkerConfig # and try to load the one passed as argument if any if options.worker_config: worker_config_class = WorkerConfig.import_class(options.worker_config) # finally instantiate and run the worker worker_config = worker_config_class() worker_config.execute() except ImportError as e: parser.print_lax_help() parser.lax_error('No WorkerConfig found. You need to use --pythonpath ' 'and/or --worker-config: %s' % str(e))
"default to limpyd_jobs.workers.WorkerConfig", ), ) # create a light option parser that ignore everything but basic options # defined below parser = LaxOptionParser(usage="%prog [options]", option_list=option_list) options, args = parser.parse_args(sys.argv[:]) # if we have some pythonpaths, add them if options.pythonpath: sys.path[0:0] = parser.parse_python_paths(sys.argv[:]) try: # still load the defaut config, needed to parse the worker_config option from limpyd_jobs.workers import WorkerConfig # by default use the default worker config worker_config_class = WorkerConfig # and try to load the one passed as argument if any if options.worker_config: worker_config_class = WorkerConfig.import_class(options.worker_config) # finally instantiate and run the worker worker_config = worker_config_class() worker_config.execute() except ImportError, e: parser.print_lax_help() parser.lax_error("No WorkerConfig found. You need to use --pythonpath " "and/or --worker-config: %s" % str(e))