#!/usr/bin/env python3 # generate_spamcontrol_credentials.py # Skript zur Erstellung von Spam Control Zugangsdaten # Maintainer: peignerpausz # Version: 1.0.0 import csv import subprocess from pathlib import Path INPUT_CSV = "activation_overview.csv" OUTPUT_DIR = "spamcontrol_credentials" Path(OUTPUT_DIR).mkdir(exist_ok=True) for old_file in Path(OUTPUT_DIR).glob("*.txt"): old_file.unlink() with open(INPUT_CSV, newline="", encoding="utf-8") as f: reader = csv.DictReader(f) for row in reader: if row["product"] != "Spam Control": continue domain = row["domain"].strip() if not domain: print( f"Übersprungen (keine Domain): " f"Bestellung {row['order_no']}" ) continue try: password = ( subprocess.check_output( ["pwgen-tyhicks.pwgen", "-ya", "16", "1"], text=True ) .strip() ) except FileNotFoundError: print( "FEHLER: pwgen ist nicht installiert.\n" "Installation unter Ubuntu:\n" "sudo apt install pwgen" ) exit(1) customer_email = row.get( "customer_email", "" ).strip() content = f"""Login: {domain} PW: {password} E-Mail: {customer_email} """ safe_domain = ( domain .replace("/", "_") .replace("\\", "_") .replace(":", "_") ) filename = ( Path(OUTPUT_DIR) / f"{safe_domain}.txt" ) with open(filename, "w", encoding="utf-8") as out: out.write(content) print(f"Erstellt: {filename}") print("\nFertig.")