From 88e744d4bcb6525ce61199fd48144fabc3fa8a76 Mon Sep 17 00:00:00 2001 From: Ruslan Portnoy Date: Thu, 23 Mar 2017 13:38:21 +0200 Subject: [PATCH] added progressbar --- py/rackattack/ssh/connection.py | 11 +++++++---- py/rackattack/tcp/allocation.py | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/py/rackattack/ssh/connection.py b/py/rackattack/ssh/connection.py index 211c147..11cc54a 100644 --- a/py/rackattack/ssh/connection.py +++ b/py/rackattack/ssh/connection.py @@ -7,6 +7,7 @@ from rackattack.ssh import run from rackattack.ssh import dirftp from rackattack.ssh import tunnel +from strato.common.log.progress_bar import progressbar_context def discardParamikoLogs(): @@ -75,10 +76,12 @@ def connect(self): def waitForTCPServer(self, timeout=60, interval=0.1): before = time.time() - while time.time() - before < timeout: - if self._rawTCPConnect((self._hostname, self._port)): - return - time.sleep(interval) + with progressbar_context("waiting for connection to {}:{}".format(self._hostname, self._port), maxval=timeout, leave=True) as pbar: + while time.time() - before < timeout: + if self._rawTCPConnect((self._hostname, self._port)): + return + time.sleep(interval) + pbar.update(int(time.time() - before)) raise Exception("SSH TCP Server '%(hostname)s:%(port)s' did not respond within timeout" % dict( hostname=self._hostname, port=self._port)) diff --git a/py/rackattack/tcp/allocation.py b/py/rackattack/tcp/allocation.py index 3966c56..4f17dde 100644 --- a/py/rackattack/tcp/allocation.py +++ b/py/rackattack/tcp/allocation.py @@ -136,7 +136,7 @@ def _allocationEventBroadcasted(self, event): if eventType == "changedState": self._waitEvent.set() elif eventType == "providerMessage": - logging.info("Rackattack provider says: %(message)s", dict(message=event['message'])) + logging.debug("Rackattack provider says: %(message)s", dict(message=event['message'])) elif eventType == "withdrawn": self._handleWithdrawl(event["message"]) @@ -148,12 +148,12 @@ def _inauguratorEventBroadcasted(self, event): msg = "Inaugurator '%(id)s' %(state)s percent: %(percent)s" % dict( id=event['id'], percent=percent, state=state) if state == 'fetching': - logging.info(msg) + logging.debug(msg) self._progressPercent[event['id']] = percent elif state == 'digesting': logging.debug(msg) else: - logging.info("Inaugurator '%(id)s' status %(status)s", event) + logging.debug("Inaugurator '%(id)s' status %(status)s", event) if self._progressCallback is not None: self._progressCallback(overallPercent=self._overallPercent(), event=event)