do not convert to json any more
This commit is contained in:
parent
6a5343f663
commit
baff78069c
|
@ -36,10 +36,4 @@ version: {version}"""
|
||||||
self.allow_insecure_https = config.get('allow_insecure_https', False)
|
self.allow_insecure_https = config.get('allow_insecure_https', False)
|
||||||
|
|
||||||
|
|
||||||
TO_JSON = {'session.server.get': ['content'],
|
|
||||||
'session.servermodel.get': ['content'],
|
|
||||||
'server.describe': ['configuration'],
|
|
||||||
'server.exec.describe': ['return']}
|
|
||||||
|
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
|
@ -5,7 +5,6 @@ from json import loads
|
||||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||||
from argparse import RawDescriptionHelpFormatter
|
from argparse import RawDescriptionHelpFormatter
|
||||||
|
|
||||||
from .config import TO_JSON
|
|
||||||
from .common import Common, send_data
|
from .common import Common, send_data
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,27 +28,12 @@ class Parser(Common):
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
def _to_json(res):
|
|
||||||
for key, value in res.items():
|
|
||||||
if key in TO_JSON[message]:
|
|
||||||
res[key] = loads(value)
|
|
||||||
|
|
||||||
# get current message
|
# get current message
|
||||||
message = self.remote_config.option('message').value.get()
|
message = self.remote_config.option('message').value.get()
|
||||||
payload = self.get_payload(message)
|
payload = self.get_payload(message)
|
||||||
# send message
|
# send message
|
||||||
result = send_data(message,
|
return send_data(message,
|
||||||
payload)
|
payload)
|
||||||
|
|
||||||
# convert some results (file) to json
|
|
||||||
if message in TO_JSON:
|
|
||||||
if isinstance(result, list):
|
|
||||||
for res in result:
|
|
||||||
_to_json(res)
|
|
||||||
else:
|
|
||||||
_to_json(result)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_payload(self,
|
def get_payload(self,
|
||||||
message: str):
|
message: str):
|
||||||
|
|
Loading…
Reference in New Issue