Skip to content

Commit

Permalink
update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
SiwatS committed Dec 10, 2023
1 parent 1420866 commit e393918
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/espmega_lightshow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import shutil
import traceback
import webbrowser
import subprocess

@dataclass
class PhysicalLightEntity:
Expand Down Expand Up @@ -1419,6 +1420,23 @@ def open_github():
company_label = ttk.Label(about_popup, text="SIWAT SYSTEM 2023")
company_label.pack()

# Check for updates using pip
def check_for_updates():
# Run pip in a subprocess
process = subprocess.Popen(["pip", "install", "--upgrade", "espmega-lightshow"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
# Check if pip returned an error
if process.returncode != 0:
messagebox.showerror("Update Error", f"An error occured while checking for updates.\n{stderr.decode('utf-8')}")
else:
return_message = stdout.decode("utf-8")
print(return_message)
# Check if pip returned a message
if ("Requirement already satisfied: espmega-lightshow" in return_message):
messagebox.showinfo("Update", "No updates found.")
else:
messagebox.showinfo("Update", "Update found.\nPlease restart the program to apply the update.")

# Create the help menu
help_menu = tk.Menu(menu_bar, tearoff=False)
help_menu.add_command(label="About", command=open_about_popup)
Expand Down

0 comments on commit e393918

Please sign in to comment.