Module: deluge
Branch: master
Commit: 45940b90642a32c4af32fa7ce756ca75932121ef

Author: Andrew Resch <[email protected]>
Date:   Sat Oct 16 12:56:00 2010 -0700

Fix #1373 use of cyrllic paths

---

 deluge/common.py     |    2 +-
 deluge/config.py     |   13 ++++++++++---
 tests/test_config.py |    7 ++++++-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/deluge/common.py b/deluge/common.py
index 1287771..3acccd7 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 ab0476f..9fe5915 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 d61920e..c329bef 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):

-- 
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.

Reply via email to