From 7a3131ef03d2a4b30cce63cb6f671a4e35da836d Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Fri, 11 Sep 2009 16:06:21 +0000 Subject: [PATCH] Bug fixes. --- sfatables/commands/Add.py | 12 ++++++------ sfatables/sfatables | 12 +++++------- sfatables/xmlextension.py | 2 -- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sfatables/commands/Add.py b/sfatables/commands/Add.py index a8a63dc6..36b22c3c 100644 --- a/sfatables/commands/Add.py +++ b/sfatables/commands/Add.py @@ -13,7 +13,7 @@ class Add(Command): return def getnextfilename(self,type,chain): - dir = sfatables_config + chain; + dir = sfatables_config + "/"+chain; last_rule_number = 1 for (root, dirs, files) in os.walk(dir): @@ -26,7 +26,7 @@ class Add(Command): return "sfatables-%d-%s"%(last_rule_number+1,type) - def call_gen(self, dir, options): + def call_gen(self, chain, type, dir, options): filename = dir + "/"+options.name+".xml" xmldoc = libxml2.parseFile(filename) @@ -47,8 +47,7 @@ class Add(Command): valueNode.addContent(option_value) context[0].addChild(valueNode) - chain = command_options.args[0] - filename = self.getnextfilename('match',chain) + filename = self.getnextfilename(type,chain) file_path = sfatables_config + '/' + chain + '/' + filename xmldoc.saveFile(file_path) p.xpathFreeContext() @@ -57,8 +56,9 @@ class Add(Command): return True def call(self, command_options, match_options, target_options): - ret = self.call_gen(match_dir, match_options) + chain = command_options.args[0] + ret = self.call_gen(chain, 'match',match_dir, match_options) if (ret): - ret = self.call_gen(target_dir, target_options) + ret = self.call_gen(chain, 'target',target_dir, target_options) return ret diff --git a/sfatables/sfatables b/sfatables/sfatables index 2fd244db..379b749c 100755 --- a/sfatables/sfatables +++ b/sfatables/sfatables @@ -111,17 +111,17 @@ def main(): target_dict = load_xml_extensions("sfatables.targets",target_dir,targets.all) target_parser = create_parser_xml_ext(target_dict) targets_str = ",".join(target_dict.keys()) - target_parser.add_option('-j','--jump',dest='target_name',help='Target name (one of %s)'%targets, metavar = 'TARGET') + target_parser.add_option('-j','--jump',dest='name',help='Target name (one of %s)'%targets, metavar = 'TARGET') (target_options, args) = target_parser.parse_args(pargs[2]) try: - target_name = target_options.target_name + name = target_options.name except Exception: print "Must specify target name with -m" - if (target_dict.has_key(target_name)): - setattr(target_options, 'arguments', target_dict[target_name].arguments) + if (target_dict.has_key(name)): + setattr(target_options, 'arguments', target_dict[name].arguments) else: - raise Exception('Target %s not found'%target_name) + raise Exception('Target %s not found'%name) else: target_options = None @@ -130,5 +130,3 @@ def main(): if __name__=='__main__': main() -if __name__=='__main__': - main() diff --git a/sfatables/xmlextension.py b/sfatables/xmlextension.py index 412419b0..1e27e762 100644 --- a/sfatables/xmlextension.py +++ b/sfatables/xmlextension.py @@ -15,8 +15,6 @@ class Xmlextension: def __init__(self, dir, component_name): filename = dir+"/"+component_name+".xml" - import pdb - pdb.set_trace() self.xmldoc = libxml2.parseFile(filename) # TODO: Check xmldoc against a schema -- 2.45.2