diff options
-rwxr-xr-x | scripts/irbe-cli.py | 14 | ||||
-rw-r--r-- | scripts/rpki/config.py | 14 |
2 files changed, 12 insertions, 16 deletions
diff --git a/scripts/irbe-cli.py b/scripts/irbe-cli.py index e2ebed6b..0d05f72e 100755 --- a/scripts/irbe-cli.py +++ b/scripts/irbe-cli.py @@ -6,8 +6,8 @@ This only handles the control channel. The query back-channel will be a separate program. """ -import glob, getopt, sys, lxml.etree, POW.pkix, xml.sax, lxml.sax, ConfigParser -import rpki.left_right, rpki.relaxng, rpki.cms, rpki.https, rpki.x509 +import glob, getopt, sys, lxml.etree, POW.pkix, xml.sax, lxml.sax +import rpki.left_right, rpki.relaxng, rpki.cms, rpki.https, rpki.x509, rpki.config # Kludge around current test setup all being PEM rather than DER format convert_from_pem = True @@ -131,8 +131,7 @@ def main(): responses. """ - cfg = ConfigParser.RawConfigParser() - cfg.read("irbe.conf") + cfg = rpki.config.parser("irbe.conf") section = "irbe-cli" rng = rpki.relaxng.RelaxNG(cfg.get(section, "rng-schema")) @@ -168,12 +167,7 @@ def main(): print q_xml - # This wants some kind of config file iterator, handle inline for now - - q_cms = rpki.cms.encode(q_xml, cfg.get(section, "cms-key"), - [cfg.get(section, "cms-cert.%d" % i) - for i in range(100) - if cfg.has_option(section, "cms-cert.%d" % i)]) + q_cms = rpki.cms.encode(q_xml, cfg.get(section, "cms-key"), cfg.multiget(section, "cms-cert")) r_cms = rpki.https.client(certInfo=httpsCerts, msg=q_cms, url="/left-right") diff --git a/scripts/rpki/config.py b/scripts/rpki/config.py index 8e15201b..6d5834d3 100644 --- a/scripts/rpki/config.py +++ b/scripts/rpki/config.py @@ -10,7 +10,7 @@ import ConfigParser class parser(ConfigParser.RawConfigParser): def __init__(self, file=None): - super(parser, self).__init__() + ConfigParser.RawConfigParser.__init__(self) if file: self.read(file) @@ -20,16 +20,18 @@ class parser(ConfigParser.RawConfigParser): Returns a list of values matching the specified option name. """ matches = [] - for key, value in self.items(): - name, index = key.rsplit(".", 1) - if name == option and index.isdigit(): - matches.append(tuple(int(index), value)) + if self.has_option(section, option): + matches.append((0, self.get(section, option))) + for key, value in self.items(section): + s = key.rsplit(".", 1) + if len(s) == 2 and s[0] == option and s[1].isdigit(): + matches.append((int(s[1]), value)) matches.sort() return [match[1] for match in matches] def get(self, section, option, default=None): """Get an option, perhaps with a default value.""" if default is None or self.has_option(section, option): - return super(parser, self).get(section, option) + return ConfigParser.RawConfigParser.get(self, section, option) else: return default |