Merge lp:~a1s/qbrz/fix-subprocess-signals into lp:qbrz

Proposed by Aleksandr Smyshliaev
Status: Merged
Approved by: Robert Ladyman
Approved revision: 1642
Merged at revision: 1646
Proposed branch: lp:~a1s/qbrz/fix-subprocess-signals
Merge into: lp:qbrz
Diff against target: 89 lines (+11/-12)
2 files modified
lib/commit.py (+1/-1)
lib/subprocess.py (+10/-11)
To merge this branch: bzr merge lp:~a1s/qbrz/fix-subprocess-signals
Reviewer Review Type Date Requested Status
Robert Ladyman Approve
Jelmer Vernooij Approve
Review via email: mp+413808@code.launchpad.net

Commit message

Fix subprocess status checks.

Description of the change

After switching to PyQt5, some bound signals in the subprocess module got the same names as former instance attributes. So, for example, "if self.process_widget.finished" always evaluates to True because "finished" is a signal instance and not a boolean flag.

I've renamed the attributes to "is_finished" and "is_conflicted".

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Looks good to me, but I'll give Robert an opportunity to comment.

review: Approve
Revision history for this message
Robert Ladyman (saccadic-masking) wrote :

Yes, that's fine - and thanks for putting up with my delay (it's been a long long 18 months!).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/commit.py'
--- lib/commit.py 2021-01-05 14:53:28 +0000
+++ lib/commit.py 2022-01-07 15:25:03 +0000
@@ -700,7 +700,7 @@
700700
701 def _save_or_wipe_commit_data(self):701 def _save_or_wipe_commit_data(self):
702 if not self.process_widget.is_running():702 if not self.process_widget.is_running():
703 if self.process_widget.finished:703 if self.process_widget.is_finished:
704 self.wipe_commit_data()704 self.wipe_commit_data()
705 else:705 else:
706 self.save_commit_data()706 self.save_commit_data()
707707
=== modified file 'lib/subprocess.py'
--- lib/subprocess.py 2021-01-05 14:53:28 +0000
+++ lib/subprocess.py 2022-01-07 15:25:03 +0000
@@ -262,7 +262,7 @@
262 return True262 return True
263263
264 def do_accept(self):264 def do_accept(self):
265 if self.process_widget.finished:265 if self.process_widget.is_finished:
266 self.close()266 self.close()
267 else:267 else:
268 try:268 try:
@@ -519,8 +519,7 @@
519519
520 self.defaultWorkingDir = self.process.workingDirectory()520 self.defaultWorkingDir = self.process.workingDirectory()
521521
522 # RJLRJL commented out522 self.is_finished = False
523 # self.finished = False
524 self.aborting = False523 self.aborting = False
525524
526 self.messageFormat = QtGui.QTextCharFormat()525 self.messageFormat = QtGui.QTextCharFormat()
@@ -536,8 +535,7 @@
536 self._args_file = None # temp file to pass arguments to qsubprocess535 self._args_file = None # temp file to pass arguments to qsubprocess
537 self.error_class = ''536 self.error_class = ''
538 self.error_data = {}537 self.error_data = {}
539 # RJLRJL Commented out538 self.is_conflicted = False
540 # self.conflicted = False
541539
542 def hide_progress(self):540 def hide_progress(self):
543 self.progressMessage.setHidden(True)541 self.progressMessage.setHidden(True)
@@ -649,7 +647,8 @@
649 # make absolute, because we may be running in a different647 # make absolute, because we may be running in a different
650 # dir.648 # dir.
651 script = os.path.abspath(script)649 script = os.path.abspath(script)
652 if os.path.basename(script) != "brz":650 # allow for bzr or brz with optional extension (such as bzr.py)
651 if os.path.splitext(os.path.basename(script))[0] not in ("brz", "bzr"):
653 import breezy652 import breezy
654 # are we running directly from a bzr directory?653 # are we running directly from a bzr directory?
655 script = os.path.join(breezy.__path__[0], "..", "brz")654 script = os.path.join(breezy.__path__[0], "..", "brz")
@@ -757,7 +756,7 @@
757 elif line.startswith(SUB_NOTIFY):756 elif line.startswith(SUB_NOTIFY):
758 msg = line[len(SUB_NOTIFY):]757 msg = line[len(SUB_NOTIFY):]
759 if msg.startswith(NOTIFY_CONFLICT):758 if msg.startswith(NOTIFY_CONFLICT):
760 self.conflicted = True759 self.is_conflicted = True
761 self.conflict_tree_path = bittorrent_b_decode_prompt(msg[len(NOTIFY_CONFLICT):].encode(self.encoding))760 self.conflict_tree_path = bittorrent_b_decode_prompt(msg[len(NOTIFY_CONFLICT):].encode(self.encoding))
762 else:761 else:
763 self.logMessageEx(line, 'plain', self.stdout)762 self.logMessageEx(line, 'plain', self.stdout)
@@ -765,7 +764,7 @@
765 def readStderr(self):764 def readStderr(self):
766 data = bytes(self.process.readAllStandardError()).decode(self.encoding, 'replace')765 data = bytes(self.process.readAllStandardError()).decode(self.encoding, 'replace')
767 if data:766 if data:
768 self.error.emit()767 self.error.emit(True)
769768
770 for line in data.splitlines():769 for line in data.splitlines():
771 # RJLRJL this should be brz, I think770 # RJLRJL this should be brz, I think
@@ -825,12 +824,12 @@
825 if self.commands and not self.aborting:824 if self.commands and not self.aborting:
826 self._start_next()825 self._start_next()
827 else:826 else:
828 self.finished = True827 self.is_finished = True
829 self.setProgress(1000000, [gettext("Finished!")])828 self.setProgress(1000000, [gettext("Finished!")])
830 if self.conflicted:829 if self.is_conflicted:
831 self.conflicted.emit(self.conflict_tree_path)830 self.conflicted.emit(self.conflict_tree_path)
832 time.sleep(2)831 time.sleep(2)
833 self.finished.emit()832 self.finished.emit(True)
834 else:833 else:
835 self.setProgress(1000000, [gettext("Failed!")])834 self.setProgress(1000000, [gettext("Failed!")])
836 self.failed.emit(self.error_class)835 self.failed.emit(self.error_class)

Subscribers

People subscribed via source and target branches