diff --git a/ivas_processing_scripts/__init__.py b/ivas_processing_scripts/__init__.py index 7f6598bf65b2e97c7ce1c4cdf9b954bb0dd84335..360148700d3af844bb571bd70715ff151945e6f3 100755 --- a/ivas_processing_scripts/__init__.py +++ b/ivas_processing_scripts/__init__.py @@ -209,7 +209,7 @@ def main(args): spinner() sleep(0.1) progressbar_update(count, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) results.get() p.close() diff --git a/ivas_processing_scripts/audiotools/__init__.py b/ivas_processing_scripts/audiotools/__init__.py index 7cb4f06c59a106e20cde38d256cd6af8906b96a9..3d3955271905ab61a0196a1b0878063e20398d6b 100755 --- a/ivas_processing_scripts/audiotools/__init__.py +++ b/ivas_processing_scripts/audiotools/__init__.py @@ -55,14 +55,12 @@ def add_processing_args(group, input=True): f"-{ps}", f"--{p}", dest=f"{p}put", - required=True, type=Path, help="Path to *.{wav, pcm, raw} file or directory", ) group.add_argument( f"-{ps}f", f"--{p}_fmt", - required=input, type=str, help="Audio format (use -l, --list for a list / -L, --long for a detailed list)", default=None, @@ -132,7 +130,7 @@ def add_processing_args(group, input=True): ) -def get_args(): +def get_argparser(): parser = argparse.ArgumentParser( description="Audiotools: Convert/Manipulate spatial audio files." ) @@ -224,12 +222,15 @@ def get_args(): action="store_true", ) - return parser.parse_args() + return parser def main(): - args = get_args() + parser = get_argparser() + + args = parser.parse_args() + # special arguments for listing formats if args.list is True or args.long is True: for fmt in AUDIO_FORMATS: if args.long: @@ -239,6 +240,11 @@ def main(): else: print(", ".join(fmt.keys())) exit() + + # validate required arguments + if args.input is None or args.in_fmt is None or args.output is None: + parser.print_usage() + raise SystemExit("the following arguments are required: -i/--in, -if/--in_fmt, -o/--out") elif args.input is not None: if not args.out_fs: @@ -272,7 +278,12 @@ def main(): if len(in_files) == 1 and args.input.is_file(): out_files = [args.output] else: - args.output.mkdir(exist_ok=True) + # input was a dir so output should be a dir too + if args.output.is_file(): + raise NotADirectoryError(f"Input directory '{args.input}' specified with file output to '{args.output}' - please specify an output directory instead") + if not args.output.exists(): + args.output.mkdir() + print(f"Created output directory {args.output}") out_files = [args.output.joinpath(i.name) for i in in_files] # Multiprocessing diff --git a/ivas_processing_scripts/processing/processing.py b/ivas_processing_scripts/processing/processing.py index a2e3316023c34d5514125c95bb6427b82003ef5b..4d96571f5d10059e214de6f46d3ae4cfbb06c8ce 100755 --- a/ivas_processing_scripts/processing/processing.py +++ b/ivas_processing_scripts/processing/processing.py @@ -345,7 +345,7 @@ def preprocess(cfg, logger): spinner() sleep(0.1) progressbar_update(count, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) results.get() p.close() @@ -441,7 +441,7 @@ def preprocess_2(cfg, logger): spinner() sleep(0.1) progressbar_update(count, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) results.get() p.close() diff --git a/ivas_processing_scripts/utils.py b/ivas_processing_scripts/utils.py index f71a6b5b7ac864662ede4fd9525c2bc3b518d6af..b1104096a1605e01e7ca2c6dbd09ee89f03ebb79 100755 --- a/ivas_processing_scripts/utils.py +++ b/ivas_processing_scripts/utils.py @@ -296,7 +296,7 @@ def progressbar(iter: Iterable, width=80): for i, item in enumerate(iter): yield item progressbar_update(i + 1, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) def spinner(): diff --git a/other/check_conditions.py b/other/check_conditions.py index 7ec03c8cf63b215376cde1e246128be7b44c88f8..74dfe8b46430792fd3649dfd2f1d8612c8af9ce0 100644 --- a/other/check_conditions.py +++ b/other/check_conditions.py @@ -231,7 +231,7 @@ def compare_dirs(ref_dir: Path, cut_dir: Path): spinner() sleep(0.1) progressbar_update(count, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) results.get() diff --git a/other/lp16k.py b/other/lp16k.py index 451b83b861911e6890318bbdc03f6ac54072bb02..cec0394f140dbcf053e2af8db9390d2851807976 100755 --- a/other/lp16k.py +++ b/other/lp16k.py @@ -92,7 +92,7 @@ def main(args): spinner() sleep(0.1) progressbar_update(count, count, width) - print("\n", flush=True, file=sys.stdout) + print("", flush=True, file=sys.stdout) results.get() p.close()