def main(): import optparse import sys parser = optparse.OptionParser() parser.add_option("--address", dest="address", default=DEFAULT_ADDRESS) parser.add_option("--size", dest="size", default='10000', type=int) parser.add_option("--reset", dest="reset", default=False, action='store_true') parser.add_option("--log-level", dest="log_level", default=DEFAULT_LOG_LEVEL) parser.add_option("--get-jobs-callback", dest="get_jobs_target", default=DEFAULT_ITERATOR_TARGET) parser.add_option("--handle-job-callback", dest="handle_job_target", default=DEFAULT_CALLBACK_TARGET) (options, args) = parser.parse_args() if len(args) < 2: print 'Usage: tm-run <script> <processes> [key=value, key2=value2]' sys.exit(1) kwargs = options.__dict__.copy() script_name = args[0] handle_job_target = script_name + ':' + kwargs.pop('handle_job_target') get_jobs_target = script_name + ':' + kwargs.pop('get_jobs_target') sys.exit(run( get_jobs_target=get_jobs_target, handle_job_target=handle_job_target, procs=int(args[1]), kwargs=parse_options(args[2:]), **kwargs ))
def main(): import optparse import sys parser = optparse.OptionParser() parser.add_option("--address", dest="address", default=DEFAULT_ADDRESS) parser.add_option("--size", dest="size", default='10000', type=int) parser.add_option("--retries", dest="retries", default=DEFAULT_RETRIES, type=int) parser.add_option("--timeout", dest="timeout", default=DEFAULT_TIMEOUT, type=int) parser.add_option("--reset", dest="reset", default=False, action='store_true') parser.add_option("--log-level", dest="log_level", default=DEFAULT_LOG_LEVEL) parser.add_option("--get-jobs-callback", dest="get_jobs_target", default=DEFAULT_ITERATOR_TARGET) parser.add_option("--handle-job-callback", dest="handle_job_target", default=DEFAULT_CALLBACK_TARGET) (options, args) = parser.parse_args() if len(args) < 2: print 'Usage: tm-run <script> <processes> [key=value, key2=value2]' sys.exit(1) kwargs = options.__dict__.copy() script_name = args[0] handle_job_target = script_name + ':' + kwargs.pop('handle_job_target') get_jobs_target = script_name + ':' + kwargs.pop('get_jobs_target') sys.exit(run( get_jobs_target=get_jobs_target, handle_job_target=handle_job_target, procs=int(args[1]), kwargs=parse_options(args[2:]), **kwargs ))
def main(): import optparse import sys parser = optparse.OptionParser() parser.add_option("--address", dest="address", default=DEFAULT_ADDRESS) parser.add_option("--size", dest="size", default=DEFAULT_BUFFER_SIZE, type=int) parser.add_option("--reset", dest="reset", default=False, action='store_true') parser.add_option("--log-level", dest="log_level", default=DEFAULT_LOG_LEVEL) (options, args) = parser.parse_args() if len(args) < 1: print 'Usage: tm-master <callback> [key=value, key2=value2]' sys.exit(1) sys.exit(run(args[0], parse_options(args[1:]), **options.__dict__))