Update
This commit is contained in:
35
2023/scripts/animation_tools/dwpicker/updatechecker.py
Normal file
35
2023/scripts/animation_tools/dwpicker/updatechecker.py
Normal 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')
|
||||
Reference in New Issue
Block a user