Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.31.1 #152

Merged
merged 14 commits into from
Mar 19, 2024
Prev Previous commit
Next Next commit
updated the update function
  • Loading branch information
Mustard2 committed Mar 10, 2024
commit e934f92ed675664ce27d5ec3abc005d9cbed9838
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": "MustardUI",
"description": "Easy-to-use UI for human characters.",
"author": "Mustard",
"version": (0, 31, 1, 1),
"version": (0, 31, 1, 3),
"blender": (4, 1, 0),
"warning": "",
"doc_url": "https://github.com/Mustard2/MustardUI/wiki",
Expand Down
46 changes: 36 additions & 10 deletions misc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,41 @@ def mustardui_retrieve_remote_version():
import requests

v = [0, 0, 0, 0]
b = [0, 0, 0]
data = None

# Import the data from the GitHub repository file
try:
response = requests.get("https://raw.githubusercontent.com/Mustard2/MustardUI/master/__init__.py")
data = response.text
except:
return 1, v
return 1, v, b

# Fetch version
try:
if '"version": (' in data:
if '"version": (' in data and '"blender": (' in data:
find = data.split('"version": (', 1)[1]
v[0] = int(find.split(',')[0])
v[1] = int(find.split(',')[1])
v[2] = int(find.split(',')[2])
v[3] = find.split(',')[3]
v[3] = int(v[3].split(')')[0])

return 0, v
find = data.split('"blender": (', 1)[1]
b[0] = int(find.split(',')[0])
b[1] = int(find.split(',')[1])
b[2] = find.split(',')[2]
b[2] = int(b[2].split(')')[0])

return 0, v, b
except:
pass

return 2, v
return 2, v, b


def mustardui_check_version():
exit_code, v = mustardui_retrieve_remote_version()
exit_code, v, b = mustardui_retrieve_remote_version()
version = (v[0], v[1], v[2], v[3])
if bl_info["version"] < version:
print("MustardUI - An update is available.")
Expand All @@ -51,6 +58,7 @@ class MustardUI_Updater(bpy.types.Operator):
bl_options = {'UNDO'}

v = [0, 0, 0, 0]
b = [0, 0, 0, 0]

@classmethod
def poll(cls, context):
Expand All @@ -59,17 +67,21 @@ def poll(cls, context):
def execute(self, context):

version = (self.v[0], self.v[1], self.v[2], self.v[3])
blender = (self.b[0], self.b[1], self.b[2])

if bl_info["version"] >= version:
self.report({'INFO'}, "MustardUI: The current version is already up-to-date")
else:
bpy.ops.mustardui.openlink(url="github.com/Mustard2/MustardUI/releases/latest")
if bpy.app.version >= blender:
bpy.ops.mustardui.openlink(url="github.com/Mustard2/MustardUI/releases/latest")
else:
bpy.ops.mustardui.openlink(url="blender.org/download/")

return {'FINISHED'}

def invoke(self, context, event):

exit_code, self.v = mustardui_retrieve_remote_version()
exit_code, self.v, self.b = mustardui_retrieve_remote_version()

if exit_code == 1:
self.report({'ERROR'}, "MustardUI: Error while retrieving remote version. Check your connection")
Expand All @@ -86,13 +98,18 @@ def draw(self, context):
layout = self.layout

version = (self.v[0], self.v[1], self.v[2], self.v[3])
blender = (self.b[0], self.b[1], self.b[2])

box = layout.box()

if bl_info["version"] >= version:
box.label(text="The current version seems up-to-date.", icon="INFO")
else:
box.label(text="Update available!", icon="INFO")
if bpy.app.version >= blender:
box.label(text="Update available!", icon="INFO")
else:
box.label(text="Update is available for a new Blender version!", icon="INFO")
box.label(text="Update Blender before installing the new MustardUI.", icon="INFO")

row = box.row()
row.label(text="Current version: ", icon="RIGHTARROW_THIN")
Expand All @@ -104,8 +121,17 @@ def draw(self, context):
text=str(self.v[0]) + '.' + str(self.v[1]) + '.' + str(self.v[2]) + '.' + str(self.v[3]))

if bl_info["version"] < version:
box = layout.box()
box.label(text="Click 'OK' to open the latest release page.", icon="ERROR")
if bpy.app.version >= blender:
box = layout.box()
box.label(text="Click 'OK' to open the latest release page.", icon="ERROR")
else:
row = box.row()
row.label(text="Minimum Blender version required: ", icon="WORLD")
row.label(
text=str(self.b[0]) + '.' + str(self.b[1]) + '.' + str(self.b[2]))

box = layout.box()
box.label(text="Click 'OK' to open the Blender download page.", icon="ERROR")


def register():
Expand Down