[Sugar-devel] [PATCH Browse 2/2] Handle datastore.error signal

Manuel Kaufmann humitos at gmail.com
Tue Sep 18 08:37:14 EDT 2012


Stop the downloading process when this signal is received with the
datastore.LOW_SPACE error code.

Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
 downloadmanager.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/downloadmanager.py b/downloadmanager.py
index 5ad1a6f..bd8386d 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -65,6 +65,9 @@ class Download(object):
         self._download.connect('notify::status', self.__state_change_cb)
         self._download.connect('error', self.__error_cb)
 
+        # connect the error datastore signal to manage LOW_SPACE
+        datastore.error.connect(self.__datastore_error_cb)
+
         self.datastore_deleted_handler = None
 
         self.dl_jobject = None
@@ -89,6 +92,11 @@ class Download(object):
         self._download.set_destination_uri('file://' + self._dest_path)
         self._download.start()
 
+    def __datastore_error_cb(self, sender, **kwargs):
+        logging.debug('__datastore_error_cb')
+        if kwargs.get('errno', -1) == datastore.LOW_SPACE:
+            self._download.cancel()
+
     def __progress_change_cb(self, download, something):
         progress = self._download.get_progress()
         self.dl_jobject.metadata['progress'] = str(int(progress * 100))
-- 
1.7.11.4



More information about the Sugar-devel mailing list