Skip to content

Commit

Permalink
Add explicit check for non integer values
Browse files Browse the repository at this point in the history
Signed-off-by: JoeLametta <[email protected]>
  • Loading branch information
JoeLametta committed Jan 29, 2020
1 parent bfebf62 commit c1e9b4c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions whipper/command/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def add_arguments(self):
choices=['file', 'embed', 'complete'],
default=None)
self.parser.add_argument('r', '--max-retries',
action="store", dest="max_retries", type=int,
action="store", dest="max_retries",
help="number of rip attempts before giving "
"up if can't rip a track. This defaults to "
"{}; 0 means "
Expand Down Expand Up @@ -336,10 +336,14 @@ def handle_arguments(self):
logger.critical(msg)
raise ValueError(msg)

try:
self.options.max_retries = int(self.options.max_retries)
except ValueError:
raise ValueError("max retries' value must be of integer type")
if self.options.max_retries == 0:
self.options.max_retries = float("inf")
elif self.options.max_retries < 0:
raise ValueError("the number of max retries must be positive")
raise ValueError("number of max retries must be positive")

def doCommand(self):
self.program.setWorkingDirectory(self.options.working_directory)
Expand Down

0 comments on commit c1e9b4c

Please sign in to comment.