コード例 #1
0
ファイル: cli.py プロジェクト: af-bull/sequencer
def dbupdate(db, config, args):
    """
    Update a rule of the sequencer table.
    """
    usage = "%prog [options] dbupdate [--nodeps] " + \
        "ruleset_name rule_name" + \
        " <column1>=<value1> <column2>=<value2>..."
    doc = "Update each columns <column1>, <column2>, ... " + \
    "of the given rule ('ruleset', 'name') with values " + \
        "<value1>, <value2>, ... respectively in the sequencer table."
    parser = optparse.OptionParser(usage, description=doc)
    add_options_to(parser, ['--nodeps'], config)
    (options, update_args) = parser.parse_args(args)
    if len(update_args) < 3:
        parser.error(DBUPDATE_ACTION_NAME + \
                         ": expected a minimum of %d arguments, given %d" %\
                         (3, len(update_args)))
    ruleset = update_args[0]
    rulename = update_args[1]
    update_set = set()
    for record in update_args[2:]:
        (col, sep, val) = record.partition("=")
        val = None if val == 'NONE' or val == 'NULL' else val
        update_set.add((col, val))
    if not db.update_rule(ruleset, rulename,
                          update_set, options.nodeps):
        _LOGGER.error(DBUPDATE_ACTION_NAME + \
                               ": unable to update specified rule (%s, %s)" %\
                               (ruleset, rulename))
コード例 #2
0
ファイル: cli.py プロジェクト: pv-bull/sequencer
def dbremove(db, config, args):
    """
    Remove a rule or a ruleset from the sequencer table.
    """
    usage = "%prog [options] dbremove [--nodeps] " + \
        "ruleset_name [rule_name...]"
    doc = """Remove all (given) rules from the sequencer table."""
    cmd = os.path.basename(sys.argv[0])
    progname=to_unicode(cmd).encode('ascii', 'replace')
    parser = optparse.OptionParser(usage, description=doc, prog=progname)
    add_options_to(parser, ['--Enforce', '--nodeps'], config)
    (options, remove_args) = parser.parse_args(args)
    if len(remove_args) < 1:
        parser.error(DBREMOVE_ACTION_NAME + \
                         ": expected at least %d arguments, given %d" % \
                         (1, len(remove_args)))
    ruleset = remove_args[0]
    rules = remove_args[1:] if len(remove_args) > 1 else None
    if not options.enforce:
        prompt = "Confirm the removal of %s ruleset %s?" % \
            (("rules %s from" % \
                  ", ".join(rules)) if rules is not None else "whole", \
                 ruleset)
        if not confirm(prompt, False):
            _LOGGER.output("Canceled.")
            sys.exit(os.EX_OK)
    remaining = db.remove_rules(ruleset, rules, options.nodeps)
    if remaining is not None and len(remaining) != 0:
        _LOGGER.error(DBREMOVE_ACTION_NAME + \
                      ": unable to remove following rules %s "
                      "from ruleset %s"
                      ", ".join(remaining), ruleset)
コード例 #3
0
ファイル: cli.py プロジェクト: pv-bull/sequencer
def _parse(config, args):
    """
    Chaining Implementation
    """
    usage = "Usage: %prog [global_options] ['chain'] <ruleset> " + \
        "[action_options] components_list"
    chain_doc = CHAIN_DOC + \
        " That is: make the dependency graph for the given ruleset and" + \
        " components_list," + \
        " compute an instructions sequence and execute it." + \
        " Note that the action name 'chain' is optional." + \
        " Giving the ruleset name directly is a shortcut."

    parser = optparse.OptionParser(usage, description=chain_doc)
    parser.add_option("-F", "--Force",
                      metavar='RULE_LIST',
                      dest='force',
                      type='string',
                      help="Specify the comma-separated list of rules" + \
                          " for which" + \
                          " related action should be forced.")

    add_options_to(parser, ['--depgraphto', '--actionsgraphto', '--progress',
                            '--doexec', '--report', '--dostats',
                            '--fanout', '--algo', '--docache'],
                   config)
    (options, action_args) = parser.parse_args(args)
    if len(action_args) < 2:
        parser.error(CHAIN_ACTION_NAME + ": wrong number of arguments.")

    return (options, action_args)
コード例 #4
0
ファイル: cli.py プロジェクト: af-bull/sequencer
def _parse(config, ism_args):
    """
    ISM Action Specific CLI Parser
    """

    usage = "Usage: %prog [global_options] " + SEQMAKE_ACTION_NAME + " [action_options]"

    doc = (
        SEQMAKE_DOC
        + " The input can be the output of the 'depmake' action."
        + " The output can be used as an input of the 'seqexec' action."
    )

    opt_parser = optparse.OptionParser(usage, description=doc)
    add_options_to(opt_parser, ["--file", "--out", "--algo"], config)
    (ism_options, action_args) = opt_parser.parse_args(ism_args)
    if len(action_args) != 0:
        opt_parser.error(SEQMAKE_ACTION_NAME + ": wrong number of arguments.")

    return (ism_options, action_args)
コード例 #5
0
ファイル: cli.py プロジェクト: af-bull/sequencer
def dbdrop(db, config, args):
    """
    Drop the sequencer table.
    """
    usage = "%prog [options] dbdrop"
    doc = DBDROP_DOC
    parser = optparse.OptionParser(usage, description=doc)
    add_options_to(parser, ['--Enforce'], config)
    (options, dbdrop_args) = parser.parse_args(args)
    if len(dbdrop_args) != 0:
        parser.error(DBDROP_ACTION_NAME + \
                         ": expected %d arguments, given %d" %\
                         (0, len(dbdrop_args)))
    if not options.enforce:
        if not confirm("Confirm the full deletion of the sequencer table?",
                       False):
            _LOGGER.output("Canceled.")
            sys.exit(os.EX_OK)

    db.drop_table()
コード例 #6
0
ファイル: cli.py プロジェクト: af-bull/sequencer
def graphrules(db, config, args):
    """
    This action fetch the rules from the DB sequencer table and call
    the DGM stage for the computation of the related graph.
    This graph is then given to the user in the DOT format.
    """
    usage = "Usage: %prog [global_options] " + GRAPHRULES_ACTION_NAME + \
        " [action_options] ruleset"
    doc = GRAPHRULES_DOC + \
        " The graph is given in DOT format."
    parser = optparse.OptionParser(usage, description=doc)
    add_options_to(parser, ['--out'], config)
    (options, action_args) = parser.parse_args(args)
    if len(action_args) != 1:
        parser.error(GRAPHRULES_ACTION_NAME + ": ruleSet is missing.")

    req_ruleset = action_args[0]
    rules = db.get_rules_for(req_ruleset)
    ruleset = RuleSet(rules.values())
    write_graph_to(ruleset.get_rules_graph(), options.out)
コード例 #7
0
ファイル: cli.py プロジェクト: pv-bull/sequencer
def _parse_depmake_cmdline(config, args):
    """
    DGM Action Specific CLI Parser
    """

    usage = "Usage: %prog [global_options] " + DEPMAKE_ACTION_NAME + \
        " [action_options] ruleset components_list"
    doc = DEPMAKE_DOC + \
        " The output format is suitable for the 'seqmake' action."
    cmd = os.path.basename(sys.argv[0])
    progname=to_unicode(cmd).encode('ascii', 'replace')
    parser = optparse.OptionParser(usage, description=doc, prog=progname)
    parser.add_option('-F', '--Force',
                      metavar='RULE_LIST',
                      dest='force',
                      type='string',
                      help="Specify the force mode ('allowed'," + \
                          " 'always' or 'never')" + \
                          " that should be used for the execution of" + \
                          " each action related to the given comma" + \
                          " separated list of rule names. When prefixed" + \
                          " by " + NOT_FORCE_OP + ", " + \
                          " action execution will 'never' be" + \
                          " forced. Otherwise, it will 'always' be" + \
                          " forced. Action related to a rule that is " + \
                          " not specified in the list will see its" + \
                          " force mode set to 'allowed' meaning that" + \
                          " the decision is left to the Instruction " + \
                          " Sequence Executor (see '" + \
                          ise_cli.SEQEXEC_ACTION_NAME + "')")

    add_options_to(parser, ['--out', '--depgraphto', '--docache'], config)
    (options, action_args) = parser.parse_args(args)
    if len(action_args) < 2:
        parser.error(DEPMAKE_ACTION_NAME + \
                         ": ruleSet and/or components lists missing.")

    req_ruleset = action_args[0]
    lists = action_args[1:]
    components_lists = parse_components_lists(lists)
    return (options, req_ruleset, components_lists)
コード例 #8
0
def _parse(config, ism_args):
    """
    ISM Action Specific CLI Parser
    """

    usage = "Usage: %prog [global_options] " + SEQMAKE_ACTION_NAME + \
        " [action_options]"

    doc = SEQMAKE_DOC + \
        " The input can be the output of the 'depmake' action." + \
        " The output can be used as an input of the 'seqexec' action."
    cmd = path.basename(sys.argv[0])
    progname=to_unicode(cmd).encode('ascii', 'replace')
    opt_parser = optparse.OptionParser(usage, description=doc, prog=progname)
    add_options_to(opt_parser, ['--file', '--out', '--algo'], config)
    (ism_options, action_args) = opt_parser.parse_args(ism_args)
    if len(action_args) != 0:
        opt_parser.error(SEQMAKE_ACTION_NAME + \
                             ": wrong number of arguments.")

    return (ism_options, action_args)
コード例 #9
0
ファイル: cli.py プロジェクト: AdrienDebrie/sequencer
def _parse(basedir, config, args):
    """
    ISE Action Specific CLI Parser
    """

    usage = "Usage: %prog [global_options] " + SEQEXEC_ACTION_NAME + \
        " [action_options]"

    doc = SEQEXEC_DOC + \
        " The input can be the output of the 'seqmake' action."
    cmd = os.path.basename(sys.argv[0])
    progname = to_unicode(cmd).encode('ascii', 'replace')
    opt_parser = optparse.OptionParser(usage, description=doc, prog=progname)
    opt_parser.add_option("-F", "--Force",
                          dest="force",
                          action='store_true',
                          default=False,
                          # If you want to read the default from a
                          # config file, you need a way to override
                          # it. Therefore, 'store_true' above is not a
                          # good action.  You should provide either a
                          # --Force=no or a --no-Force option.

                          # default=config.getboolean(SEQEXEC_ACTION_NAME, \
                          #                           "Force"),
                          help="Do not stop the execution of an action when" + \
                              " one of its dependencies exits" + \
                              " with a WARNING error code.")
    add_options_to(opt_parser, ['--file', '--actionsgraphto', '--progress',
                            '--doexec', '--report', '--dostats', '--fanout'],
                   config)


    (ise_options, action_args) = opt_parser.parse_args(args)
    if len(action_args) != 0:
        opt_parser.error(SEQEXEC_ACTION_NAME + \
                             ": wrong number of arguments.")

    return (ise_options, action_args)
コード例 #10
0
ファイル: cli.py プロジェクト: pv-bull/sequencer
def dbupdate(db, config, args):
    """
    Update a rule of the sequencer table.
    """
    usage = "%prog [options] dbupdate [--nodeps] " + \
        "ruleset_name rule_name" + \
        " <column1>=<value1> <column2>=<value2>..."
    doc = "Update each columns <column1>, <column2>, ... " + \
    "of the given rule ('ruleset', 'name') with values " + \
        "<value1>, <value2>, ... respectively in the sequencer table."
    cmd = os.path.basename(sys.argv[0])
    progname=to_unicode(cmd).encode('ascii', 'replace')
    parser = optparse.OptionParser(usage, description=doc, prog=progname)
    add_options_to(parser, ['--nodeps'], config)
    (options, update_args) = parser.parse_args(args)
    if len(update_args) < 3:
        parser.error(DBUPDATE_ACTION_NAME + \
                         ": expected a minimum of %d arguments, given %d" % \
                         (3, len(update_args)))
    ruleset = update_args[0]
    rulename = update_args[1]
    update_set = set()
    for record in update_args[2:]:
        (col, sep, val) = record.partition("=")
        val = None if val == 'NONE' or val == 'NULL' else val
        update_set.add((col, val))
    try:
        if not db.update_rule(ruleset, rulename,
                              update_set, options.nodeps):
            _LOGGER.error(DBUPDATE_ACTION_NAME + \
                          ": unable to update specified rule (%s, %s)",
                          ruleset, rulename)
    except UnknownRuleSet as urs:
        _LOGGER.error(DBUPDATE_ACTION_NAME + str(urs))
        return 1
    except NoSuchRuleError as nsre:
        _LOGGER.error(DBUPDATE_ACTION_NAME + str(nsre))
        return 1