core, plugin file: fixed progress id + data is now returned by getProgress, instead of being an argument to fill
This commit is contained in:
parent
4826320188
commit
2c8b91ee6c
3 changed files with 10 additions and 11 deletions
|
|
@ -811,7 +811,7 @@ class SAT(service.Service):
|
|||
|
||||
def _progressGet(self, progress_id, profile):
|
||||
data = self.progressGet(progress_id, profile)
|
||||
return {k: unicode(v) for k,v in data}
|
||||
return {k: unicode(v) for k,v in data.iteritems()}
|
||||
|
||||
def progressGet(self, progress_id, profile):
|
||||
"""Return a dict with progress information
|
||||
|
|
@ -824,11 +824,10 @@ class SAT(service.Service):
|
|||
if id doesn't exists (may be a finished progression), and empty dict is returned
|
||||
"""
|
||||
client = self.getClient(profile)
|
||||
data = {}
|
||||
try:
|
||||
client._progress_cb[progress_id](progress_id, data, profile)
|
||||
data = client._progress_cb[progress_id](progress_id, profile)
|
||||
except KeyError:
|
||||
log.debug("Requested progress for unknown progress_id")
|
||||
data = {}
|
||||
return data
|
||||
|
||||
def _progressGetAll(self, profile_key):
|
||||
|
|
@ -844,9 +843,9 @@ class SAT(service.Service):
|
|||
|
||||
@param profile_key: %(doc_profile)s get all progress from this profile
|
||||
if C.PROF_KEY_ALL is used, all progress from all profiles are returned
|
||||
@return (dict[dict]): key=progress id, value=dict of data with the following keys:
|
||||
'position' (int): current possition
|
||||
'size' (int): end_position
|
||||
@return (dict[dict[dict]]): a dict which map profile to progress_dict
|
||||
progress_dict map progress_id to progress_data
|
||||
progress_data is the same dict as returned by [progressGet]
|
||||
"""
|
||||
clients = self.getClients(profile_key)
|
||||
progress_all = {}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class SatFile(object):
|
|||
self.host = host
|
||||
self.uid = uid or unicode(uuid.uuid4())
|
||||
self._file = open(path, mode)
|
||||
self.size = None
|
||||
self.size = size
|
||||
self.profile = profile
|
||||
self.eof = defer.Deferred()
|
||||
self.host.registerProgressCb(self.uid, self.getProgress, profile)
|
||||
|
|
@ -96,8 +96,8 @@ class SatFile(object):
|
|||
def tell(self):
|
||||
return self._file.tell()
|
||||
|
||||
def getProgress(self, progress_id, data, profile):
|
||||
return {'position': self._file.tell(), 'size': self.size or 0}
|
||||
def getProgress(self, progress_id, profile):
|
||||
return {'position': self._file.tell(), 'size': self.size or -1}
|
||||
|
||||
|
||||
class FilePlugin(object):
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class XEP_0234(object):
|
|||
# jingle callbacks
|
||||
|
||||
def jingleSessionInit(self, session, content_name, filepath, name, file_desc, progress_id_d, profile=C.PROF_KEY_NONE):
|
||||
progress_id_d.callback(self.getProgressId(session, content_name))
|
||||
progress_id_d.callback(self._getProgressId(session, content_name))
|
||||
content_data = session['contents'][content_name]
|
||||
application_data = content_data['application_data']
|
||||
assert 'file_path' not in application_data
|
||||
|
|
|
|||
Loading…
Reference in a new issue