From 1eca1b07d02ffddf99450e21adeeacec48b22046 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 11 Aug 2021 14:43:33 +0300 Subject: [PATCH] Update tgn_tcl.py fix for IxeCard class ... rg_info_list = tcl_list_2_py_list(self.resourceGroupInfoList, within_tcl_str=True) --- trafficgenerator/tgn_tcl.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/trafficgenerator/tgn_tcl.py b/trafficgenerator/tgn_tcl.py index 9511a74..9dce170 100644 --- a/trafficgenerator/tgn_tcl.py +++ b/trafficgenerator/tgn_tcl.py @@ -58,23 +58,23 @@ def build_obj_ref_list(objects: List[TgnObject]) -> str: return " ".join([o.ref for o in objects]) -def tcl_list_2_py_list(tcl_list: str) -> list: - """Recursievely convert embedded Tcl list to embedded Python list using Tcl interpreter. +def tcl_list_2_py_list(tcl_list: str, within_tcl_str=False) -> list: + """ Recursievely convert embedded Tcl list to embedded Python list using Tcl interpreter. :param str tcl_list: string representing the Tcl list. """ if not tcl_list: return [] - + #return tcl_interp_g.eval('join ' + tcl_list + ' LiStSeP').split('LiStSeP') if tcl_list else [] try: return json.loads(tcl_list) - except json.decoder.JSONDecodeError: + except Exception as _: try: - python_list = tcl_interp_g.eval("join " + tcl_list + " LiStSeP").split("LiStSeP") - except TclError: - python_list = tcl_interp_g.eval("join " + tcl_str(tcl_list) + " LiStSeP").split("LiStSeP") - if len([i for i in python_list if "{" in i]) == 0: + python_list = tcl_interp_g.eval('join ' + tcl_list + ' LiStSeP').split('LiStSeP') + except Exception as _: + python_list = tcl_interp_g.eval('join ' + tcl_str(tcl_list) + ' LiStSeP').split('LiStSeP') + if len([i for i in python_list if '{' in i]) == 0 or within_tcl_str: return python_list return [tcl_list_2_py_list(e) for e in python_list]