Author: andar
Revision: 5544
Log:
Add get_free_space() to core
Diff:
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py 2009-07-24 10:32:14 UTC (rev 5543)
+++ trunk/deluge/core/core.py 2009-07-24 23:36:43 UTC (rev 5544)
@@ -803,3 +803,19 @@
return 0
else:
return int(status)
+
+ @export
+ def get_free_space(self, path):
+ """
+ Returns the number of free bytes at path
+
+ :param path: the path to check free space at
+ :type path: string
+
+ :returns: the number of free bytes at path
+ :rtype: int
+
+ :raises InvalidPathError: if the path is invalid
+
+ """
+ return deluge.common.free_space(path)
Modified: trunk/deluge/error.py
===================================================================
--- trunk/deluge/error.py 2009-07-24 10:32:14 UTC (rev 5543)
+++ trunk/deluge/error.py 2009-07-24 23:36:43 UTC (rev 5544)
@@ -35,10 +35,7 @@
class DelugeError(Exception):
- def __init__(self, value):
- self.value = value
- def __str__(self):
- return repr(self.value)
+ pass
class NoCoreError(DelugeError):
pass
@@ -48,3 +45,6 @@
class InvalidTorrentError(DelugeError):
pass
+
+class InvalidPathError(DelugeError):
+ pass
Modified: trunk/tests/test_core.py
===================================================================
--- trunk/tests/test_core.py 2009-07-24 10:32:14 UTC (rev 5543)
+++ trunk/tests/test_core.py 2009-07-24 23:36:43 UTC (rev 5544)
@@ -11,6 +11,7 @@
from deluge.core.rpcserver import RPCServer
from deluge.core.core import Core
import deluge.component as component
+import deluge.error
class CoreTestCase(unittest.TestCase):
def setUp(self):
@@ -75,7 +76,6 @@
import base64
torrent_id = self.core.add_torrent_file(filename,
base64.encodestring(open(filename).read()), options)
- import deluge.error
self.assertRaises(deluge.error.InvalidTorrentError,
self.core.remove_torrent, "torrentidthatdoesntexist", True)
ret = self.core.remove_torrent(torrent_id, True)
@@ -93,4 +93,11 @@
self.assertEquals(type(status), dict)
self.assertEquals(status["write_hit_ratio"], 0.0)
self.assertEquals(status["read_hit_ratio"], 0.0)
-
+
+ def test_get_free_space(self):
+ space = self.core.get_free_space(".")
+ self.assertTrue(type(space) == int)
+ self.assertTrue(space >= 0)
+ self.assertRaises(deluge.error.InvalidPathError,
self.core.get_free_space, "/someinvalidpath")
+
+
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---