From b6f5ba8b5b32fad29a54aa37e114cfc707027bd4 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 8 Feb 2022 21:26:12 +0800 Subject: [PATCH] afws_client: improve error message when output already exists --- artiq/frontend/afws_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/artiq/frontend/afws_client.py b/artiq/frontend/afws_client.py index f88fcada1..88bd8cdd3 100755 --- a/artiq/frontend/afws_client.py +++ b/artiq/frontend/afws_client.py @@ -132,8 +132,12 @@ def main(): try: os.mkdir(args.directory) except FileExistsError: - if any(os.scandir(args.directory)): - print("Output directory already exists and is not empty. Please remove it and try again.") + try: + if any(os.scandir(args.directory)): + print("Output directory already exists and is not empty. Please remove it and try again.") + sys.exit(1) + except NotADirectoryError: + print("A file with the same name as the output directory already exists. Please remove it and try again.") sys.exit(1) rev = args.rev if rev is None: