-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivate.py
More file actions
48 lines (35 loc) · 1.46 KB
/
Activate.py
File metadata and controls
48 lines (35 loc) · 1.46 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
import os
import sys
import subprocess
from venv import EnvBuilder
def create_virtual_env(env_dir: str):
print(f"Creating virtual environment in '{env_dir}'...")
builder = EnvBuilder(with_pip=True)
builder.create(env_dir)
def install_requirements(python_executable: str, requirements_file: str = "requirements.txt"):
if os.path.exists(requirements_file):
print(f"Installing requirements from '{requirements_file}'...")
subprocess.check_call([python_executable, '-m', 'pip', 'install', '-r', requirements_file])
else:
print(f"{requirements_file} not found. Make sure it exists in the current directory.")
def run_script(python_executable: str, script: str):
if not os.path.exists(script):
print(f"{script} not found. Cannot run.")
sys.exit(1)
print(f"Starting '{script}'...")
subprocess.check_call([python_executable, script])
def main():
env_dir = 'lupusG2FA_venv'
# Step 1: Create virtual environment
create_virtual_env(env_dir)
# Determine the path to the venv's Python executable
if os.name == 'nt':
python_exec = os.path.join(env_dir, 'Scripts', 'python.exe')
else:
python_exec = os.path.join(env_dir, 'bin', 'python')
# Step 2: Install requirements
install_requirements(python_exec)
# Step 3: Run the 2FA_TUI.py script
run_script(python_exec, 'LupusG2FA.py')
if __name__ == '__main__':
main()