From e95f041f500ba34118c3141ae7eaba383cb71c30 Mon Sep 17 00:00:00 2001 From: David GAILLETON Date: Mon, 9 Feb 2026 13:57:53 +0100 Subject: [PATCH] 04 finnish --- 04/ex4/ft_crisis_response.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 04/ex4/ft_crisis_response.py diff --git a/04/ex4/ft_crisis_response.py b/04/ex4/ft_crisis_response.py new file mode 100644 index 0000000..5165271 --- /dev/null +++ b/04/ex4/ft_crisis_response.py @@ -0,0 +1,31 @@ +def file_error_tester() -> None: + print("=== CYBER ARCHIVES - CRISIS RESPONSE SYSTEM ===\n") + try: + print("CRISIS ALERT: Attempting access to 'lost_archive.txt'...") + with open("lost_archive.txt") as file: + print("STATUS: Normal operations resumed") + except FileNotFoundError: + print("RESPONSE: Archive not found in storage matrix") + print("STATUS: Crisis handled, system stable") + print() + try: + print("CRISIS ALERT: Attempting access to 'classified_vault.txt'...") + with open("/bin/zsh", "w") as file: + print("STATUS: Normal operations resumed") + except PermissionError: + print("RESPONSE: Security protocols deny access") + print("STATUS: Crisis handled, security maintained") + print() + try: + print("ROUTINE ACCESS: Attempting access to 'standard_archive.txt'...") + with open("standard_archive.txt") as file: + print(f"SUCCESS: Archive recovered - ``{file.read()}''") + print("STATUS: Normal operations resumed") + except Exception as err: + print(err) + print("STATUS: Crisis handled, security maintained") + print("\nAll crisis scenarios handled successfully. Archives secure.") + + +if __name__ == "__main__": + file_error_tester()