From 6dc139e68528a73379e17fb9f4be0b39e782124c Mon Sep 17 00:00:00 2001 From: idziubenko Date: Fri, 24 Dec 2021 17:28:13 +0300 Subject: [PATCH] added check for world update to EmergeLog --- pym/calculate/lib/utils/portage.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pym/calculate/lib/utils/portage.py b/pym/calculate/lib/utils/portage.py index d038066..1c149a1 100644 --- a/pym/calculate/lib/utils/portage.py +++ b/pym/calculate/lib/utils/portage.py @@ -1164,6 +1164,14 @@ class EmergeLog(): if m: self._remove_list.append(m.group(2)) + def did_update_world_happen(self): + latest_log = '\n'.join(line for line in self._get_last_changes()) + reg_emerge = r"(?s)(?<=[\s|@]world\n).*?(?=terminating)" + reg_success = r"\w*(?=\: \*\*\* exiting successfully)" + matches = re.finditer(reg_emerge, latest_log) + match_successes = [re.search(reg_success, match.group()) for match in matches] + return any(match_successes) + def _set_marker(self, text_marker): with open(self.emerge_log, 'a') as f: f.write("{0:.0f}: {1}\n".format(time.time(), text_marker))