From 649624fb255ac927b4efb2c1b4d65b725d7c20a4 Mon Sep 17 00:00:00 2001 From: bretello Date: Fri, 14 Jun 2024 20:07:50 +0200 Subject: [PATCH] fix check_call usages --- app.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 19af596..11b939b 100644 --- a/app.py +++ b/app.py @@ -24,8 +24,8 @@ def convert_to_wav(file_name: str): print(f"{extension=}") command = [ "tape2wav", - file_name, - f"${output}.wav", + os.path.join("uploads", file_name), + os.path.join("uploads", f"${output}.wav"), ] try: check_call(command) @@ -35,10 +35,13 @@ def convert_to_wav(file_name: str): def run_cassetta(cassetta: str): - command = f"aplay uploads/{cassetta}" + command = [ + "aplay", + os.path.join("uploads", cassetta), + ] try: - check_call(command.split()) + check_call(command) except CalledProcessError as exc: print(f"aplay failed: {exc.output=}\n{exc.stderr=}") @@ -72,7 +75,10 @@ def upload_file(): return "No file?" save_path = os.path.join("uploads", file.filename) - assert not os.path.exists(save_path) + if os.path.exists(save_path): + response = make_response(make_response("file already exists", 400)) + response.headers["Location"] = "/" + response.status_code = 400 try: file.save(save_path)