Пример #1
0
    def tests_callback( self, option, opt_str, value, parser ):
        assert value is None
        done = 0
        value = []
        rargs = parser.rargs
        while rargs:
            arg = rargs[0]
            if ( (arg[:2] == "--" and len(arg) > 2) or
                 (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-") ):
                break
            else:
                if ( arg in ("KS", "chi2", "bbb", "all" ) ):
                    value.append(arg)
                    del rargs[0]
                else:
                    raise optparse.OptionValueError("unknown statistics test value '%s'" % arg ) 

        if ( "all" in value ): value = [ "KS", "bbb", "chi2" ]
        assert len(value) != 0
        setattr( parser.values, option.dest, value )
Пример #2
0
 def process(self, opt, value, values, parser):
     """
     Call the validator function on applicable settings and
     evaluate the 'overrides' option.
     Extends `optparse.Option.process`.
     """
     result = optparse.Option.process(self, opt, value, values, parser)
     setting = self.dest
     if setting:
         if self.validator:
             value = getattr(values, setting)
             try:
                 new_value = self.validator(setting, value, parser)
             except Exception, error:
                 raise (optparse.OptionValueError(
                     'Error in option "%s":\n    %s' %
                     (opt, ErrorString(error))), None, sys.exc_info()[2])
             setattr(values, setting, new_value)
         if self.overrides:
             setattr(values, self.overrides, None)
Пример #3
0
 def zekkaa(option, opt, value):
     try:
         num, unit = value[:-1], value[-1]
         if unit not in "tsark%":
             return float(value), "s"
         elif unit == "%":
             return float(num), unit
         elif unit == "s":
             return float(num), unit
         elif unit == "a":
             return int(num), unit
         elif unit == "r":
             return int(num), unit
         elif unit == "k":
             return int(num), unit
         elif unit == "t":
             return int(num), unit
     except ValueError:
         raise optparse.OptionValueError("Invalid datarate value: %s" %
                                         value)
Пример #4
0
def partition(pgt, opts):

    from .dropmake import pg_generator

    algo_params = opts.algo_params or []
    param_types = {
        'min_goal': int,
        'ptype': int,
        'max_load_imb': int,
        'max_dop': int,
        'time_greedy': float,
        'deadline': int,
        'topk': int,
        'swarm_size': int
    }

    # Double-check that -A command-line flags are of shape name=value
    for p in algo_params:
        if len(list(filter(None, p.split('=')))) != 2:
            raise optparse.OptionValueError(
                'Algorithm parameter has no form of name=value: %s' % (p, ))

    # Extract algorithm parameters and convert to proper type
    algo_params = {
        n: param_types[n](v)
        for n, v in map(lambda p: p.split('='), algo_params)
        if n in param_types
    }

    pgt = pg_generator.partition(pgt,
                                 algo=opts.algo,
                                 num_partitions=opts.partitions,
                                 num_islands=opts.islands,
                                 partition_label='partition',
                                 **algo_params)
    pg_spec = pgt.to_pg_spec([],
                             ret_str=False,
                             num_islands=opts.islands,
                             tpl_nodes_len=opts.partitions + opts.islands)
    logger.info("PG spec is calculated!")
    return pg_spec
def check_manifest_conflict_args(option, opt_str, value, parser):
    '''Check for -m/--manifest with conflicting args'''
    conflict_args = ['abstractions',
                     'read_path',
                     'write_path',
                     # template always get set to 'default', can't conflict
                     # 'template',
                     'policy_groups',
                     'policy_version',
                     'policy_vendor',
                     'name',
                     'profile_name',
                     'comment',
                     'copyright',
                     'author',
                     'template_var']
    for conflict in conflict_args:
        if getattr(parser.values, conflict, False):
            raise optparse.OptionValueError("can't use --%s with --manifest " \
                                            "argument" % conflict)
    setattr(parser.values, option.dest, value)
Пример #6
0
def get_suites(values, args):
    if (values.suite_files is None and not args) or (values.suite_files is not None and args):
        raise optparse.OptionValueError("Must specify either --suites or a list of tests")

    # If there are no suites specified, but there are args, assume they are jstests.
    if args:
        # No specified config, just use the following, and default the logging and executor.
        suite_config = _make_jstests_config(args)
        _ensure_executor(suite_config, values.executor_file)
        suite = testing.suite.Suite("<jstests>", suite_config)
        return [suite]

    suite_files = values.suite_files.split(",")

    suites = []
    for suite_filename in suite_files:
        suite_config = _get_suite_config(suite_filename)
        _ensure_executor(suite_config, values.executor_file)
        suite = testing.suite.Suite(suite_filename, suite_config)
        suites.append(suite)
    return suites
Пример #7
0
def update_config_vars(values):
    options = _get_options_config(values.options_file)

    config = _config.DEFAULTS.copy()
    config.update(options)

    values = vars(values)
    for dest in values:
        if dest not in DEST_TO_CONFIG:
            continue
        config_var = DEST_TO_CONFIG[dest]
        if values[dest] is not None:
            config[config_var] = values[dest]

    _config.BUILDLOGGER_URL = config.pop("buildloggerUrl")
    _config.DBPATH_PREFIX = _expand_user(config.pop("dbpathPrefix"))
    _config.DBTEST_EXECUTABLE = _expand_user(config.pop("dbtest"))
    _config.DRY_RUN = config.pop("dryRun")
    _config.FAIL_FAST = not config.pop("continueOnFailure")
    _config.JOBS = config.pop("jobs")
    _config.MONGO_EXECUTABLE = _expand_user(config.pop("mongo"))
    _config.MONGOD_EXECUTABLE = _expand_user(config.pop("mongod"))
    _config.MONGOD_SET_PARAMETERS = config.pop("mongodSetParameters")
    _config.MONGOS_EXECUTABLE = _expand_user(config.pop("mongos"))
    _config.MONGOS_SET_PARAMETERS = config.pop("mongosSetParameters")
    _config.NO_JOURNAL = config.pop("nojournal")
    _config.NO_PREALLOC_JOURNAL = config.pop("nopreallocj")
    _config.RANDOM_SEED = config.pop("seed")
    _config.REPEAT = config.pop("repeat")
    _config.REPORT_FILE = config.pop("reportFile")
    _config.SHELL_WRITE_MODE = config.pop("shellWriteMode")
    _config.SHUFFLE = config.pop("shuffle")
    _config.STORAGE_ENGINE = config.pop("storageEngine")
    _config.WT_COLL_CONFIG = config.pop("wiredTigerCollectionConfigString")
    _config.WT_ENGINE_CONFIG = config.pop("wiredTigerEngineConfigString")
    _config.WT_INDEX_CONFIG = config.pop("wiredTigerIndexConfigString")

    if config:
        raise optparse.OptionValueError("Unknown option(s): %s" %
                                        (config.keys()))
Пример #8
0
def reapVarArgsCallback(option, optStr, value, parser):
    """Used as optparse callback for reaping a variable number of option args.
  The option may be specified multiple times, and all the args associated with
  that option name will be accumulated in the order that they are encountered
  """
    newValues = []

    # Reap the args, taking care to stop before the next option or '.'
    gotDot = False
    for arg in parser.rargs:
        # Stop on --longname options
        if arg.startswith("--") and len(arg) > 2:
            break

        # Stop on -b options
        if arg.startswith("-") and len(arg) > 1:
            break

        if arg == ".":
            gotDot = True
            break

        newValues.append(arg)

    if not newValues:
        raise optparse.OptionValueError(
            ("Empty arg list for option %r expecting one or more args "
             "(remaining tokens: %r)") % (optStr, parser.rargs))

    del parser.rargs[:len(newValues) + int(gotDot)]

    # Retrieve the existing arg accumulator, if any
    value = getattr(parser.values, option.dest, [])
    #print "Previous value: %r" % value
    if value is None:
        value = []

    # Append the new args to the existing ones and save to the parser
    value.extend(newValues)
    setattr(parser.values, option.dest, value)
Пример #9
0
    def __init__(self, argv):
        """Parse and encapsulate the command-line options.

    Also sets up some basic logger configuration.

    Args:
      argv: sys.argv (argv[0] is the main script). None for unit tests.

    Raises:
      optarse.OptParseError: bad option or input filenames.
    """
        o = self._options()
        self._options, arguments = o.parse_args(argv)
        self._options.input, output = _parse_arguments(arguments[1:])
        if output:
            if self._options.output:
                raise optparse.OptionValueError(
                    "x:y notation not allowed with -o")
            self._options.output = output
        names = {opt.dest for opt in o.option_list if opt.dest}
        names.add("input")
        self._postprocess_options(names)
Пример #10
0
 def expand_args(self, args):
     """Expands @response files and wildcards in the command line"""
     result = []
     for arg in args:
         if arg[0] == '@' and len(arg) > 1:
             arg = os.path.normcase(
                 os.path.realpath(
                     os.path.abspath(os.path.expanduser(arg[1:]))))
             try:
                 with open(arg, 'rU') as resp_file:
                     for resp_arg in resp_file:
                         # Only strip the line break (whitespace is significant)
                         resp_arg = resp_arg.rstrip('\n')
                         # Only perform globbing on response file values for UNIX
                         if sys.platform.startswith('win'):
                             result.append(resp_arg)
                         else:
                             result.extend(self.glob_arg(resp_arg))
             except IOError, e:
                 raise optparse.OptionValueError(str(e))
         else:
             result.append(arg)
Пример #11
0
 def _CheckMemsize(option, opt, value):
     # Note: purposely no 'b' suffix, since that makes 0x12b ambiguous.
     multiplier_table = [
         ('g', 1024 * 1024 * 1024),
         ('m', 1024 * 1024),
         ('k', 1024),
         ('', 1),
     ]
     for (suffix, multiplier) in multiplier_table:
         if value.lower().endswith(suffix):
             new_value = value
             if suffix:
                 new_value = new_value[:-len(suffix)]
             try:
                 # Convert w/ base 0 (handles hex, binary, octal, etc)
                 return int(new_value, 0) * multiplier
             except ValueError:
                 # Pass and try other suffixes; not useful now, but may be
                 # useful later if we ever allow B vs. GB vs. GiB.
                 pass
     raise optparse.OptionValueError(
         "option %s: invalid memsize value: %r" % (opt, value))
Пример #12
0
def output_option_parser(option, opt, value, parser):
    """Parse the string of outputs and validate it.

    Args:
        option (optparse.Option): the Option instnace.
        opt (str): option calling format.
        value (str): user input for the option.
        parser (optparse.OptionParser): the parser of the option.

    Raises:
        optparse.OptionValueError. unsupported handler requested.
    """
    output_options = get_result_handler_options()

    handlers = value.split(',')

    for handler in handlers:
        if handler not in output_options:
            raise optparse.OptionValueError(
                'Unsupported handler %r, supported handlers: %s' %
                (handler, ", ".join(output_options)))

    setattr(parser.values, option.dest, handlers)
Пример #13
0
    def build_tests(roots=["./"],
                    include_files=[],
                    include_files_except=[],
                    exclude_files=[],
                    exclude_files_except=[],
                    extract_metadata=True,
                    **kwargs):

        if len(kwargs) > 0:
            raise optparse.OptionValueError(
                "Unrecognized options for tests: %s" % kwargs)

        file_regex_query = smoke.suites.RegexQuery(re_compile_all(include_files),
                                                   re_compile_all(
                                                       include_files_except),
                                                   re_compile_all(
                                                       exclude_files),
                                                   re_compile_all(exclude_files_except))

        if isinstance(roots, basestring):
            roots = [roots]

        return smoke.tests.build_tests(roots, file_regex_query, extract_metadata)
Пример #14
0
def get_suites(values, args):
    if (values.suite_files is None
            and not args) or (values.suite_files is not None and args):
        raise optparse.OptionValueError(
            "Must specify either --suites or a list of tests")

    _config.INTERNAL_EXECUTOR_NAME = values.executor_file

    # If there are no suites specified, but args, collect the specified files.
    if args:
        # Do not change the execution order of the tests passed as args, unless a tag option is
        # specified. If an option is specified, then sort the tests for consistent execution order.
        _config.ORDER_TESTS_BY_NAME = any(
            tag_filter is not None
            for tag_filter in (_config.EXCLUDE_WITH_ANY_TAGS,
                               _config.INCLUDE_WITH_ANY_TAGS))
        # No specified config, just use the following, and default the logging and executor.
        suite_config = _make_config(args)
        _ensure_executor(suite_config, values.executor_file)
        # The test_kind comes from the executor file.
        _ensure_test_kind(suite_config,
                          _get_yaml_config("executor", values.executor_file),
                          values.executor_file)
        suite = testing.suite.Suite("<%s>" % suite_config["test_kind"],
                                    suite_config)
        return [suite]

    suite_files = values.suite_files.split(",")

    suites = []
    for suite_filename in suite_files:
        suite_config = _get_suite_config(suite_filename)
        _ensure_executor(suite_config, values.executor_file)
        suite = testing.suite.Suite(suite_filename, suite_config)
        suites.append(suite)
    return suites
Пример #15
0
def _PaddingHandler(option, dummy_opt, value, parser):
    """Validates the parameter to the reorder-padding parameter."""
    if value > _MAX_PADDING or value % _SAFEST_ALIGNMENT != 0:
        raise optparse.OptionValueError('Invalid padding value')
    setattr(parser.values, option.dest, value)
Пример #16
0
def _update_config_vars(values):  # pylint: disable=too-many-statements
    """Update the variables of the config module."""

    config = _config.DEFAULTS.copy()

    # Override `config` with values from command line arguments.
    cmdline_vars = vars(values)
    for cmdline_key in cmdline_vars:
        if cmdline_key not in _config.DEFAULTS:
            # Ignore options that don't map to values in config.py
            continue
        if cmdline_vars[cmdline_key] is not None:
            config[cmdline_key] = cmdline_vars[cmdline_key]

    _config.ARCHIVE_FILE = config.pop("archive_file")
    _config.ARCHIVE_LIMIT_MB = config.pop("archive_limit_mb")
    _config.ARCHIVE_LIMIT_TESTS = config.pop("archive_limit_tests")
    _config.BASE_PORT = int(config.pop("base_port"))
    _config.BENCHRUN_DEVICE = config.pop("benchrun_device")
    _config.BENCHRUN_EMBEDDED_ROOT = config.pop("benchrun_embedded_root")
    _config.BUILDLOGGER_URL = config.pop("buildlogger_url")
    _config.DBPATH_PREFIX = _expand_user(config.pop("dbpath_prefix"))
    _config.DBTEST_EXECUTABLE = _expand_user(config.pop("dbtest_executable"))
    _config.DRY_RUN = config.pop("dry_run")
    # EXCLUDE_WITH_ANY_TAGS will always contain the implicitly defined EXCLUDED_TAG.
    _config.EXCLUDE_WITH_ANY_TAGS = [_config.EXCLUDED_TAG]
    _config.EXCLUDE_WITH_ANY_TAGS.extend(
        utils.default_if_none(_tags_from_list(config.pop("exclude_with_any_tags")), []))
    _config.FAIL_FAST = not config.pop("continue_on_failure")
    _config.INCLUDE_WITH_ANY_TAGS = _tags_from_list(config.pop("include_with_any_tags"))
    _config.GENNY_EXECUTABLE = _expand_user(config.pop("genny_executable"))
    _config.JOBS = config.pop("jobs")
    _config.MAJORITY_READ_CONCERN = config.pop("majority_read_concern") == "on"
    _config.MONGO_EXECUTABLE = _expand_user(config.pop("mongo_executable"))
    _config.MONGOD_EXECUTABLE = _expand_user(config.pop("mongod_executable"))
    _config.MONGOD_SET_PARAMETERS = config.pop("mongod_set_parameters")
    _config.MONGOEBENCH_EXECUTABLE = _expand_user(config.pop("mongoebench_executable"))
    _config.MONGOS_EXECUTABLE = _expand_user(config.pop("mongos_executable"))
    _config.MONGOS_SET_PARAMETERS = config.pop("mongos_set_parameters")
    _config.NO_JOURNAL = config.pop("no_journal")
    _config.NUM_CLIENTS_PER_FIXTURE = config.pop("num_clients_per_fixture")
    _config.PERF_REPORT_FILE = config.pop("perf_report_file")
    _config.RANDOM_SEED = config.pop("seed")
    _config.REPEAT_SUITES = config.pop("repeat_suites")
    _config.REPEAT_TESTS = config.pop("repeat_tests")
    _config.REPEAT_TESTS_MAX = config.pop("repeat_tests_max")
    _config.REPEAT_TESTS_MIN = config.pop("repeat_tests_min")
    _config.REPEAT_TESTS_SECS = config.pop("repeat_tests_secs")
    _config.REPORT_FAILURE_STATUS = config.pop("report_failure_status")
    _config.REPORT_FILE = config.pop("report_file")
    _config.SERVICE_EXECUTOR = config.pop("service_executor")
    _config.SHELL_READ_MODE = config.pop("shell_read_mode")
    _config.SHELL_WRITE_MODE = config.pop("shell_write_mode")
    _config.SPAWN_USING = config.pop("spawn_using")
    _config.STAGGER_JOBS = config.pop("stagger_jobs") == "on"
    _config.STORAGE_ENGINE = config.pop("storage_engine")
    _config.STORAGE_ENGINE_CACHE_SIZE = config.pop("storage_engine_cache_size_gb")
    _config.TAG_FILE = config.pop("tag_file")
    _config.TRANSPORT_LAYER = config.pop("transport_layer")

    # Evergreen options.
    _config.EVERGREEN_BUILD_ID = config.pop("build_id")
    _config.EVERGREEN_DISTRO_ID = config.pop("distro_id")
    _config.EVERGREEN_EXECUTION = config.pop("execution_number")
    _config.EVERGREEN_PATCH_BUILD = config.pop("patch_build")
    _config.EVERGREEN_PROJECT_NAME = config.pop("project_name")
    _config.EVERGREEN_REVISION = config.pop("git_revision")
    _config.EVERGREEN_REVISION_ORDER_ID = config.pop("revision_order_id")
    _config.EVERGREEN_TASK_ID = config.pop("task_id")
    _config.EVERGREEN_TASK_NAME = config.pop("task_name")
    _config.EVERGREEN_VARIANT_NAME = config.pop("variant_name")
    _config.EVERGREEN_VERSION_ID = config.pop("version_id")

    # Wiredtiger options.
    _config.WT_COLL_CONFIG = config.pop("wt_coll_config")
    _config.WT_ENGINE_CONFIG = config.pop("wt_engine_config")
    _config.WT_INDEX_CONFIG = config.pop("wt_index_config")

    # Benchmark/Benchrun options.
    _config.BENCHMARK_FILTER = config.pop("benchmark_filter")
    _config.BENCHMARK_LIST_TESTS = config.pop("benchmark_list_tests")
    benchmark_min_time = config.pop("benchmark_min_time_secs")
    if benchmark_min_time is not None:
        _config.BENCHMARK_MIN_TIME = datetime.timedelta(seconds=benchmark_min_time)
    _config.BENCHMARK_REPETITIONS = config.pop("benchmark_repetitions")
    _config.BENCHRUN_REPORT_ROOT = config.pop("benchrun_report_root")

    shuffle = config.pop("shuffle")
    if shuffle == "auto":
        # If the user specified a value for --jobs > 1 (or -j > 1), then default to randomize
        # the order in which tests are executed. This is because with multiple threads the tests
        # wouldn't run in a deterministic order anyway.
        _config.SHUFFLE = _config.JOBS > 1
    else:
        _config.SHUFFLE = shuffle == "on"

    conn_string = config.pop("shell_conn_string")
    port = config.pop("shell_port")

    if port is not None:
        conn_string = "mongodb://localhost:" + port

    if conn_string is not None:
        # The --shellConnString command line option must be a MongoDB connection URI, which means it
        # must specify the mongodb:// or mongodb+srv:// URI scheme. pymongo.uri_parser.parse_uri()
        # raises an exception if the connection string specified isn't considered a valid MongoDB
        # connection URI.
        pymongo.uri_parser.parse_uri(conn_string)
        _config.SHELL_CONN_STRING = conn_string

    if config:
        raise optparse.OptionValueError("Unknown option(s): %s" % (config.keys()))
Пример #17
0
 def check_includepath(option, opt_str, value, parser):
     if not value or not os.path.isdir(os.path.abspath(value)):
         raise optparse.OptionValueError("Couldn't find %s include path." %
                                         value)
     l = getattr(parser.values, "%s" % option.dest)
     l.append(value)
Пример #18
0
 def set_time_sep(sep, opt):
     if sep == '-':
         raise optparse.OptionValueError(
             "Dash ('-') not valid for time-separator.")
     globals.time_separator = sep
     old_fn_deprecation(opt)
Пример #19
0
 def set_log_fd(fd):
     if fd < 1:
         raise optparse.OptionValueError(
             "log-fd must be greater than zero.")
     log.add_fd(fd)
Пример #20
0
def check_time(option, opt, value):
    try:
        return dup_time.genstrtotime(value)
    except dup_time.TimeException, e:
        raise optparse.OptionValueError(str(e))
Пример #21
0
def exclude_callback(option, opt, value, parser):
    if EXCLUDE_RE.match(value) is None:
        raise optparse.OptionValueError("%s argument has invalid value" % (opt,))
    parser.values.exclude = TAG_RE.findall(value)
Пример #22
0
def check_json(option, opt, value):
    # We return the parsed JSON here; see bug 610816 for background on why.
    try:
        return json.loads(value)
    except ValueError:
        raise optparse.OptionValueError("Option %s must be JSON." % opt)
Пример #23
0
        if len(harness_options['allTestModules']) == 0:
            sys.exit(0)

    from cuddlefish.rdf import gen_manifest, RDFUpdate

    manifest_rdf = gen_manifest(template_root_dir=app_extension_dir,
                                target_cfg=target_cfg,
                                jid=jid,
                                update_url=options.update_url,
                                bootstrap=True,
                                enable_mobile=options.enable_mobile)

    if command == "xpi" and options.update_link:
        if not options.update_link.startswith("https"):
            raise optparse.OptionValueError(
                "--update-link must start with 'https': %s" %
                options.update_link)
        rdf_name = UPDATE_RDF_FILENAME % target_cfg.name
        print >> stdout, "Exporting update description to %s." % rdf_name
        update = RDFUpdate()
        update.add(manifest_rdf, options.update_link)
        open(rdf_name, "w").write(str(update))

    # ask the manifest what files were used, so we can construct an XPI
    # without the rest. This will include the loader (and everything it
    # uses) because of the "loader_modules" starting points we passed to
    # build_manifest earlier
    used_files = None
    if command == "xpi":
        used_files = set(manifest.get_used_files(options.bundle_sdk))
Пример #24
0
def update_config_vars(values):
    options = _get_options_config(values.options_file)

    config = _config.DEFAULTS.copy()
    config.update(options)

    values = vars(values)
    for dest in values:
        if dest not in DEST_TO_CONFIG:
            continue
        config_var = DEST_TO_CONFIG[dest]
        if values[dest] is not None:
            config[config_var] = values[dest]

    _config.BASE_PORT = int(config.pop("basePort"))
    _config.BUILDLOGGER_URL = config.pop("buildloggerUrl")
    _config.DBPATH_PREFIX = _expand_user(config.pop("dbpathPrefix"))
    _config.DBTEST_EXECUTABLE = _expand_user(config.pop("dbtest"))
    _config.DRY_RUN = config.pop("dryRun")
    _config.EXCLUDE_WITH_ANY_TAGS = config.pop("excludeWithAnyTags")
    _config.FAIL_FAST = not config.pop("continueOnFailure")
    _config.INCLUDE_WITH_ANY_TAGS = config.pop("includeWithAnyTags")
    _config.JOBS = config.pop("jobs")
    _config.MONGO_EXECUTABLE = _expand_user(config.pop("mongo"))
    _config.MONGOD_EXECUTABLE = _expand_user(config.pop("mongod"))
    _config.MONGOD_SET_PARAMETERS = config.pop("mongodSetParameters")
    _config.MONGOS_EXECUTABLE = _expand_user(config.pop("mongos"))
    _config.MONGOS_SET_PARAMETERS = config.pop("mongosSetParameters")
    _config.NO_JOURNAL = config.pop("nojournal")
    _config.NO_PREALLOC_JOURNAL = config.pop("preallocJournal") == "off"
    _config.NUM_CLIENTS_PER_FIXTURE = config.pop("numClientsPerFixture")
    _config.RANDOM_SEED = config.pop("seed")
    _config.REPEAT = config.pop("repeat")
    _config.REPORT_FAILURE_STATUS = config.pop("reportFailureStatus")
    _config.REPORT_FILE = config.pop("reportFile")
    _config.SERVICE_EXECUTOR = config.pop("serviceExecutor")
    _config.SHELL_READ_MODE = config.pop("shellReadMode")
    _config.SHELL_WRITE_MODE = config.pop("shellWriteMode")
    _config.STAGGER_JOBS = config.pop("staggerJobs") == "on"
    _config.STORAGE_ENGINE = config.pop("storageEngine")
    _config.STORAGE_ENGINE_CACHE_SIZE = config.pop("storageEngineCacheSizeGB")
    _config.TAG_FILE = config.pop("tagFile")
    _config.TASK_ID = config.pop("taskId")
    _config.TRANSPORT_LAYER = config.pop("transportLayer")
    _config.WT_COLL_CONFIG = config.pop("wiredTigerCollectionConfigString")
    _config.WT_ENGINE_CONFIG = config.pop("wiredTigerEngineConfigString")
    _config.WT_INDEX_CONFIG = config.pop("wiredTigerIndexConfigString")

    shuffle = config.pop("shuffle")
    if shuffle == "auto":
        # If the user specified a value for --jobs > 1 (or -j > 1), then default to randomize
        # the order in which tests are executed. This is because with multiple threads the tests
        # wouldn't run in a deterministic order anyway.
        _config.SHUFFLE = _config.JOBS > 1
    else:
        _config.SHUFFLE = shuffle == "on"

    conn_string = config.pop("shellConnString")
    port = config.pop("shellPort")

    if port is not None:
        conn_string = "mongodb://localhost:" + port

    if conn_string is not None:
        _config.SHELL_CONN_STRING = conn_string

    if config:
        raise optparse.OptionValueError("Unknown option(s): %s" %
                                        (config.keys()))
Пример #25
0
def _non_empty_string_validator(opt, _, value):
    if not len(value):
        msg = "indent string can't be empty."
        raise optparse.OptionValueError(msg)
    return utils._unquote(value)
Пример #26
0
def _choice_validator(choices, name, value):
    if value not in choices:
        msg = "option %s: invalid value: %r, should be in %s"
        raise optparse.OptionValueError(msg % (name, value, choices))
    return value
Пример #27
0
 def store_abspath_dir(option, opt_str, value, parser):
     if not os.path.isdir(value):
         raise optparse.OptionValueError("'%s' is not a directory" % value)
     setattr(parser.values, option.dest, os.path.abspath(value))
    virtManager.guidiff.is_gui(True)

    # Now we've got basic environment up & running we can fork
    if not options.nofork and not options.debug:
        drop_tty()
        drop_stdio()

        # Ignore SIGHUP, otherwise a serial console closing drops the whole app
        signal.signal(signal.SIGHUP, signal.SIG_IGN)

    from virtManager.engine import vmmEngine

    gtk.window_set_default_icon_name(appname)

    if options.show and options.uri == None:
        raise optparse.OptionValueError("can't use --show-* options "
                                        "without --connect")

    engine = vmmEngine()

    if not options.nodbus:
        try:
            managerObj = dbus_config(engine)
            if managerObj:
                # yes, we exit completely now - remote service is in charge
                logging.debug("Connected to already running instance.")
                show_remote(managerObj, options.show, options.uri,
                            options.uuid)
                return
        except:
            # Something went wrong doing dbus setup, just ignore & carry on
            logging.exception("Could not get connection to session bus, "
Пример #29
0
def check_directory(option, opt_str, value, parser):
    if not os.path.exists(value):
        raise optparse.OptionValueError("directory %r does not exist" % value)
    setattr(parser.values, option.dest, value)
Пример #30
0
 def checkExistingFile(option, opt_str, value):
     if not os.path.isfile(value):
         raise optparse.OptionValueError(
             '%s value was not an existing file: %s' % (opt_str, value))
     return os.path.realpath(value)