VCS/StatusMonitorThread.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3013
fe886b7f8f40
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
15 class VcsStatusMonitorThread(QThread): 15 class VcsStatusMonitorThread(QThread):
16 """ 16 """
17 Class implementing the VCS status monitor thread base class. 17 Class implementing the VCS status monitor thread base class.
18 18
19 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status 19 @signal vcsStatusMonitorData(list of str) emitted to update the VCS status
20 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of the 20 @signal vcsStatusMonitorStatus(str, str) emitted to signal the status of
21 monitoring thread (ok, nok, op) and a status message 21 the monitoring thread (ok, nok, op) and a status message
22 """ 22 """
23 vcsStatusMonitorData = pyqtSignal(list) 23 vcsStatusMonitorData = pyqtSignal(list)
24 vcsStatusMonitorStatus = pyqtSignal(str, str) 24 vcsStatusMonitorStatus = pyqtSignal(str, str)
25 25
26 def __init__(self, interval, project, vcs, parent=None): 26 def __init__(self, interval, project, vcs, parent=None):
57 Protected method implementing the tasks action. 57 Protected method implementing the tasks action.
58 """ 58 """
59 while not self.__stopIt: 59 while not self.__stopIt:
60 # perform the checking task 60 # perform the checking task
61 self.statusList = [] 61 self.statusList = []
62 self.vcsStatusMonitorStatus.emit("wait", self.trUtf8("Waiting for lock")) 62 self.vcsStatusMonitorStatus.emit(
63 "wait", self.trUtf8("Waiting for lock"))
63 try: 64 try:
64 locked = self.vcs.vcsExecutionMutex.tryLock(5000) 65 locked = self.vcs.vcsExecutionMutex.tryLock(5000)
65 except TypeError: 66 except TypeError:
66 locked = self.vcs.vcsExecutionMutex.tryLock() 67 locked = self.vcs.vcsExecutionMutex.tryLock()
67 if locked: 68 if locked:
73 self.vcs.vcsExecutionMutex.unlock() 74 self.vcs.vcsExecutionMutex.unlock()
74 if res: 75 if res:
75 status = "ok" 76 status = "ok"
76 else: 77 else:
77 status = "nok" 78 status = "nok"
78 self.vcsStatusMonitorStatus.emit("send", self.trUtf8("Sending data")) 79 self.vcsStatusMonitorStatus.emit(
80 "send", self.trUtf8("Sending data"))
79 self.vcsStatusMonitorData.emit(self.statusList) 81 self.vcsStatusMonitorData.emit(self.statusList)
80 self.vcsStatusMonitorStatus.emit(status, statusMsg) 82 self.vcsStatusMonitorStatus.emit(status, statusMsg)
81 else: 83 else:
82 self.vcsStatusMonitorStatus.emit( 84 self.vcsStatusMonitorStatus.emit(
83 "timeout", self.trUtf8("Timed out waiting for lock")) 85 "timeout", self.trUtf8("Timed out waiting for lock"))
88 self.shouldUpdate = False 90 self.shouldUpdate = False
89 91
90 # wait until interval has expired checking for a stop condition 92 # wait until interval has expired checking for a stop condition
91 self.monitorMutex.lock() 93 self.monitorMutex.lock()
92 if not self.__stopIt: 94 if not self.__stopIt:
93 self.monitorCondition.wait(self.monitorMutex, self.interval * 1000) 95 self.monitorCondition.wait(
96 self.monitorMutex, self.interval * 1000)
94 self.monitorMutex.unlock() 97 self.monitorMutex.unlock()
95 98
96 self._shutdown() 99 self._shutdown()
97 self.exit() 100 self.exit()
98 101
165 168
166 def _performMonitor(self): 169 def _performMonitor(self):
167 """ 170 """
168 Protected method implementing the real monitoring action. 171 Protected method implementing the real monitoring action.
169 172
170 This method must be overridden and populate the statusList member variable 173 This method must be overridden and populate the statusList member
171 with a list of strings giving the status in the first column and the 174 variable with a list of strings giving the status in the first column
172 path relative to the project directory starting with the third column. 175 and the path relative to the project directory starting with the
173 The allowed status flags are: 176 third column. The allowed status flags are:
174 <ul> 177 <ul>
175 <li>"A" path was added but not yet comitted</li> 178 <li>"A" path was added but not yet comitted</li>
176 <li>"M" path has local changes</li> 179 <li>"M" path has local changes</li>
177 <li>"O" path was removed</li> 180 <li>"O" path was removed</li>
178 <li>"R" path was deleted and then re-added</li> 181 <li>"R" path was deleted and then re-added</li>
179 <li>"U" path needs an update</li> 182 <li>"U" path needs an update</li>
180 <li>"Z" path contains a conflict</li> 183 <li>"Z" path contains a conflict</li>
181 <li>" " path is back at normal</li> 184 <li>" " path is back at normal</li>
182 </ul> 185 </ul>
183 186
184 @return tuple of flag indicating successful operation (boolean) and 187 @ireturn tuple of flag indicating successful operation (boolean) and
185 a status message in case of non successful operation (string) 188 a status message in case of non successful operation (string)
189 @exception RuntimeError to indicate that this method must be
190 implemented by a subclass
186 """ 191 """
187 raise RuntimeError('Not implemented') 192 raise RuntimeError('Not implemented')
188 193
189 def _shutdown(self): 194 def _shutdown(self):
190 """ 195 """

eric ide

mercurial