summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2010-10-16 12:56:00 -0700
committerAndrew Resch <andrewresch@gmail.com>2010-10-16 12:56:29 -0700
commit6d2a001635e384fedef3f5ebd9a1f3ad4cb1b7bb (patch)
tree63089d671c65f1a76c8555fd82f445ba00ff4aca
parent2a3eb0578c6064c66d0fabcf78b2fe7f9b3d6d12 (diff)
downloaddeluge-6d2a001635e384fedef3f5ebd9a1f3ad4cb1b7bb.tar.gz
deluge-6d2a001635e384fedef3f5ebd9a1f3ad4cb1b7bb.tar.bz2
deluge-6d2a001635e384fedef3f5ebd9a1f3ad4cb1b7bb.zip
Fix #1373 use of cyrllic paths
-rw-r--r--deluge/common.py2
-rw-r--r--deluge/config.py13
-rw-r--r--tests/test_config.py7
3 files changed, 17 insertions, 5 deletions
diff --git a/deluge/common.py b/deluge/common.py
index 128777134..3acccd780 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -475,7 +475,7 @@ def free_space(path):
sectors, bytes, free, total = map(long, win32file.GetDiskFreeSpace(path))
return (free * sectors * bytes)
else:
- disk_data = os.statvfs(path)
+ disk_data = os.statvfs(path.encode("utf8"))
block_size = disk_data.f_bsize
return disk_data.f_bavail * block_size
diff --git a/deluge/config.py b/deluge/config.py
index ab0476f1a..9fe5915eb 100644
--- a/deluge/config.py
+++ b/deluge/config.py
@@ -191,6 +191,7 @@ what is currently in the config and it could not convert the value
if isinstance(value, basestring):
value = deluge.common.utf8_encoded(value)
+
if not self.__config.has_key(key):
self.__config[key] = value
log.debug("Setting '%s' to %s of %s", key, value, type(value))
@@ -204,7 +205,10 @@ what is currently in the config and it could not convert the value
if value is not None and oldtype != type(None) and oldtype != newtype:
try:
- value = oldtype(value)
+ if oldtype == unicode:
+ value = oldtype(value, "utf8")
+ else:
+ value = oldtype(value)
except ValueError:
log.warning("Type '%s' invalid for '%s'", newtype, key)
raise
@@ -254,7 +258,10 @@ what is currently in the config and it could not convert the value
5
"""
- return self.__config[key]
+ if isinstance(self.__config[key], str):
+ return self.__config[key].decode("utf8")
+ else:
+ return self.__config[key]
def register_change_callback(self, callback):
"""
@@ -404,7 +411,7 @@ what is currently in the config and it could not convert the value
# The config has not changed so lets just return
if self._save_timer and self._save_timer.active():
self._save_timer.cancel()
- return
+ return True
except IOError, e:
log.warning("Unable to open config file: %s because: %s", filename, e)
diff --git a/tests/test_config.py b/tests/test_config.py
index d61920e20..c329befc4 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
from twisted.trial import unittest
from twisted.python.failure import Failure
@@ -6,7 +8,7 @@ import os
from deluge.config import Config
-DEFAULTS = {"string": "foobar", "int": 1, "float": 0.435, "bool": True}
+DEFAULTS = {"string": "foobar", "int": 1, "float": 0.435, "bool": True, "unicode": u"foobar"}
class ConfigTestCase(unittest.TestCase):
def setUp(self):
@@ -27,6 +29,9 @@ class ConfigTestCase(unittest.TestCase):
config["foo"] = 2
self.assertEquals(config.get_item("foo"), 2)
+ config["unicode"] = u"ВИДЕОФИЛЬМЫ"
+ self.assertEquals(config["unicode"], u"ВИДЕОФИЛЬМЫ")
+
config._save_timer.cancel()
def test_load(self):