MCPcopy
hub / github.com/pyload/pyload / getProgress

Method getProgress

module/gui/Queue.py:190–218  ·  view source on GitHub ↗

return download progress, locks by default since it's used in already locked calls, it provides an option to not lock

(self, item, locked=True)

Source from the content-addressed store, hash-verified

188 return None
189
190 def getProgress(self, item, locked=True):
191 """
192 return download progress, locks by default
193 since it's used in already locked calls,
194 it provides an option to not lock
195 """
196 if locked:
197 locker = QMutexLocker(self.mutex)
198 if isinstance(item, Link):
199 try:
200 if item.data["status"] == 0:
201 return 100
202 return int(item.data["downloading"]["percent"])
203 except:
204 return 0
205 elif isinstance(item, Package):
206 count = len(item.children)
207 perc_sum = 0
208 for child in item.children:
209 try:
210 if child.data["status"] == 0: #completed
211 perc_sum += 100
212 perc_sum += int(child.data["downloading"]["percent"])
213 except:
214 pass
215 if count == 0:
216 return 0
217 return perc_sum/count
218 return 0
219
220 def getSpeed(self, item):
221 """

Callers 2

dataMethod · 0.95
paintMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected