Merge pull request #63 from PallasNeko/Remove_BeautifulSoup

Remove BeautifulSoup
This commit is contained in:
Prohurtz 2023-02-05 17:14:25 -06:00 committed by GitHub
commit 951cf7e624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,8 +7,7 @@ import queue
import threading
import PySimpleGUI as sg
import sys
from urllib.request import urlopen
from bs4 import BeautifulSoup
import urllib.request
import webbrowser
@ -53,23 +52,22 @@ def main():
if config.settings.gui_update_check:
print("\033[95m[INFO] Checking for updates...\033[0m")
url = "https://raw.githubusercontent.com/RedHawk989/EyeTrackVR-Installer/master/Version-Data/Version_Num.txt"
html = urlopen(url).read()
soup = BeautifulSoup(html, features="html.parser")
for script in soup(["script", "style"]):
script.extract()
text = soup.get_text()
# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())
# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
# drop blank lines
latestversion = '\n'.join(chunk for chunk in chunks if chunk)
req = urllib.request.Request(url)
try:
with urllib.request.urlopen(req, timeout=10) as res:
latestversion = res.read().decode("utf-8").strip()
except urllib.error.HTTPError as err:
print("Failed to check latest version.")
print("{} : {}".format(err.code,err.reason))
except urllib.error.URLError as err:
print("Failed to check latest version.")
print(err.reason)
else:
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")
else:
print(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"):
toaster = ToastNotifier()
toaster.show_toast( # show windows toast
@ -81,7 +79,6 @@ def main():
callback_on_click=open_url
)
# Check to see if we have an ROI. If not, bring up ROI finder GUI.
# Spawn worker threads