Files
spotify-gui/update.py
Brandon4466 cf6f02acd1 updated background dominant color calculation
reworked updater to work as handler, will restart if exception
2023-03-27 00:13:26 -07:00

34 lines
821 B
Python

import urllib
from urllib.request import urlopen
from zipfile import ZipFile
from io import BytesIO
from time import sleep
import subprocess
while True:
try:
urlopen('http://bbrunson.com', timeout=1)
print("Connection to server established.")
break
except:
pass
try:
print("Checking for updates...")
with ZipFile(BytesIO((urlopen('http://files.bbrunson.com/spotify-gui/update.zip')).read())) as zipObj:
zipObj.extractall()
print("Update successfully installed.")
except urllib.error.HTTPError:
print("No update available.")
pass
while True:
try:
subprocess.check_call(['python', 'spotifycontroller.py'])
except:
print("An error has ocurred, reestablishing the application in 10 seconds.")
sleep(10)
continue