-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
56 lines (47 loc) · 1.6 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import time
from datetime import datetime
from playwright.sync_api import sync_playwright
import logging
from dotenv import load_dotenv
import os
from checker.sim24 import check_sim24
from checker.oneandone import check_1und1
load_dotenv()
SERVICE = os.getenv("SERVICE")
USERNAME = os.getenv("USERNAME")
PASSWORD = os.getenv("PASSWORD")
CHECK_INTERVAL = int(os.getenv("CHECK_INTERVAL"))
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - [%(prefix)s] %(message)s',
handlers=[
logging.FileHandler('automation.log'),
logging.StreamHandler()
]
)
class PrefixFilter(logging.Filter):
def __init__(self, prefix=""):
self.prefix = prefix
super().__init__()
def filter(self, record):
record.prefix = self.prefix
return True
logging.getLogger().addFilter(PrefixFilter(SERVICE))
def main():
logging.info("Starte Automatisierung...")
try:
if SERVICE == "sim24":
while True:
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
logging.info(f"Starte neue Überprüfung um {current_time}")
check_sim24(USERNAME, PASSWORD)
logging.info(f"Warte {CHECK_INTERVAL} Sekunden bis zur nächsten Überprüfung...")
time.sleep(CHECK_INTERVAL)
elif SERVICE == "1und1":
check_1und1(USERNAME, PASSWORD, CHECK_INTERVAL)
else:
logging.error(f"Unbekannte Service-ID: {SERVICE}")
except Exception as e:
logging.error(f"Fehler im Hauptprozess: {str(e)}")
if __name__ == "__main__":
main()