Fix error when resolving an integer

Fixes #588
This commit is contained in:
Zestyr 2017-07-03 23:53:35 +02:00 committed by Kay Kurokawa
parent 2d1624f088
commit 0c2d049c90
3 changed files with 10 additions and 6 deletions

View file

@ -23,6 +23,8 @@ at anytime.
* Fixed incorrect formatting of "amount" fields
* Fixed handling of SIGINT, SIGTERM.
* Fixed shutdown sequence
* Fix error when resolving an integer
*
### Deprecated
* The API will no longer be served at the /lbryapi path. It will now be at the root.
@ -80,7 +82,7 @@ at anytime.
### Fixed
* Fixed timeout behaviour when calling API command get
* Fixed https://github.com/lbryio/lbry/issues/765
### Removed
* Removed stream_info_cache.json from daemon.py

View file

@ -28,12 +28,12 @@ def set_flag_vals(flag_names, parsed_args):
elif key.startswith("--"):
if remove_brackets(key[2:]) not in kwargs:
k = remove_brackets(key[2:])
kwargs[k] = guess_type(arg)
elif key in flag_names:
if remove_brackets(flag_names[key]) not in kwargs:
kwargs[remove_brackets(flag_names[key])] = guess_type(arg)
k = remove_brackets(flag_names[key])
elif remove_brackets(key) not in kwargs:
kwargs[remove_brackets(key)] = guess_type(arg)
k = remove_brackets(key)
kwargs[k] = guess_type(arg, k)
return kwargs
@ -130,7 +130,7 @@ def main():
return 1
def guess_type(x):
def guess_type(x, key=None):
if not isinstance(x, (unicode, str)):
return x
if x in ('true', 'True', 'TRUE'):
@ -143,6 +143,8 @@ def guess_type(x):
except ValueError:
# not a float
pass
if key == "uri":
return x
try:
return int(x)
except ValueError:

View file

@ -7,6 +7,7 @@ class DaemonCLITests(unittest.TestCase):
self.assertEqual('0.3.8', DaemonCLI.guess_type('0.3.8'))
self.assertEqual(0.3, DaemonCLI.guess_type('0.3'))
self.assertEqual(3, DaemonCLI.guess_type('3'))
self.assertEqual('3', DaemonCLI.guess_type('3', key="uri"))
self.assertEqual('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA==', DaemonCLI.guess_type('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA=='))
self.assertEqual(0.3, DaemonCLI.guess_type('0.3'))
self.assertEqual(True, DaemonCLI.guess_type('TRUE'))
@ -15,4 +16,3 @@ class DaemonCLITests(unittest.TestCase):
self.assertEqual(False, DaemonCLI.guess_type('FALSE'))
self.assertEqual(False, DaemonCLI.guess_type('false'))
self.assertEqual(False, DaemonCLI.guess_type('False'))