Skip to content

polished error capture of option 'Firewall-Status anzeigen' #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions SysScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import shutil
from colorama import init, Fore, Style
import sys

init(autoreset=True)

Expand Down Expand Up @@ -99,9 +100,13 @@ def check_open_ports():

def show_firewall_status():
try:
subprocess.run(["ufw", "status"], check = True, stderr=subprocess.DEVNULL, text=True)
except subprocess.CalledProcessError:
print(Fore.RED + "Um diese Aktion auszuführen, benötigen Sie Root-Rechte von Ihrem Betriebssystem. Führen Sie bitte „sudo python SysScope“ aus und wählen Sie 12. Firewall-Status anzeigen")
result = subprocess.run(["ufw", "status"], capture_output=True, text=True, check=True)
print(result.stdout)

except subprocess.CalledProcessError as e:
# Check if the error message is about missing root permissions
if "need to be root" in e.stderr.lower():
print(Fore.RED + "Um diese Aktion auszuführen, benötigen Sie Root-Rechte von Ihrem Betriebssystem. Führen Sie bitte „sudo python SysScope“ aus und wählen Sie 12. Firewall-Status anzeigen")


def show_system_time():
Expand Down Expand Up @@ -129,7 +134,11 @@ def menu():
for idx, option in enumerate(options, 1):
print(f"{idx}. {option}")

choice = input(Fore.YELLOW + "Wähle eine Option: ")
if not sys.stdin.isatty():
print("CI environment detected – skipping interactive menu.")
choice = 12
else:
choice = input(Fore.YELLOW + "Wähle eine Option: ")
functions = [
create_snapshot, show_events, check_sysconfig, list_snapshots, backup_snapshots,
check_disk_usage, show_processes, show_logs, show_network_connections, show_users,
Expand Down