mirror of https://git.48k.eu/ogclient
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.more_events
parent
bb9ec5d7a5
commit
8e81b8091e
|
@ -60,42 +60,41 @@ class restRequest:
|
||||||
print ("Error: Json message incomplete")
|
print ("Error: Json message incomplete")
|
||||||
return
|
return
|
||||||
|
|
||||||
if "run" in body:
|
if "run" in json_param:
|
||||||
self.run = json_param["run"]
|
self.run = json_param["run"]
|
||||||
try:
|
try:
|
||||||
self.echo = json_param["echo"]
|
self.echo = json_param["echo"]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if "disk" in body:
|
if "disk" in json_param:
|
||||||
self.disk = json_param["disk"]
|
self.disk = json_param["disk"]
|
||||||
|
|
||||||
if "partition" in body:
|
if "partition" in json_param:
|
||||||
if not "partition_setup" in body:
|
self.partition = json_param["partition"]
|
||||||
self.partition = json_param["partition"]
|
|
||||||
|
|
||||||
if "cache" in body:
|
if "cache" in json_param:
|
||||||
self.cache = json_param["cache"]
|
self.cache = json_param["cache"]
|
||||||
|
|
||||||
if "cache_size" in body:
|
if "cache_size" in json_param:
|
||||||
self.cache_size = json_param["cache_size"]
|
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"]
|
self.partition_setup = json_param["partition_setup"]
|
||||||
|
|
||||||
if "name" in body:
|
if "name" in json_param:
|
||||||
self.name = json_param["name"]
|
self.name = json_param["name"]
|
||||||
|
|
||||||
if "repository" in body:
|
if "repository" in json_param:
|
||||||
self.repo = json_param["repository"]
|
self.repo = json_param["repository"]
|
||||||
|
|
||||||
if "type" in body:
|
if "type" in json_param:
|
||||||
self.type = json_param["type"]
|
self.type = json_param["type"]
|
||||||
|
|
||||||
if "profile" in body:
|
if "profile" in json_param:
|
||||||
self.profile = json_param["profile"]
|
self.profile = json_param["profile"]
|
||||||
|
|
||||||
if "id" in body:
|
if "id" in json_param:
|
||||||
self.id = json_param["id"]
|
self.id = json_param["id"]
|
||||||
|
|
||||||
if "code" in json_param:
|
if "code" in json_param:
|
||||||
|
|
Loading…
Reference in New Issue