Remove BeautifulSoup

This commit is contained in:
PallasNeko 2023-02-02 19:17:52 +09:00
parent 6e2f8b0847
commit 7e6f2a7199

View File

@ -7,8 +7,7 @@ import queue
import threading import threading
import PySimpleGUI as sg import PySimpleGUI as sg
import sys import sys
from urllib.request import urlopen import urllib.request
from bs4 import BeautifulSoup
import webbrowser import webbrowser
@ -53,35 +52,33 @@ def main():
if config.settings.gui_update_check: if config.settings.gui_update_check:
print("\033[95m[INFO] Checking for updates...\033[0m") print("\033[95m[INFO] Checking for updates...\033[0m")
url = "https://raw.githubusercontent.com/RedHawk989/EyeTrackVR-Installer/master/Version-Data/Version_Num.txt" url = "https://raw.githubusercontent.com/RedHawk989/EyeTrackVR-Installer/master/Version-Data/Version_Num.txt"
html = urlopen(url).read() req = urllib.request.Request(url)
soup = BeautifulSoup(html, features="html.parser") try:
for script in soup(["script", "style"]): with urllib.request.urlopen(req, timeout=10) as res:
script.extract() latestversion = res.read().decode("utf-8").strip()
text = soup.get_text() except urllib.error.HTTPError as err:
print("Failed to check latest version.")
# break into lines and remove leading and trailing space on each print("{} : {}".format(err.code,err.reason))
lines = (line.strip() for line in text.splitlines()) except urllib.error.URLError as err:
# break multi-headlines into a line each print("Failed to check latest version.")
chunks = (phrase.strip() for line in lines for phrase in line.split(" ")) print(err.reason)
# drop blank lines else:
latestversion = '\n'.join(chunk for chunk in chunks if chunk) if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date.
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m")
if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date. else:
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m") print(
else: f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m")
print(f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m") if sys.platform.startswith("win"):
if sys.platform.startswith("win"): toaster = ToastNotifier()
toaster = ToastNotifier() toaster.show_toast( # show windows toast
toaster.show_toast( #show windows toast "EyeTrackVR has an update.",
"EyeTrackVR has an update.", "Click to go to the latest version.",
"Click to go to the latest version.", icon_path="Images/logo.ico",
icon_path= "Images/logo.ico", duration=5,
duration=5, threaded=True,
threaded=True, callback_on_click=open_url
callback_on_click=open_url
) )
# Check to see if we have an ROI. If not, bring up ROI finder GUI. # Check to see if we have an ROI. If not, bring up ROI finder GUI.
# Spawn worker threads # Spawn worker threads