Skip to content

Commit

Permalink
tuned-adm: Fix a traceback when run without arguments
Browse files Browse the repository at this point in the history
Running tuned-adm without arguments using Python 3 results in
a traceback. This is because in this case parse_args does not
exit with a usage message in Python 3 and the 'action' option
is then undefined. So let's check for this case and print the
usage message ourselves. There may be a better solution to this,
but I wasn't able to come up with anything in a reasonable amount
of time.

Signed-off-by: Ondřej Lysoněk <[email protected]>
  • Loading branch information
olysonek committed Jul 9, 2018
1 parent d9fc983 commit 5ff48f7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tuned-adm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def check_log_level(value):
parser_profile_mode = subparsers.add_parser("profile_mode", help="show current profile selection mode")
parser_profile_mode.set_defaults(action="profile_mode")

if len(sys.argv) < 2:
parser.print_usage(file = sys.stderr)
sys.exit(1)
args = parser.parse_args(sys.argv[1:])

options = vars(args)
Expand Down

0 comments on commit 5ff48f7

Please sign in to comment.