changeset 1598:b144babc2658

core, plugin file: fixed progress id + data is now returned by getProgress, instead of being an argument to fill
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:20:33 +0100
parents 91a605feed8c
children e2ed8009e66e
files src/core/sat_main.py src/plugins/plugin_misc_file.py src/plugins/plugin_xep_0234.py
diffstat 3 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/sat_main.py	Sat Nov 14 19:19:04 2015 +0100
+++ b/src/core/sat_main.py	Sat Nov 14 19:20:33 2015 +0100
@@ -811,7 +811,7 @@
 
     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 @@
             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 @@
 
         @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 = {}
--- a/src/plugins/plugin_misc_file.py	Sat Nov 14 19:19:04 2015 +0100
+++ b/src/plugins/plugin_misc_file.py	Sat Nov 14 19:20:33 2015 +0100
@@ -66,7 +66,7 @@
         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 @@
     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):
--- a/src/plugins/plugin_xep_0234.py	Sat Nov 14 19:19:04 2015 +0100
+++ b/src/plugins/plugin_xep_0234.py	Sat Nov 14 19:20:33 2015 +0100
@@ -100,7 +100,7 @@
     # 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