mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
04 finnish
This commit is contained in:
31
04/ex4/ft_crisis_response.py
Normal file
31
04/ex4/ft_crisis_response.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user