-
Notifications
You must be signed in to change notification settings - Fork 7
Slightly Nicer Windows Experience #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
854577b
b323f04
6319bf8
02d2332
f6d8c09
155f8b1
7581a52
f42bb2c
8de2e71
21b2c0c
0406cf4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env python | ||
| #******************************************************* | ||
| # Copyright (c) MLRS project | ||
| # GPL3 | ||
| # https://www.gnu.org/licenses/gpl-3.0.de.html | ||
| #******************************************************* | ||
| # Win Launcher | ||
| #******************************************************** | ||
|
|
||
| import subprocess | ||
| import os | ||
|
|
||
| def setup_virtualenv(): | ||
| """Creates and sets up a virtual environment using venv.""" | ||
| # Create virtual environment | ||
| subprocess.run(["python", "-m", "venv", "venv"], check=True) | ||
| print("Virtual environment created.") | ||
|
|
||
| # Upgrade pip | ||
| subprocess.run(["venv\\Scripts\\python", "-m", "pip", "install", "--upgrade", "pip"], check=True) | ||
| print("Pip upgraded.") | ||
|
|
||
| # Install required modules | ||
| subprocess.run(["venv\\Scripts\\python", "-m", "pip", "install", "pillow", "requests", "pyserial", "customtkinter", "tk"], check=True) | ||
| print("Required modules installed.") | ||
|
|
||
| def run_flasher(): | ||
| """Runs the mLRS_Flasher.py script within the virtual environment.""" | ||
| subprocess.run(["venv\\Scripts\\pythonw", "mLRS_Flasher.py"], check=True) | ||
| print("mLRS_Flasher.py executed successfully.") | ||
|
|
||
| if __name__ == "__main__": | ||
| # Check if venv folder exists before running run_flasher | ||
| if os.path.isdir("venv"): | ||
| print("Virtual environment found, running flasher script...") | ||
| run_flasher() | ||
| else: | ||
| print("Virtual environment not found. Setting up virtual environment...") | ||
| setup_virtualenv() | ||
| run_flasher() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,11 @@ | |
| # OlliW @ www.olliw.eu | ||
| #************************************************************ | ||
| # mLRS Flasher Desktop App | ||
| # 11. Apr. 2025 001 | ||
| # 13. Apr. 2025 001 | ||
| #************************************************************ | ||
| app_version = '11.04.2025-001' | ||
| app_version = '13.04.2025-001' | ||
|
|
||
| import os, sys, time | ||
| import os, platform, sys, time | ||
| import subprocess | ||
| import re | ||
|
|
||
|
|
@@ -29,6 +29,69 @@ | |
| import apInitPassthru as appassthru | ||
| import edgetxInitPassthru as radio | ||
|
|
||
| ''' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I would like to have the venev section be moved to the last before the if main |
||
| -------------------------------------------------- | ||
| Venv | ||
| -------------------------------------------------- | ||
| ''' | ||
|
|
||
| def setup_virtualenv_win(): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems to me that the three can be largely slimmed down to essentially only one pl don't use """ or ''' for inline comments (I often use that to uncomment blocks and it just makes things screwy) |
||
| """Creates and sets up a virtual environment using venv.""" | ||
| # Create virtual environment | ||
| subprocess.run(["python", "-m", "venv", "venv"], check=True) | ||
| print("Virtual environment created.") | ||
|
|
||
| # Upgrade pip | ||
| subprocess.run(["venv\\Scripts\\python", "-m", "pip", "install", "--upgrade", "pip"], check=True) | ||
| print("Pip upgraded.") | ||
|
|
||
| # Install required modules | ||
| subprocess.run(["venv\\Scripts\\python", "-m", "pip", "install", "pillow", "requests", "pyserial", "customtkinter", "tk"], check=True) | ||
| print("Required modules installed.") | ||
|
|
||
| def setup_virtualenv_mac(): | ||
| """Recursively removes the quarantine attribute from all files in the given directory.""" | ||
| for root, dirs, files in os.walk(os.getcwd()): | ||
| for name in dirs + files: | ||
| file_path = os.path.join(root, name) | ||
| try: | ||
| subprocess.run(["xattr", "-d", "com.apple.quarantine", file_path], check=True, stderr=subprocess.DEVNULL) | ||
| print(f"Removed quarantine from: {file_path}") | ||
| except subprocess.CalledProcessError: | ||
| print(f"Failed to remove quarantine from: {file_path}") | ||
|
|
||
| """Creates and sets up a virtual environment using virtualenv.""" | ||
| subprocess.run(["virtualenv", "--python=/opt/homebrew/bin/python3", "venv"], check=True) | ||
| print("Virtual environment created using Homebrew's Python.") | ||
|
|
||
| subprocess.run(["venv/bin/python", "-m", "pip", "install", "--upgrade", "pip"], check=True) | ||
| print("Pip upgraded.") | ||
|
|
||
| subprocess.run(["venv/bin/python", "-m", "pip", "install", "pillow", "requests", "pyserial", "customtkinter", "tk"], check=True) | ||
| print("Required modules installed including Tkinter in virtual environment.") | ||
|
|
||
| subprocess.run(["brew", "install", "python-tk"], check=True) | ||
| print("python-tk installed via Homebrew.") | ||
|
|
||
| def setup_virtualenv_linux(): | ||
| """Creates and sets up a virtual environment using venv on Linux.""" | ||
| # Create virtual environment | ||
| subprocess.run(["python3", "-m", "venv", "venv"], check=True) | ||
| print("Virtual environment created.") | ||
|
|
||
| # Upgrade pip | ||
| subprocess.run(["venv/bin/python", "-m", "pip", "install", "--upgrade", "pip"], check=True) | ||
| print("Pip upgraded.") | ||
|
|
||
| # Install required modules | ||
| subprocess.run(["venv/bin/python", "-m", "pip", "install", "pillow", "requests", "pyserial", "customtkinter", "tk"], check=True) | ||
| print("Required modules installed.") | ||
|
|
||
| ''' | ||
| -------------------------------------------------- | ||
| Tools | ||
| -------------------------------------------------- | ||
| ''' | ||
|
|
||
| ctk.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue" | ||
| #ctk.set_default_color_theme("green") | ||
|
|
@@ -1914,6 +1977,16 @@ def fLuaScript_Download_button_event(self): | |
| #-------------------------------------------------- | ||
|
|
||
| if __name__ == "__main__": | ||
| if os.path.isdir("venv"): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a if not os.path.dir('venv') is sufficient (btw I prefer using '' over "" when possible) |
||
| print("Virtual environment found, running flasher script...") | ||
| else: | ||
| if platform.system() == 'Windows': | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we please separate that by os.name == 'posix' and then do the subselection using platform.system() reason is that in other parts of the code it splices by os.name, want to keep it coherent |
||
| setup_virtualenv_win() | ||
| elif platform.system() == 'Darwin': | ||
| setup_virtualenv_mac() | ||
| elif platform.system() == 'Linux': | ||
| setup_virtualenv_linux() | ||
|
|
||
| app = App() | ||
| app.update() | ||
| app.after(10,app.after_startup()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe