From patchwork Tue Sep 18 11:18:31 2012
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [sugar-toolkit-gtk3,1/2] Activity class method to check enough space
Date: Tue, 18 Sep 2012 16:18:31 -0000
From: Manuel Kaufmann <humitos@gmail.com>
X-Patchwork-Id: 1749
Message-Id: <1347967112-4960-1-git-send-email-humitos@gmail.com>
To: simon@laptop.org
Cc: Manuel Kaufmann <humitos@gmail.com>, sugar-devel@lists.sugarlabs.org
New method to check if there is enough space to handle a file with the
size passed as argument on a specific path.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
src/sugar3/activity/activity.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py
index c896caf..c6f500f 100644
a
|
b
|
class Activity(Window, Gtk.Container): |
891 | 891 | |
892 | 892 | return True |
893 | 893 | |
| 894 | def enough_space(self, size, path='/'): |
| 895 | """Check if there is enough (size) free space on path |
| 896 | |
| 897 | size -- free space requested in Kb |
| 898 | |
| 899 | path -- device where the check will be done. For example: '/tmp' |
| 900 | |
| 901 | This method is useful to check the free space, for example, |
| 902 | before starting a download from internet, creating a big map |
| 903 | in some game or whatever action that needs some space in the |
| 904 | Hard Disk. |
| 905 | """ |
| 906 | |
| 907 | free_space = datastore.free_available_space(path=path) |
| 908 | return free_space - size > datastore.SPACE_THRESHOLD |
| 909 | |
894 | 910 | def _prepare_close(self, skip_save=False): |
895 | 911 | if not skip_save: |
896 | 912 | try: |