Skip to content

Commit

Permalink
Update open.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KorryKatti committed Apr 8, 2024
1 parent 5faa857 commit 5721c41
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions open.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ def create_venv(directory):

# Function to install customtkinter (assuming it's a package)
def install_customtkinter(venv_directory):
os.system(f"{os.path.join(venv_directory, 'bin', 'python')} -m pip install customtkinter")
os.system(f"{os.path.join(venv_directory, 'bin', 'python' if os.name != 'nt' else 'Scripts', 'pip')} install customtkinter")

# Function to activate the virtual environment on Windows
def activate_venv_windows(directory):
activate_script = os.path.join(directory, "Scripts", "activate")
return f"call {activate_script}"

# Function to activate the virtual environment on Linux
def activate_venv_linux(directory):
activate_script = os.path.join(directory, "bin", "activate")
return f"source {activate_script}"
# Function to activate the virtual environment
def activate_venv(directory):
if os.name == 'nt':
activate_script = os.path.join(directory, "Scripts", "activate")
return f"call {activate_script}"
else:
activate_script = os.path.join(directory, "bin", "activate")
return f"source {activate_script}"

# Function to run main.py or updater.py using the Python interpreter from the virtual environment
def run_script_py(venv_directory, script_name):
Expand All @@ -70,7 +69,7 @@ def main():
# Check if customtkinter is importable
import customtkinter
except ImportError:
activate_command = activate_venv_windows(venv_directory) if os.name == 'nt' else activate_venv_linux(venv_directory)
activate_command = activate_venv(venv_directory)
try:
subprocess.run(f"{activate_command} && python updater.py", shell=True)
except Exception as e:
Expand Down

0 comments on commit 5721c41

Please sign in to comment.