def dbadd(db, config, args): """ Add a rule into the sequencer table. """ usage = "%prog [options] dbadd ruleset name types " + \ "filter action depsfinder dependson comments help" doc = """Add a rule into the sequencer table. Multiple 'types' can be specified using the comma separator ','. Multiple dependencies can be specified using the comma separator ','. Both action and depsfinder should be a valid shell command line. Quote must be used to prevent mis-interpretation by the running shell. Special 'NONE' and 'NULL' strings are interpreted as the special NULL db value. Note that errors might be raised if DB constraints are not fulfilled. The DB specific error message should tell what the problem is. If unclear, have a look to the DB constraints.""" cmd = os.path.basename(sys.argv[0]) progname=to_unicode(cmd).encode('ascii', 'replace') parser = optparse.OptionParser(usage, description=doc, prog=progname) (options, add_args) = parser.parse_args(args) if len(add_args) != 9: parser.error(DBADD_ACTION_NAME + \ ": expected %d arguments, given %d" % \ (9, len(add_args))) add_args = [None if x == "NONE" or x == "NULL" else x for x in add_args] try: db.add_rule(create_rule_from_strings_array(add_args)) except DuplicateRuleError as dre: _LOGGER.error(DBADD_ACTION_NAME + \ ": Rule %s.%s does already exists.", dre.ruleset, dre.name)
def dbadd(db, config, args): """ Add a rule into the sequencer table. """ usage = "%prog [options] dbadd ruleset name types " + \ "filter action depsfinder dependson comments" doc = """Add a rule into the sequencer table. Multiple 'types' can be specified using the comma separator ','. Multiple dependencies can be specified using the comma separator ','. Both action and depsfinder should be a valid shell command line. Quote must be used to prevent mis-interpretation by the running shell. Special 'NONE' and 'NULL' strings are interpreted as the special NULL db value. Note that errors might be raised if DB constraints are not fulfilled. The DB specific error message should tell what the problem is. If unclear, have a look to the DB constraints.""" parser = optparse.OptionParser(usage, description=doc) (options, add_args) = parser.parse_args(args) if len(add_args) != 8: parser.error(DBADD_ACTION_NAME + \ ": expected %d arguments, given %d" %\ (8, len(add_args))) add_args = [None if x == "NONE" or x == "NULL" else x for x in add_args] db.add_rule(create_rule_from_strings_array(add_args))