From 84ca17a14c00d19dbc645f4f83043341f01b34ac Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 29 Mar 2016 21:30:42 +0200 Subject: [PATCH] select_quality: Replace sys.exits with UIExceptions --- lib/svtplay_dl/utils/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/svtplay_dl/utils/__init__.py b/lib/svtplay_dl/utils/__init__.py index b346d69..e4ae3f8 100644 --- a/lib/svtplay_dl/utils/__init__.py +++ b/lib/svtplay_dl/utils/__init__.py @@ -108,14 +108,12 @@ def select_quality(options, streams): try: optq = int(options.quality) except ValueError: - log.error("Requested quality need to be a number") - sys.exit(4) + raise error.UIException("Requested quality needs to be a number") if optq: try: optf = int(options.flexibleq) except ValueError: - log.error("Flexible-quality need to be a number") - sys.exit(4) + raise error.UIException("Flexible-quality needs to be a number") if not optf: wanted = [optq] else: @@ -131,9 +129,8 @@ def select_quality(options, streams): if not selected and selected != 0: data = sort_quality(streams) quality = ", ".join("%s (%s)" % (str(x), str(y)) for x, y in data) - log.error("Can't find that quality. Try one of: %s (or try --flexible-quality)", quality) - - sys.exit(4) + raise error.UIException("Can't find that quality. Try one of: %s (or " + "try --flexible-quality)" % quality) for s in streams: if s.bitrate == selected: