aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/VatExecutor.py
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2016-04-22 13:58:22 +0200
committerStefan Kobza <skobza@cisco.com>2016-04-22 14:51:07 +0000
commit87ec18ad91a63e7925005057ccbb7a7570347376 (patch)
tree85afaf264818d781c0fd4a70877e66ae81e8bc6a /resources/libraries/python/VatExecutor.py
parent6afd4834db96cab257352bf02449e9e526198f96 (diff)
VatExecutor update
Strip non-JSON data from VAT terminal output Add method for VAT command retval verification Change-Id: Ibe68020393cb1a700ad048dc78078f71064707b4 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'resources/libraries/python/VatExecutor.py')
-rw-r--r--resources/libraries/python/VatExecutor.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py
index 9851d93edd..fd1d8db232 100644
--- a/resources/libraries/python/VatExecutor.py
+++ b/resources/libraries/python/VatExecutor.py
@@ -183,6 +183,21 @@ class VatTerminal(object):
self.__VAT_PROMPT)
logger.debug("VAT output: {}".format(out))
if self.json:
+ obj_start = out.find('{')
+ obj_end = out.rfind('}')
+ array_start = out.find('[')
+ array_end = out.rfind(']')
+
+ if -1 == obj_start and -1 == array_start:
+ raise RuntimeError("No JSON data.")
+
+ if obj_start < array_start or -1 == array_start:
+ start = obj_start
+ end = obj_end + 1
+ else:
+ start = array_start
+ end = array_end + 1
+ out = out[start:end]
json_out = json.loads(out)
return json_out
else: