mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
Fix #823 setting config values to -1.0
This commit is contained in:
parent
0042fb1767
commit
a8697114c1
1 changed files with 8 additions and 9 deletions
|
@ -102,7 +102,7 @@ class Command(BaseCommand):
|
||||||
"""Show and set configuration values"""
|
"""Show and set configuration values"""
|
||||||
|
|
||||||
option_list = BaseCommand.option_list + (
|
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'),
|
help='set value for key'),
|
||||||
)
|
)
|
||||||
usage = "Usage: config [key1 [key2 ...]]\n"\
|
usage = "Usage: config [key1 [key2 ...]]\n"\
|
||||||
|
@ -153,17 +153,16 @@ class Command(BaseCommand):
|
||||||
def _set_config(self, *args, **options):
|
def _set_config(self, *args, **options):
|
||||||
deferred = defer.Deferred()
|
deferred = defer.Deferred()
|
||||||
config = component.get("CoreConfig")
|
config = component.get("CoreConfig")
|
||||||
key = args[0]
|
key = options["set"][0]
|
||||||
|
val = options["set"][1]
|
||||||
if key not in config.keys():
|
if key not in config.keys():
|
||||||
self.console.write("{!error!}The key '%s' is invalid!" % key)
|
self.console.write("{!error!}The key '%s' is invalid!" % key)
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
val = simple_eval(' '.join(args[1:]))
|
|
||||||
except SyntaxError, e:
|
|
||||||
self.console.write("{!error!}%s" % e)
|
|
||||||
return
|
|
||||||
|
|
||||||
if type(config[key]) != type(val):
|
if type(config[key]) != type(val):
|
||||||
|
try:
|
||||||
|
val = type(config[key])(val)
|
||||||
|
except:
|
||||||
self.config.write("{!error!}Configuration value provided has incorrect type.")
|
self.config.write("{!error!}Configuration value provided has incorrect type.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue