-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (38 loc) · 1.39 KB
/
Copy pathmain.py
File metadata and controls
56 lines (38 loc) · 1.39 KB
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
"""Application entry point."""
from __future__ import annotations
import importlib.util
import os
import subprocess
import sys
from pathlib import Path
REQUIRED_MODULES = (
"requests",
"certifi",
"cryptography",
"dns",
"whois",
)
def auto_install_requirements() -> None:
"""Install requirements.txt automatically when modules are missing."""
if getattr(sys, "frozen", False) or os.environ.get("HTTPS_CHECKER_SKIP_AUTO_INSTALL") == "1":
return
missing = [module for module in REQUIRED_MODULES if importlib.util.find_spec(module) is None]
if not missing:
return
requirements_path = Path(__file__).with_name("requirements.txt")
if not requirements_path.exists():
raise RuntimeError(f"Missing requirements file: {requirements_path}")
print("Missing Python packages detected:")
for module in missing:
print(f" - {module}")
print("\nInstalling requirements automatically. This may take a few minutes...\n")
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", str(requirements_path)])
def main() -> None:
"""Start the Windows console application."""
auto_install_requirements()
from app.console import HTTPSCheckerConsole
app = HTTPSCheckerConsole()
app.run()
if __name__ == "__main__":
main()