mirror of
https://github.com/EyeTrackVR/EyeTrackVR.git
synced 2025-11-04 14:39:42 +08:00
Merge pull request #63 from PallasNeko/Remove_BeautifulSoup
Remove BeautifulSoup
This commit is contained in:
commit
951cf7e624
@ -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,23 +52,22 @@ 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.
|
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")
|
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m")
|
||||||
else:
|
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"):
|
if sys.platform.startswith("win"):
|
||||||
toaster = ToastNotifier()
|
toaster = ToastNotifier()
|
||||||
toaster.show_toast( # show windows toast
|
toaster.show_toast( # show windows toast
|
||||||
@ -81,7 +79,6 @@ def main():
|
|||||||
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user