13 class VcsStatusMonitorThread(QThread): |
13 class VcsStatusMonitorThread(QThread): |
14 """ |
14 """ |
15 Class implementing the VCS status monitor thread base class. |
15 Class implementing the VCS status monitor thread base class. |
16 |
16 |
17 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status |
17 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status |
18 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of the |
18 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of |
19 monitoring thread (ok, nok, op) and a status message |
19 the monitoring thread (ok, nok, op) and a status message |
20 """ |
20 """ |
21 vcsStatusMonitorData = pyqtSignal(list) |
21 vcsStatusMonitorData = pyqtSignal(list) |
22 vcsStatusMonitorStatus = pyqtSignal(str, str) |
22 vcsStatusMonitorStatus = pyqtSignal(str, str) |
23 |
23 |
24 def __init__(self, interval, project, vcs, parent=None): |
24 def __init__(self, interval, project, vcs, parent=None): |
55 Protected method implementing the tasks action. |
55 Protected method implementing the tasks action. |
56 """ |
56 """ |
57 while not self.__stopIt: |
57 while not self.__stopIt: |
58 # perform the checking task |
58 # perform the checking task |
59 self.statusList = [] |
59 self.statusList = [] |
60 self.vcsStatusMonitorStatus.emit("wait", self.trUtf8("Waiting for lock")) |
60 self.vcsStatusMonitorStatus.emit( |
|
61 "wait", self.trUtf8("Waiting for lock")) |
61 try: |
62 try: |
62 locked = self.vcs.vcsExecutionMutex.tryLock(5000) |
63 locked = self.vcs.vcsExecutionMutex.tryLock(5000) |
63 except TypeError: |
64 except TypeError: |
64 locked = self.vcs.vcsExecutionMutex.tryLock() |
65 locked = self.vcs.vcsExecutionMutex.tryLock() |
65 if locked: |
66 if locked: |
71 self.vcs.vcsExecutionMutex.unlock() |
72 self.vcs.vcsExecutionMutex.unlock() |
72 if res: |
73 if res: |
73 status = "ok" |
74 status = "ok" |
74 else: |
75 else: |
75 status = "nok" |
76 status = "nok" |
76 self.vcsStatusMonitorStatus.emit("send", self.trUtf8("Sending data")) |
77 self.vcsStatusMonitorStatus.emit( |
|
78 "send", self.trUtf8("Sending data")) |
77 self.vcsStatusMonitorData.emit(self.statusList) |
79 self.vcsStatusMonitorData.emit(self.statusList) |
78 self.vcsStatusMonitorStatus.emit(status, statusMsg) |
80 self.vcsStatusMonitorStatus.emit(status, statusMsg) |
79 else: |
81 else: |
80 self.vcsStatusMonitorStatus.emit( |
82 self.vcsStatusMonitorStatus.emit( |
81 "timeout", self.trUtf8("Timed out waiting for lock")) |
83 "timeout", self.trUtf8("Timed out waiting for lock")) |
86 self.shouldUpdate = False |
88 self.shouldUpdate = False |
87 |
89 |
88 # wait until interval has expired checking for a stop condition |
90 # wait until interval has expired checking for a stop condition |
89 self.monitorMutex.lock() |
91 self.monitorMutex.lock() |
90 if not self.__stopIt: |
92 if not self.__stopIt: |
91 self.monitorCondition.wait(self.monitorMutex, self.interval * 1000) |
93 self.monitorCondition.wait( |
|
94 self.monitorMutex, self.interval * 1000) |
92 self.monitorMutex.unlock() |
95 self.monitorMutex.unlock() |
93 |
96 |
94 self._shutdown() |
97 self._shutdown() |
95 self.exit() |
98 self.exit() |
96 |
99 |
163 |
166 |
164 def _performMonitor(self): |
167 def _performMonitor(self): |
165 """ |
168 """ |
166 Protected method implementing the real monitoring action. |
169 Protected method implementing the real monitoring action. |
167 |
170 |
168 This method must be overridden and populate the statusList member variable |
171 This method must be overridden and populate the statusList member |
169 with a list of strings giving the status in the first column and the |
172 variable with a list of strings giving the status in the first column |
170 path relative to the project directory starting with the third column. |
173 and the path relative to the project directory starting with the |
171 The allowed status flags are: |
174 third column. The allowed status flags are: |
172 <ul> |
175 <ul> |
173 <li>"A" path was added but not yet comitted</li> |
176 <li>"A" path was added but not yet comitted</li> |
174 <li>"M" path has local changes</li> |
177 <li>"M" path has local changes</li> |
175 <li>"O" path was removed</li> |
178 <li>"O" path was removed</li> |
176 <li>"R" path was deleted and then re-added</li> |
179 <li>"R" path was deleted and then re-added</li> |