Skip to content

Commit

Permalink
fix: Progress bars should not be printed in silent mode (#412)
Browse files Browse the repository at this point in the history
* fix: Progress bars should not be printed in silent mode

* add default for silent

* add default for silent
  • Loading branch information
wayyoungboy authored Sep 3, 2024
1 parent ee1af55 commit 0849afd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/ssh_client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, context, node):
self.node = node
self.ssh_type = node.get("ssh_type") or "remote"
self.client = None
self.inner_config_manager = context.inner_config

def exec_cmd(self, cmd):
raise Exception("the client type is not support exec_cmd")
Expand All @@ -53,6 +54,8 @@ def get_ip(self):
return self.client.get_ip()

def progress_bar(self, transferred, to_be_transferred, suffix=''):
if self.inner_config_manager.get("obdiag", default={"logger": {"silent": False}}).get("logger").get("silent"):
return
bar_len = 20
filled_len = int(round(bar_len * transferred / float(to_be_transferred)))
percents = round(20.0 * transferred / float(to_be_transferred), 1)
Expand Down
2 changes: 2 additions & 0 deletions common/ssh_client/remote_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def download(self, remote_path, local_path):
self._sftp_client.close()

def progress_bar(self, transferred, to_be_transferred, suffix=''):
if self.inner_config_manager.get("obdiag", default={"logger": {"silent": False}}).get("logger").get("silent"):
return
bar_len = 20
filled_len = int(round(bar_len * transferred / float(to_be_transferred)))
percents = round(20.0 * transferred / float(to_be_transferred), 1)
Expand Down

0 comments on commit 0849afd

Please sign in to comment.