From 806ff8455c094b7da7edffe5351c8073062a7a15 Mon Sep 17 00:00:00 2001 From: Rob Frye Date: Mon, 23 Nov 2020 15:59:50 -0700 Subject: [PATCH] Issue 42: StatViewAssistant fails with regex matching multiple views; GetFileList fails when given a remote_directory --- .../assistants/statistics/statviewassistant.py | 14 +++++++++++--- ixnetwork_restpy/testplatform/sessions/sessions.py | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ixnetwork_restpy/assistants/statistics/statviewassistant.py b/ixnetwork_restpy/assistants/statistics/statviewassistant.py index 41089fceb..59ce3d62f 100644 --- a/ixnetwork_restpy/assistants/statistics/statviewassistant.py +++ b/ixnetwork_restpy/assistants/statistics/statviewassistant.py @@ -87,17 +87,25 @@ def _take_csv_snapshot(self): @property def _is_view_ready(self): start = time.time() + # Find the right view(s) while self._View is None: view = self._Statistics.View.find(Caption='^%s$' % self._ViewName) - if (len(view)) == 1: + if (len(view)) >= 1: self._View = view break if time.time() - start > self._Timeout: raise NotFoundError('After %s seconds the %s view does not exist.' % (self._Timeout, self._ViewName)) time.sleep(2) + # Wait until the/a view has data or time runs out + # For multiple matching views, return successfully if any has data while True: - if self._View.Data.IsReady is True: - break + if len(self._View) == 1: + if self._View.Data.IsReady is True: + return + else: + for v in self._View: + if v.Data.IsReady is True: + return if time.time() - start > self._Timeout: raise NotFoundError('After %s seconds the %s view has no data available.' % (self._Timeout, self._View.Caption)) time.sleep(2) diff --git a/ixnetwork_restpy/testplatform/sessions/sessions.py b/ixnetwork_restpy/testplatform/sessions/sessions.py index c7a13f5af..74422e1b8 100644 --- a/ixnetwork_restpy/testplatform/sessions/sessions.py +++ b/ixnetwork_restpy/testplatform/sessions/sessions.py @@ -322,7 +322,7 @@ def GetFileList(self, remote_directory=None): """ href = '%s/ixnetwork/files' % self.href if remote_directory is not None: - href = '%s?absolute=remote_directory' + href = '%s?absolute=remote_directory' % (href, remote_directory) return self._connection._read(href) def DownloadFile(self, remote_filename, local_filename = None): @@ -357,4 +357,4 @@ def UploadFile(self, local_filename, remote_filename=None): if self._parent.Platform == 'linux' and remote_filename is not None: remote_filename = remote_filename.replace('\\', '/') return self._connection._put_file('%s/ixnetwork' % self.href, - local_filename=local_filename, remote_filename=remote_filename) \ No newline at end of file + local_filename=local_filename, remote_filename=remote_filename)