48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
|
from playwright_stealth import stealth_sync
|
|
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
|
|
|
from actions.cards import daily_cards, more_cards, all_cards
|
|
from actions.login import login
|
|
from actions.websearch import pc_search
|
|
from tools.browser_config import create_display, start_browser
|
|
from tools.logger import *
|
|
import sys
|
|
import json
|
|
|
|
|
|
def check_config(data: dict) -> None:
|
|
info("Checking config file.")
|
|
try:
|
|
assert data["accounts"]["nb"] != 0, "No accounts found in the file"
|
|
for i in range(data["accounts"]["nb"]):
|
|
assert data["accounts"][str(i)]["mail"] != "", f"Account {i} has no mail."
|
|
assert data["accounts"][str(i)]["pwd"] != "", f"Account {i} has no password."
|
|
assert data["config"]["vnc_enabled"] in ["True", "False"], f"vnc_enable should be either True or False."
|
|
assert data["config"]["claim"] in ["True", "False"], f"claim should be either True or False."
|
|
assert 1024 < data["config"]["vnc_port"] < 65535, f"vnc_port should be a valid port."
|
|
assert data["config"]["vnc_port"] not in [1234], f"vnc_port should be different than the webserver's ports."
|
|
except AssertionError as e:
|
|
critical(e)
|
|
exit(1)
|
|
except KeyError as e:
|
|
critical(f"Malformed config file. Missing {e}. Refer to the example config file.")
|
|
exit(1)
|
|
info("Successfully Checked config.")
|
|
|
|
|
|
def load_parameters() -> dict:
|
|
parameters = sys.argv
|
|
if len(parameters) == 1:
|
|
critical("Started with no parameters. Please provide at least a config file.")
|
|
exit(1)
|
|
if len(parameters) > 2:
|
|
warning("Started with multiple parameters. Some will be ignored")
|
|
try:
|
|
with open(parameters[1], "r") as f:
|
|
data = json.load(f)
|
|
return data
|
|
except FileNotFoundError:
|
|
critical("Could not open the config file.")
|
|
exit(1)
|