Author: andar

Revision: 6023

Log:
        Fix #823 setting config values to -1.0

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2009-12-13 22:16:05 UTC (rev 6022)
+++ branches/1.2_RC/ChangeLog   2009-12-13 22:47:15 UTC (rev 6023)
@@ -29,6 +29,7 @@
 
 ==== Console ====
        * Fix using the console in Windows, but only in command-line mode
+       * Fix #823 setting config values to -1.0
 
 ==== Label ====
        * Fix #1085 only use ints for specific options to prevent unhandled 
exception

Modified: branches/1.2_RC/deluge/ui/console/commands/config.py
===================================================================
--- branches/1.2_RC/deluge/ui/console/commands/config.py        2009-12-13 
22:16:05 UTC (rev 6022)
+++ branches/1.2_RC/deluge/ui/console/commands/config.py        2009-12-13 
22:47:15 UTC (rev 6023)
@@ -102,7 +102,7 @@
     """Show and set configuration values"""
 
     option_list = BaseCommand.option_list + (
-            make_option('-s', '--set', action='store_true', default=False, 
dest='set',
+            make_option('-s', '--set', action='store', nargs=2, dest='set',
                         help='set value for key'),
     )
     usage = "Usage: config [key1 [key2 ...]]\n"\
@@ -153,19 +153,18 @@
     def _set_config(self, *args, **options):
         deferred = defer.Deferred()
         config = component.get("CoreConfig")
-        key = args[0]
+        key = options["set"][0]
+        val = options["set"][1]
         if key not in config.keys():
             self.console.write("{!error!}The key '%s' is invalid!" % key)
             return
-        try:
-            val = simple_eval(' '.join(args[1:]))
-        except SyntaxError, e:
-            self.console.write("{!error!}%s" % e)
-            return
 
         if type(config[key]) != type(val):
-            self.config.write("{!error!}Configuration value provided has 
incorrect type.")
-            return
+            try:
+                val = type(config[key])(val)
+            except:
+                self.config.write("{!error!}Configuration value provided has 
incorrect type.")
+                return
 
         def on_set_config(result):
             self.console.write("{!success!}Configuration value successfully 
updated.")

Modified: trunk/deluge/ui/console/commands/config.py
===================================================================
--- trunk/deluge/ui/console/commands/config.py  2009-12-13 22:16:05 UTC (rev 
6022)
+++ trunk/deluge/ui/console/commands/config.py  2009-12-13 22:47:15 UTC (rev 
6023)
@@ -102,7 +102,7 @@
     """Show and set configuration values"""
 
     option_list = BaseCommand.option_list + (
-            make_option('-s', '--set', action='store_true', default=False, 
dest='set',
+            make_option('-s', '--set', action='store', nargs=2, dest='set',
                         help='set value for key'),
     )
     usage = "Usage: config [key1 [key2 ...]]\n"\
@@ -153,19 +153,18 @@
     def _set_config(self, *args, **options):
         deferred = defer.Deferred()
         config = component.get("CoreConfig")
-        key = args[0]
+        key = options["set"][0]
+        val = options["set"][1]
         if key not in config.keys():
             self.console.write("{!error!}The key '%s' is invalid!" % key)
             return
-        try:
-            val = simple_eval(' '.join(args[1:]))
-        except SyntaxError, e:
-            self.console.write("{!error!}%s" % e)
-            return
 
         if type(config[key]) != type(val):
-            self.config.write("{!error!}Configuration value provided has 
incorrect type.")
-            return
+            try:
+                val = type(config[key])(val)
+            except:
+                self.config.write("{!error!}Configuration value provided has 
incorrect type.")
+                return
 
         def on_set_config(result):
             self.console.write("{!success!}Configuration value successfully 
updated.")


--

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