update main.py
This commit is contained in:
72
main.py
72
main.py
@@ -1,4 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
"""
|
||||||
macOS Setup Wizard - Automatisierte Installation und Konfiguration
|
macOS Setup Wizard - Automatisierte Installation und Konfiguration
|
||||||
Erstellt Verzeichnisse und installiert Apps aus einer JSON-Repository-Liste
|
Erstellt Verzeichnisse und installiert Apps aus einer JSON-Repository-Liste
|
||||||
@@ -12,6 +11,10 @@ import urllib.request
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
|
||||||
|
class Url:
|
||||||
|
DIRECTORIES = "https://raw.githubusercontent.com/VoidEUW/mac/refs/heads/main/v1/directories.json"
|
||||||
|
APPS = "https://raw.githubusercontent.com/VoidEUW/mac/refs/heads/main/v1/apps.json"
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
"""ANSI Farbcodes für Terminal-Ausgabe"""
|
"""ANSI Farbcodes für Terminal-Ausgabe"""
|
||||||
HEADER = '\033[95m'
|
HEADER = '\033[95m'
|
||||||
@@ -25,14 +28,22 @@ class Colors:
|
|||||||
|
|
||||||
class MacSetupWizard:
|
class MacSetupWizard:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.directories: List[str] = [
|
self.directories: List[str] = []
|
||||||
'~/Development',
|
|
||||||
'~/Development/Projects',
|
|
||||||
'~/Development/Tools',
|
|
||||||
'~/Documents/Work'
|
|
||||||
]
|
|
||||||
self.apps: List[Dict[str, str]] = []
|
self.apps: List[Dict[str, str]] = []
|
||||||
self.selected_apps: List[str] = []
|
self.selected_apps: List[str] = []
|
||||||
|
self.get_directories()
|
||||||
|
|
||||||
|
def get_directories(self) -> None:
|
||||||
|
"""Lädt die Verzeichnisse aus der JSON-Datei"""
|
||||||
|
try:
|
||||||
|
print(f"\n{Colors.YELLOW}Lade Directories...{Colors.END}")
|
||||||
|
with urllib.request.urlopen(Url.DIRECTORIES) as response:
|
||||||
|
data = json.loads(response.read().decode())
|
||||||
|
self.directories = data.get('directories', [])
|
||||||
|
print(f"{Colors.GREEN}✓ {len(self.directories)} Directories geladen{Colors.END}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"{Colors.RED}✗ Fehler beim Laden der Verzeichnisse: {e}{Colors.END}")
|
||||||
|
self.directories = []
|
||||||
|
|
||||||
def clear_screen(self):
|
def clear_screen(self):
|
||||||
"""Terminal-Bildschirm leeren"""
|
"""Terminal-Bildschirm leeren"""
|
||||||
@@ -116,8 +127,6 @@ class MacSetupWizard:
|
|||||||
self.print_header("macOS Setup Wizard")
|
self.print_header("macOS Setup Wizard")
|
||||||
self.print_step(2, 4, "Apps-Liste laden")
|
self.print_step(2, 4, "Apps-Liste laden")
|
||||||
|
|
||||||
default_url = "https://raw.githubusercontent.com/username/repo/main/apps.json"
|
|
||||||
|
|
||||||
print(f"{Colors.YELLOW}Beispiel JSON-Format:{Colors.END}")
|
print(f"{Colors.YELLOW}Beispiel JSON-Format:{Colors.END}")
|
||||||
print(json.dumps({
|
print(json.dumps({
|
||||||
"apps": [
|
"apps": [
|
||||||
@@ -132,7 +141,7 @@ class MacSetupWizard:
|
|||||||
}, indent=2))
|
}, indent=2))
|
||||||
|
|
||||||
print(f"\n{Colors.CYAN}Repository-URL:{Colors.END}")
|
print(f"\n{Colors.CYAN}Repository-URL:{Colors.END}")
|
||||||
repo_url = input(f"[{default_url}]: ").strip() or default_url
|
repo_url = input(f"[{Url.APPS}]: ").strip() or Url.APPS
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print(f"\n{Colors.YELLOW}Lade Apps-Liste...{Colors.END}")
|
print(f"\n{Colors.YELLOW}Lade Apps-Liste...{Colors.END}")
|
||||||
@@ -142,51 +151,10 @@ class MacSetupWizard:
|
|||||||
print(f"{Colors.GREEN}✓ {len(self.apps)} Apps geladen{Colors.END}")
|
print(f"{Colors.GREEN}✓ {len(self.apps)} Apps geladen{Colors.END}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{Colors.RED}✗ Fehler beim Laden: {e}{Colors.END}")
|
print(f"{Colors.RED}✗ Fehler beim Laden: {e}{Colors.END}")
|
||||||
print(f"{Colors.YELLOW}Verwende Demo-Daten...{Colors.END}")
|
self.apps = []
|
||||||
self.apps = self.get_demo_apps()
|
|
||||||
|
|
||||||
input(f"\n{Colors.GREEN}Enter drücken um fortzufahren...{Colors.END}")
|
input(f"\n{Colors.GREEN}Enter drücken um fortzufahren...{Colors.END}")
|
||||||
|
|
||||||
def get_demo_apps(self) -> List[Dict[str, str]]:
|
|
||||||
"""Demo-Apps für Testzwecke"""
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
"id": "homebrew",
|
|
||||||
"name": "Homebrew",
|
|
||||||
"url": "https://brew.sh",
|
|
||||||
"type": "script",
|
|
||||||
"install_command": '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "vscode",
|
|
||||||
"name": "Visual Studio Code",
|
|
||||||
"url": "https://code.visualstudio.com",
|
|
||||||
"type": "brew",
|
|
||||||
"install_command": "brew install --cask visual-studio-code"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "git",
|
|
||||||
"name": "Git",
|
|
||||||
"url": "https://git-scm.com",
|
|
||||||
"type": "brew",
|
|
||||||
"install_command": "brew install git"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "docker",
|
|
||||||
"name": "Docker Desktop",
|
|
||||||
"url": "https://www.docker.com/products/docker-desktop",
|
|
||||||
"type": "brew",
|
|
||||||
"install_command": "brew install --cask docker"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "iterm2",
|
|
||||||
"name": "iTerm2",
|
|
||||||
"url": "https://iterm2.com",
|
|
||||||
"type": "brew",
|
|
||||||
"install_command": "brew install --cask iterm2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
def step_select_apps(self):
|
def step_select_apps(self):
|
||||||
"""Schritt 3: Apps zur Installation auswählen"""
|
"""Schritt 3: Apps zur Installation auswählen"""
|
||||||
self.clear_screen()
|
self.clear_screen()
|
||||||
|
|||||||
Reference in New Issue
Block a user