From 8ab5de6b19c6ab06f23bd45631d8e7c9f7053373 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Fri, 29 Jul 2022 13:20:14 +0200 Subject: [PATCH] Fix unlinks --- great_ai/__main__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/great_ai/__main__.py b/great_ai/__main__.py index 3cc12be..9a16916 100644 --- a/great_ai/__main__.py +++ b/great_ai/__main__.py @@ -76,9 +76,13 @@ def serve() -> None: finally: if args.file_name.endswith(".ipynb"): - Path(get_script_name_of_notebook(args.file_name)).unlink( - missing_ok=True - ) + try: + Path(get_script_name_of_notebook(args.file_name)).unlink( + missing_ok=True + ) + except FileNotFoundError: + # missing_ok only exists >= Python 3.8 + pass else: class EventHandler(PatternMatchingEventHandler): @@ -124,9 +128,13 @@ def stop_server(self) -> None: observer.stop() restart_handler.stop_server() if args.file_name.endswith(".ipynb"): - Path(get_script_name_of_notebook(args.file_name)).unlink( - missing_ok=True - ) + try: + Path(get_script_name_of_notebook(args.file_name)).unlink( + missing_ok=True + ) + except FileNotFoundError: + # missing_ok only exists >= Python 3.8 + pass observer.join()