fixed percent progress

master
idziubenko 3 years ago
parent 560791b01b
commit 6ea3065a69

@ -1146,7 +1146,6 @@ class PercentProgress(processProgress):
end: конечный прогрессбар (по умолчанию)
atty: для получения данных создается pty
"""
#TODO probably full of encoding errors, needs testing
def init(self, *args, **kwargs):
self.rePerc = re.compile(b"(\d+(?:\.\d+)?)%", re.S)
self.part = kwargs.get("part", 1)
@ -1163,7 +1162,7 @@ class PercentProgress(processProgress):
"Bad Option|No space left|FATAL ERROR|SYNTAX:|mkisofs:|"
"error:|warning:|fatal:).*)"), encoding="UTF-8"))
self.atty = kwargs.get("atty", False)
self.alldata = ""
self.alldata = b""
def _open(self):
self.master, self.slave = None, None
@ -1181,7 +1180,7 @@ class PercentProgress(processProgress):
cwd=self.cwd,
close_fds=True,
env=self.envdict)
self.pipe.stdout = os.fdopen(self.master, 'r')
self.pipe.stdout = os.fdopen(self.master, 'rb')
else:
process._open(self)
@ -1204,8 +1203,8 @@ class PercentProgress(processProgress):
resSearch = self.cachedata.search(strdata)
if resSearch:
self._cachedata.append(
re.sub("\[31;01m\*|\[33;01m\*|\[.*?m",
"", resSearch.group(1)))
re.sub(b"\[31;01m\*|\[33;01m\*|\[.*?m",
b"", resSearch.group(1)))
if match:
percent = int(float(match.group(1)))
if percent < self.percent:

Loading…
Cancel
Save