This commit is contained in:
2025-11-23 23:31:18 +08:00
parent d60cdc52fd
commit 9f7667a475
710 changed files with 252869 additions and 6 deletions

View File

@@ -0,0 +1,35 @@
import re
import webbrowser
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen # python2
from maya import cmds
from .dialog import UpdateAvailableDialog
from .appinfos import VERSION
from .optionvar import CHECK_FOR_UPDATE
APPINFOS_URL = (
'https://raw.githubusercontent.com/DreamWall-Animation/dwpicker/main/'
'dwpicker/appinfos.py')
LATEST_RELEASE_URL = (
'https://github.com/DreamWall-Animation/dwpicker/releases/latest')
VERSION_PATTERN = r'\d(\.|,).\d(\.|,).\d'
def warn_if_update_available():
if not cmds.optionVar(query=CHECK_FOR_UPDATE):
return
try:
appinfos = urlopen(APPINFOS_URL).read().decode()
latest_version_str = re.search(VERSION_PATTERN, appinfos)[0]
latest_version = tuple(
int(n) for n in latest_version_str.replace(',', '.').split('.'))
if VERSION < latest_version:
if UpdateAvailableDialog(latest_version_str).exec_():
webbrowser.open(LATEST_RELEASE_URL)
except BaseException:
print('DwPicker: could not check for new version')