Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix CLI arguments type casting
The JsonServer is designed to allow change the tcpport and disable autoaddmgr and autodeletemgr settings via command line arguments
--tcpport 8081
,--autoaddmgr False
and--autodeltemgr False
.description of the bug
The current code does not works as per design intention as the python
argparse
library consider the default user input as ‘string’,User input:
will parsed by the argparse as a string instead of an integer for 8081:
Same issue for
--autoaddmgr
(and--autodeletemgr
), where the user input argument is parsed as a string instead of bool.result:
proposed changes for fixing the issue
The solution for correctly cast the input argument for
--tcpport
can be solved by addtype=int
into the code:Adding
type=bool
however doesn’t work forargparse
library, instead it requires of usingaction
as suggested byargparse
documentation (see reference link below):With
action='store-false
, simply add--autoaddmgr
as command line argument without a value will disable the autoaddmgr thread. This is a little bit counter-intuitive, therefore a helper text would be helpful to explain the usage.Reference: https://docs.python.org/2.7/library/argparse.html#action