From 6ea3065a69b974ac5595bab964649f8c2a437d81 Mon Sep 17 00:00:00 2001 From: idziubenko Date: Thu, 12 Aug 2021 15:36:31 +0300 Subject: [PATCH] fixed percent progress --- pym/calculate/lib/utils/files.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pym/calculate/lib/utils/files.py b/pym/calculate/lib/utils/files.py index ee53d34..49a67c8 100644 --- a/pym/calculate/lib/utils/files.py +++ b/pym/calculate/lib/utils/files.py @@ -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: