summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sanchez Parra <jsanchez@soleta.eu>2020-02-26 10:42:18 +0100
committerAlvaro Neira Ayuso <aneira@soleta.eu>2020-02-26 17:55:03 +0100
commit8e81b8091ebabd7b98e443432d3a7f5044ed2538 (patch)
tree748e512ae42e654879ef18771098d9271ad138ae
parentbb9ec5d7a55bff675e0aa0afa150171d098b3968 (diff)
Search the key in the parsed json
Testing the ogClient I found that if a value of the json match a key the ogClient has an exception. For example: body = "... shell/run {"run": "fdisk -l"} ..." CURRENT Enters in if "disk" in body:... if "run" in body:... EXPECTED Enters in if "run" in body:... This commit changes the behaviour to search for the keys in the dictionary returned by json.loads() instead of searching in the raw string. This way the ogClient looks for the keys without searching in the values.
-rw-r--r--src/restRequest.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/restRequest.py b/src/restRequest.py
index 2354143..6ed00c4 100644
--- a/src/restRequest.py
+++ b/src/restRequest.py
@@ -60,42 +60,41 @@ class restRequest:
print ("Error: Json message incomplete")
return
- if "run" in body:
+ if "run" in json_param:
self.run = json_param["run"]
try:
self.echo = json_param["echo"]
except:
pass
- if "disk" in body:
+ if "disk" in json_param:
self.disk = json_param["disk"]
- if "partition" in body:
- if not "partition_setup" in body:
- self.partition = json_param["partition"]
+ if "partition" in json_param:
+ self.partition = json_param["partition"]
- if "cache" in body:
+ if "cache" in json_param:
self.cache = json_param["cache"]
- if "cache_size" in body:
+ if "cache_size" in json_param:
self.cache_size = json_param["cache_size"]
- if "partition_setup" in body:
+ if "partition_setup" in json_param:
self.partition_setup = json_param["partition_setup"]
- if "name" in body:
+ if "name" in json_param:
self.name = json_param["name"]
- if "repository" in body:
+ if "repository" in json_param:
self.repo = json_param["repository"]
- if "type" in body:
+ if "type" in json_param:
self.type = json_param["type"]
- if "profile" in body:
+ if "profile" in json_param:
self.profile = json_param["profile"]
- if "id" in body:
+ if "id" in json_param:
self.id = json_param["id"]
if "code" in json_param: