diff --git a/src/core/sat_main.py b/src/core/sat_main.py index 2ec50479..09d8a85b 100644 --- a/src/core/sat_main.py +++ b/src/core/sat_main.py @@ -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 = {} diff --git a/src/plugins/plugin_misc_file.py b/src/plugins/plugin_misc_file.py index 1b653677..66a47890 100644 --- a/src/plugins/plugin_misc_file.py +++ b/src/plugins/plugin_misc_file.py @@ -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): diff --git a/src/plugins/plugin_xep_0234.py b/src/plugins/plugin_xep_0234.py index b6a46bf0..b9715929 100644 --- a/src/plugins/plugin_xep_0234.py +++ b/src/plugins/plugin_xep_0234.py @@ -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