Skip to content

Commit

Permalink
Merge pull request #332 from TheDuckCow/dev
Browse files Browse the repository at this point in the history
Dev to master for v3.4.1
  • Loading branch information
TheDuckCow committed Aug 11, 2022
2 parents 29a4531 + 25ba829 commit 0e7459a
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 163 deletions.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion MCprep_addon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
bl_info = {
"name": "MCprep",
"category": "Object",
"version": (3, 4, 0),
"version": (3, 4, 0, 1),
"blender": (2, 80, 0),
"location": "3D window toolshelf > MCprep tab",
"description": "Minecraft workflow addon for rendering and animation",
Expand Down
71 changes: 35 additions & 36 deletions MCprep_addon/addon_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
https://github.com/CGCookie/blender-addon-updater
"""

__version__ = "1.1.0"
__version__ = "1.1.1"

import errno
import traceback
Expand Down Expand Up @@ -910,42 +910,41 @@ def unpack_staged_zip(self, clean=False):

self.print_verbose(
"Begin extracting source from zip:" + str(self._source_zip))
zfile = zipfile.ZipFile(self._source_zip, "r")

if not zfile:
self._error = "Install failed"
self._error_msg = "Resulting file is not a zip, cannot extract"
self.print_verbose(self._error_msg)
return -1
with zipfile.ZipFile(self._source_zip, "r") as zfile:
if not zfile:
self._error = "Install failed"
self._error_msg = "Resulting file is not a zip, cannot extract"
self.print_verbose(self._error_msg)
return -1

# Now extract directly from the first subfolder (not root)
# this avoids adding the first subfolder to the path length,
# which can be too long if the download has the SHA in the name.
zsep = '/' # Not using os.sep, always the / value even on windows.
for name in zfile.namelist():
if zsep not in name:
continue
top_folder = name[:name.index(zsep) + 1]
if name == top_folder + zsep:
continue # skip top level folder
sub_path = name[name.index(zsep) + 1:]
if name.endswith(zsep):
try:
os.mkdir(os.path.join(outdir, sub_path))
self.print_verbose(
"Extract - mkdir: " + os.path.join(outdir, sub_path))
except OSError as exc:
if exc.errno != errno.EEXIST:
self._error = "Install failed"
self._error_msg = "Could not create folder from zip"
self.print_trace()
return -1
else:
with open(os.path.join(outdir, sub_path), "wb") as outfile:
data = zfile.read(name)
outfile.write(data)
self.print_verbose(
"Extract - create: " + os.path.join(outdir, sub_path))
# Now extract directly from the first subfolder (not root)
# this avoids adding the first subfolder to the path length,
# which can be too long if the download has the SHA in the name.
zsep = '/' # Not using os.sep, always the / value even on windows.
for name in zfile.namelist():
if zsep not in name:
continue
top_folder = name[:name.index(zsep) + 1]
if name == top_folder + zsep:
continue # skip top level folder
sub_path = name[name.index(zsep) + 1:]
if name.endswith(zsep):
try:
os.mkdir(os.path.join(outdir, sub_path))
self.print_verbose(
"Extract - mkdir: " + os.path.join(outdir, sub_path))
except OSError as exc:
if exc.errno != errno.EEXIST:
self._error = "Install failed"
self._error_msg = "Could not create folder from zip"
self.print_trace()
return -1
else:
with open(os.path.join(outdir, sub_path), "wb") as outfile:
data = zfile.read(name)
outfile.write(data)
self.print_verbose(
"Extract - create: " + os.path.join(outdir, sub_path))

self.print_verbose("Extracted source")

Expand Down
15 changes: 14 additions & 1 deletion MCprep_addon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def init():
# Used to print out extra information, set false with distribution
# -----------------------------------------------
global dev
dev = False
dev = True

global v
v = True # $VERBOSE, UI setting
Expand Down Expand Up @@ -189,6 +189,19 @@ def log(statement, vv_only=False):
print(statement)


def updater_select_link_function(self, tag):
"""Indicates what zip file to use for updating from a tag structure.
Injected function to avoid being overwritten in future updates.
"""
link = tag["zipball_url"] # Fallback is full source code.

# However, prefer puling the uploaded addon zip build.
if "assets" in tag and "browser_download_url" in tag["assets"][0]:
link = tag["assets"][0]["browser_download_url"]
return link


# -----------------------------------------------------------------------------
# GLOBAL REGISTRATOR INIT
# -----------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion MCprep_addon/load_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
world_tools,
# bridge,
mcprep_ui,
optimize_scene
optimize_scene
)


Expand All @@ -180,6 +180,9 @@ def register(bl_info):
# addon updater code and configurations
addon_updater_ops.register(bl_info)

# Inject the custom updater function, to use release zip instead src.
addon_updater_ops.updater.select_link = conf.updater_select_link_function

conf.log("MCprep: Verbose is enabled")
conf.log("MCprep: Very Verbose is enabled", vv_only=True)

Expand Down
18 changes: 17 additions & 1 deletion MCprep_addon/spawner/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ def load_geonode_effect_list(context):
path = context.scene.mcprep_effects_path
path = os.path.join(path, "geonodes")

if not os.path.isdir(path):
print("The geonode directory is missing! Reinstall MCprep")
print(path)
return

# Find all files with geonodes.
blends = [
os.path.join(path, blend) for blend in os.listdir(path)
Expand Down Expand Up @@ -834,6 +839,11 @@ def load_area_particle_effects(context):
path = context.scene.mcprep_effects_path
path = os.path.join(path, "particle")

if not os.path.isdir(path):
print("The particle directory is missing! Reinstall MCprep")
print(path)
return

# Find all files with geonodes.
blends = [
os.path.join(path, blend) for blend in os.listdir(path)
Expand Down Expand Up @@ -862,6 +872,11 @@ def load_collection_effects(context):
path = context.scene.mcprep_effects_path
path = os.path.join(path, "collection")

if not os.path.isdir(path):
print("The collection directory is missing! Reinstall MCprep")
print(path)
return

# Find all files with geonodes.
blends = [
os.path.join(path, blend) for blend in os.listdir(path)
Expand Down Expand Up @@ -894,7 +909,8 @@ def load_image_sequence_effects(context):
lvl_3 = os.path.join(resource_folder, "assets", "minecraft", "textures", "particle")

if not os.path.isdir(resource_folder):
conf.log("Error, resource folder does not exist")
conf.log(
"The particle resource directory is missing! Assign another resource pack")
return
elif os.path.isdir(lvl_0):
resource_folder = lvl_0
Expand Down
Loading

0 comments on commit 0e7459a

Please sign in to comment.