tuna: tuna-cmd: Display usage instead of traceback -c missing args
Display a usage messaage instead of a python traceback when a required
argument to the -c or --cpus is missing, or when the argument doesn't
make sense. (Such as passing a nonsense string, instead of a comma separated list of numbers)
- In function pick_op, handle the unusual but possible case where an
empty string is passed as an argument.
- Display a usage message upon ValueError when caling cpustring_to_list
when processing the -c option
This fixes various erroneous or missing input to -c, such as the
following
./tuna-cmd.py -c -P
Traceback (most recent call last):
File "./tuna-cmd.py", line 656, in <module>
main()
File "./tuna-cmd.py", line 494, in main
op_list = tuna.cpustring_to_list(a)
File "/home/jkacur/source/tuna/tuna/tuna.py", line 124, in
cpustring_to_list
ends = [ int(a, 0) for a in field.split("-") ]
ValueError: invalid literal for int() with base 0: 'P'
./tuna-cmd.py -c "" -P
Traceback (most recent call last):
File "./tuna-cmd.py", line 656, in <module>
main()
File "./tuna-cmd.py", line 493, in main
(op, a) = pick_op(a)
File "./tuna-cmd.py", line 408, in pick_op
if argument[0] in ('+', '-'):
IndexError: string index out of range
./tuna-cmd.py -c "nonesense" -P
Traceback (most recent call last):
File "./tuna-cmd.py", line 656, in <module>
main()
File "./tuna-cmd.py", line 494, in main
op_list = tuna.cpustring_to_list(a)
File "/home/jkacur/source/tuna/tuna/tuna.py", line 124, in
cpustring_to_list
ends = [ int(a, 0) for a in field.split("-") ]
ValueError: invalid literal for int() with base 0: 'nonesense'
This fixes bugzilla 1268287
Signed-off-by: John Kacur <jkacur@redhat.com>
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
1 file changed