Automated PaŃkage versions update for tags
Module repos.py
- ReposInfo(), walks mirror using HTTP and builds
all repos map available
- RepoManager(), using repos map builds package versions map
either for specific tags or for all of them
Fixes:
- Progress class clears line remainder on change
Utils:
- Download GZ file into memory
- TGZ file interface, CRU (no deletion)
Change-Id: Ifdb37aa4b68fb25f642b2089cf16cd242ed25a0b
Related-PROD: PROD-28199
diff --git a/cfg_checker/helpers/console_utils.py b/cfg_checker/helpers/console_utils.py
index 5c32506..d1db2a1 100644
--- a/cfg_checker/helpers/console_utils.py
+++ b/cfg_checker/helpers/console_utils.py
@@ -2,6 +2,9 @@
class Progress(object):
+ _strsize = 0
+ _note_size = 0
+
def __init__(self, max_index, bar_size=21):
self.total = max_index
# bar size in symbols
@@ -9,21 +12,35 @@
def write_progress(self, index, note=''):
# calc index and percent values
+ _suffix = ''
+ new_size = len(note)
+ if self._note_size > new_size:
+ _suffix = ' '*(self._note_size - new_size)
_percent = (100 * index) / self.total
_index = (self.bar_size * index) / self.total
# clear the line
sys.stdout.write('\r')
# print new progress
_format = "[{:"+str(self.bar_size-1)+"}] {}/{} ({}%) {}"
- sys.stdout.write(_format.format(
+ _progress_string = _format.format(
'='*_index,
index,
self.total,
_percent,
- note
- ))
+ note + _suffix
+ )
+ sys.stdout.write(_progress_string)
+ # Save new note size and whole string size
+ self._strsize = len(_progress_string)
+ self._note_size = new_size
sys.stdout.flush()
- @staticmethod
- def newline():
+ def clearline(self):
+ sys.stdout.write('\r')
+ sys.stdout.write(' '*self._strsize)
+ sys.stdout.write('\r')
+
+ def end(self):
+ self._note_size = 0
+ self._strsize = 0
sys.stdout.write('\n')