diff options
author | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2014-03-19 17:43:39 +0000 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2014-03-19 17:43:39 +0000 |
commit | bb5ebedc00420997c7f811f28a3cc0dee8627391 (patch) | |
tree | b2acc06a9d52e94256e3967b0972c149d06d4022 | |
parent | 5cf2bcb691ae618c41efc46fb806af5b4aacbbc3 (diff) |
changed lava cache handling
-rwxr-xr-x | prepare-config.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/prepare-config.py b/prepare-config.py index 78fdfe4..b4644a8 100755 --- a/prepare-config.py +++ b/prepare-config.py @@ -1,8 +1,7 @@ #!/usr/bin/env python -from ConfigParser import RawConfigParser -from optparse import OptionParser +import re +import sys from string import Template -from StringIO import StringIO TEMPLATE_PATH = "templates/" CONFIG_NAME = "config.py" @@ -12,13 +11,16 @@ ROOT = 'root' if __name__ == '__main__': lava_cache_file = open(LAVA_CACHE_PATH, 'r') - lava_cache = '[' + ROOT + ']\n' + lava_cache_file.read() - print lava_cache + lava_cache = lava_cache_file.read() lava_cache_file.close() - lava_cache_config = StringIO(lava_cache) - lava_cache_reader = RawConfigParser() - lava_cache_reader.readfp(lava_cache_config) - ipaddr = lava_cache_reader.get(ROOT, 'ipaddr') + lava_cache_regexp = re.compile("^(?P<device_id>[a-zA-Z0-9_\-]+):(?P<key>\w+)=(?P<value>.*)$") + print lava_cache + lava_cache_match = lava_cache_regexp.search(lava_cache) + ipaddr = None + if lava_cache_match: + ipaddr = lava_cache_match.group("value") + else: + sys.exit(1) config = open(CONFIG_PATH, "r") config_template = Template(config.read()) config.close() |