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
1=== modified file 'lib/commit.py'
2--- lib/commit.py 2021-01-05 14:53:28 +0000
3+++ lib/commit.py 2022-01-07 15:25:03 +0000
4@@ -700,7 +700,7 @@
5
6 def _save_or_wipe_commit_data(self):
7 if not self.process_widget.is_running():
8- if self.process_widget.finished:
9+ if self.process_widget.is_finished:
10 self.wipe_commit_data()
11 else:
12 self.save_commit_data()
13
14=== modified file 'lib/subprocess.py'
15--- lib/subprocess.py 2021-01-05 14:53:28 +0000
16+++ lib/subprocess.py 2022-01-07 15:25:03 +0000
17@@ -262,7 +262,7 @@
18 return True
19
20 def do_accept(self):
21- if self.process_widget.finished:
22+ if self.process_widget.is_finished:
23 self.close()
24 else:
25 try:
26@@ -519,8 +519,7 @@
27
28 self.defaultWorkingDir = self.process.workingDirectory()
29
30- # RJLRJL commented out
31- # self.finished = False
32+ self.is_finished = False
33 self.aborting = False
34
35 self.messageFormat = QtGui.QTextCharFormat()
36@@ -536,8 +535,7 @@
37 self._args_file = None # temp file to pass arguments to qsubprocess
38 self.error_class = ''
39 self.error_data = {}
40- # RJLRJL Commented out
41- # self.conflicted = False
42+ self.is_conflicted = False
43
44 def hide_progress(self):
45 self.progressMessage.setHidden(True)
46@@ -649,7 +647,8 @@
47 # make absolute, because we may be running in a different
48 # dir.
49 script = os.path.abspath(script)
50- if os.path.basename(script) != "brz":
51+ # allow for bzr or brz with optional extension (such as bzr.py)
52+ if os.path.splitext(os.path.basename(script))[0] not in ("brz", "bzr"):
53 import breezy
54 # are we running directly from a bzr directory?
55 script = os.path.join(breezy.__path__[0], "..", "brz")
56@@ -757,7 +756,7 @@
57 elif line.startswith(SUB_NOTIFY):
58 msg = line[len(SUB_NOTIFY):]
59 if msg.startswith(NOTIFY_CONFLICT):
60- self.conflicted = True
61+ self.is_conflicted = True
62 self.conflict_tree_path = bittorrent_b_decode_prompt(msg[len(NOTIFY_CONFLICT):].encode(self.encoding))
63 else:
64 self.logMessageEx(line, 'plain', self.stdout)
65@@ -765,7 +764,7 @@
66 def readStderr(self):
67 data = bytes(self.process.readAllStandardError()).decode(self.encoding, 'replace')
68 if data:
69- self.error.emit()
70+ self.error.emit(True)
71
72 for line in data.splitlines():
73 # RJLRJL this should be brz, I think
74@@ -825,12 +824,12 @@
75 if self.commands and not self.aborting:
76 self._start_next()
77 else:
78- self.finished = True
79+ self.is_finished = True
80 self.setProgress(1000000, [gettext("Finished!")])
81- if self.conflicted:
82+ if self.is_conflicted:
83 self.conflicted.emit(self.conflict_tree_path)
84 time.sleep(2)
85- self.finished.emit()
86+ self.finished.emit(True)
87 else:
88 self.setProgress(1000000, [gettext("Failed!")])
89 self.failed.emit(self.error_class)

Subscribers

People subscribed via source and target branches