Skip to content
Snippets Groups Projects
Commit b23651fb authored by Riccardo Sellari's avatar Riccardo Sellari
Browse files

working version (hopefully)

parent aba8fc6b
No related branches found
No related tags found
No related merge requests found
...@@ -11,25 +11,29 @@ import json ...@@ -11,25 +11,29 @@ import json
def jsonData2Influx(fileData,clientMemcached): def jsonData2Influx(fileData,clientMemcached):
jsonData = clientMemcached.get(fileData['keybind']) jsonData = clientMemcached.get(fileData['keybind'])
fileData['memcached'] = json.loads(jsonData) fileData['memcached'] = json.loads(jsonData)
payload = [] for field in fileData["memcached"]:
payload.append({ payload = []
"measurement": "dafneStat", payload.append({
"tags": { "measurement": "dafneStat",
"key": fileData["keybind"] "tags": {
}, "key": fileData["keybind"]
"fields": { },
"data": json.dumps(fileData["memcached"]) "fields": {
} field:fileData["memcached"][field]
}
}) })
return payload return payload
def findTheKey(configFile,path): def findTheKey(configFile,path):
data = {} data = {}
#find all the line with usefull data, except for keybind
pattern = r'^"(.+)":(.+,(( ←)|[^a-zA-Z ]))' pattern = r'^"(.+)":(.+,(( ←)|[^a-zA-Z ]))'
for line in configFile: for line in configFile:
match = re.search(pattern,line) match = re.search(pattern,line)
#knowing that the keybind is always the last value, the return is set right after it
if(match): if(match):
match = re.search(pattern,line) #match = re.search(pattern,line)
parameter = re.sub(r',|"|( ←)',"",match.group(2)) parameter = re.sub(r',|"|( ←)',"",match.group(2))
data[match.group(1)] = parameter data[match.group(1)] = parameter
elif(line.find('keybind') != -1): elif(line.find('keybind') != -1):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment