From d89b33f8cbbcdb4569f0d6911972c8f3815a84bb Mon Sep 17 00:00:00 2001 From: colaclanth Date: Mon, 15 Jul 2019 19:45:02 +0100 Subject: [PATCH] Changed output arg to just be as string --- sstv/command.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sstv/command.py b/sstv/command.py index 388d540..c1c7a3a 100644 --- a/sstv/command.py +++ b/sstv/command.py @@ -1,5 +1,6 @@ """Parsing arguments and starting program from command line""" +from .common import log_message from .decode import SSTVDecoder from sys import exit import argparse @@ -45,7 +46,7 @@ examples: parser.add_argument("-d", "--decode", type=argparse.FileType('rb'), help="SSTV audio file to decode", dest="audio_file") - parser.add_argument("-o", "--output", type=argparse.FileType('wb'), + parser.add_argument("-o", "--output", type=str, help="desination of output file", default="result.png", dest="output_file") @@ -93,13 +94,13 @@ examples: img = sstv.decode() try: img.save(self._output_file) - except KeyError: + except (KeyError, ValueError): + log_message("Error saving file, saved to result.png instead", + err=True) img.save("result.png") def close(self): """ Closes any input/output files if they exist """ - if self._output_file is not None and not self._output_file.closed: - self._output_file.close() if self._audio_file is not None and not self._audio_file.closed: self._audio_file.close()