X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fcollect%2Fserver%2Ftxt2dict.py;fp=web%2Fcollect%2Fserver%2Ftxt2dict.py;h=7a1a7d37bfb1141adbc313df34dd6867d8a7e492;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/collect/server/txt2dict.py b/web/collect/server/txt2dict.py new file mode 100644 index 0000000..7a1a7d3 --- /dev/null +++ b/web/collect/server/txt2dict.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import sys + +def file_to_dict(file): + convert = { + 'iptables_status' : "list", + 'rpm_versions' : "list", + 'running_slices' : "list", + } + f = open(file, 'r') + d = {} + for line in f: + l = line[:-1] + s = l.split() + key = s[0] + val = " ".join(s[2:]) + d[key] = val + if key in convert: + if convert[key] == "list": + d[key] = d[key].split() + if 'type' not in d: + d['type'] = "node-status-v0" + return d + +