From 34439b63571de5ea298361d7c39016387020cf26 Mon Sep 17 00:00:00 2001 From: schroef Date: Tue, 12 Nov 2024 15:00:27 -0400 Subject: [PATCH] Removed Simple updater ### Removed - Simple Updater, think about Blenders Extension Platform, easier method perhaps ### Fixed - poll issue with nodes light object > use different approach to get active node vs material --- CHANGELOG.md | 11 +++ README.md | 2 +- __init__.py | 66 +++++++++----- updater.py | 242 --------------------------------------------------- 4 files changed, 54 insertions(+), 267 deletions(-) delete mode 100644 updater.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a9c11e3..c7b82f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. +## [0.2.9] - 2024-11-08 + +### Removed + +- Simple Updater, think about Blenders Extension Platform, easier method perhaps + +### Fixed + +- poll issue with nodes light object > use different approach to get active node vs material + ## [0.2.8] - 2024-11-05 ### Fixed @@ -80,6 +90,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +[0.2.9]:https://github.com/schroef/Extra-Image-List/releases/tag/v0.2.9 [0.2.8]:https://github.com/schroef/Extra-Image-List/releases/tag/v0.2.8 [0.2.3]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.3 [0.2.2_2.80]:https://github.com/schroef/Extra-Image-List/releases/tag/v.0.2.2_2.80 diff --git a/README.md b/README.md index 108e47b..1defda7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ I added a cleaner look to the panel and added the panel settings to option bool. I also added source image so users can pick image sequence or sinle image. I Also added is showing the image texture name above its size, this is very convienent because the source path only shows a very small section. This makes it much easier to identify the used texture. -!['Preview extra imge list'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list-v028.jpg?2025-11-06) +!['Preview extra imge list'](https://raw.githubusercontent.com/wiki/schroef/extra-image-list/images/extra-image-list-v029.jpg?2025-11-12) ## Features diff --git a/__init__.py b/__init__.py index f27521c..db8c2eb 100644 --- a/__init__.py +++ b/__init__.py @@ -17,7 +17,17 @@ # Changelog -## v0.2.8 - 2024-11-05 +## [0.2.9] - 2024-11-12 + +### Removed + +- Updater, thing about Blenders Extension Platform, easier method perhaps + +### Fixed + +- poll issue with nodes light object > use different approach to get active node vs material + +## [0.2.8] - 2024-11-05 ### Fixed @@ -28,25 +38,25 @@ -Shortcut double Right Click to preview texture UV Editor > Double Left click -## v0.2.7 - 2022-05-16 +## 0.2.7] - 2022-05-16 ### Fixed - Poll isseu texture preview > #295 -## v0.2.6 - 2021-11-01 +## [0.2.6] - 2021-11-01 ### Fixed - Poll isseu texture preview -## v0.2.5 - 2021-07-29 +## [0.2.5] - 2021-07-29 ### Fixed - Panel issue difference 2.83 and 290 -## v0.2.4 - 2021-04-06 +## [0.2.4] - 2021-04-06 ### Added @@ -63,7 +73,7 @@ - List view updating with arrow buttons -## v0.2.3 - 2019-11-01 +## [0.2.3] - 2019-11-01 ### Fixed @@ -83,7 +93,7 @@ "category": "UV", "description": "An alternative image list for UV/Image Editor.", "location": "UV/Image Editor > Tools > Image List", - "version": (0, 2, 8), + "version": (0, 2, 9), "blender": (2, 80, 0), "wiki_url": "https://github.com/schroef/Extra-Image-List", "tracker_url": "https://github.com/schroef/Extra-Image-List/issues", @@ -110,9 +120,6 @@ PointerProperty ) from bpy.app.handlers import persistent - -from . import updater - #------------------------------------------------------------------------------- # UI PANEL - Extra Image List #------------------------------------------------------------------------------- @@ -324,6 +331,7 @@ class EIL_OT_UpdateNode(Operator): @classmethod def poll(cls, context): + aNode = None # print(bpy.context.active_object.active_material) # print(bpy.context.active_object.active_material.node_tree.nodes.active) # return context.active_node and context.active_node.type == 'TEX_IMAGE' @@ -331,21 +339,35 @@ def poll(cls, context): # return context.scene.node_tree.nodes.active and context.scene.node_tree.nodes.active.type == 'TEX_IMAGE' # return context.active_object.active_material.node_tree.nodes.active is not None # return context.active_node is not None - if bpy.context.active_object.active_material: - actN = bpy.context.active_object.active_material.node_tree.nodes.active - if actN.type=='GROUP': - actN = actN.node_tree.nodes.active + # actN = context.active_node + if bpy.context.active_object.type == 'LIGHT': + ntree = bpy.context.active_object.data.id_data.node_tree + aNode = ntree.nodes.active + else: + if bpy.context.active_object.active_material: + aNode = bpy.context.active_object.active_material.node_tree.nodes.active + if aNode!=None: + if aNode.type=='GROUP': + aNode = aNode.node_tree.nodes.active else: return False - # print(actN) - # print(actN.type) - return actN.type == 'TEX_IMAGE' and actN != None and bpy.context.active_object.active_material.node_tree.nodes + return aNode.type == 'TEX_IMAGE' and aNode != None #and bpy.context.active_object.active_material.node_tree.nodes def execute(self, context): + aNode = None # Get active node - aNode = context.active_object.active_material.node_tree.nodes.active - if aNode.type=='GROUP': - aNode = aNode.node_tree.nodes.active + if bpy.context.active_object.type == 'LIGHT': + ntree = bpy.context.active_object.data.id_data.node_tree + aNode = ntree.nodes.active + else: + if bpy.context.active_object.active_material: + aNode = bpy.context.active_object.active_material.node_tree.nodes.active + + # print(aNode.type) + # aNode = context.active_object.active_material.node_tree.nodes.active + if aNode!=None: + if aNode.type=='GROUP': + aNode = aNode.node_tree.nodes.active # Get list of all images img_list = list(bpy.data.images) @@ -640,8 +662,6 @@ def register(): bpy.types.Scene.extra_image_list = PointerProperty(type=ExtraImageList_Props) bpy.app.handlers.depsgraph_update_post.append(update_image_list) - updater.check(bl_info) - updater.register() # Add custom shortcut (image node double click) kc = bpy.context.window_manager.keyconfigs.addon @@ -651,8 +671,6 @@ def register(): icon_Load() def unregister(): - - updater.unregister() global custom_icons bpy.utils.previews.remove(custom_icons) diff --git a/updater.py b/updater.py deleted file mode 100644 index d2719f7..0000000 --- a/updater.py +++ /dev/null @@ -1,242 +0,0 @@ -import bpy -import os, platform, subprocess -#from ping3 import ping, verbose_ping -import urllib.request -import webbrowser -import ssl -import socket -import json -from bpy.props import (StringProperty, - BoolProperty, - IntProperty, - FloatProperty, - FloatVectorProperty, - EnumProperty, - PointerProperty, - ) -version = "" -urlPath = "" - -def check(bl_info): - global version, urlPath - vs = '' - version = bl_info["version"] - for v in version: - vs += str(v)+'.' - version = vs[:-1] - #urlPath = "https://gist.githubusercontent.com/schroef/4010a53b81200748af09b5abb9d24e88/raw/update_quickswitch.json" - #urlPath = "https://api.github.com/repos/schroef/Extra-Image-List/tags" - urlPath = "https://api.github.com/repos/schroef/Extra-Image-List/releases" - #urlPath = 'https://gist.githubusercontent.com/schroef/4010a53b81200748af09b5abb9d24e88/raw/5d552535e7f4f15d4d6494ba450ea88da2eeb756/update_quickswitch.json' - - -# Pin google -# https://stackoverflow.com/questions/2953462/pinging-servers-in-python -def is_connected(): - hostname = "www.google.com" - # Option for the number of packets as a function of - try: - if socket.gethostbyname(hostname): - return True - except: - return False -# param = '-n' if platform.system().lower()=='windows' else '-c' - -# # Building the command. Ex: "ping -c 1 google.com" -# command = ['ping', param, '1', hostname] -# if subprocess.call(command) == 0: -# return True -# else: -# return False - - -def get_json_from_remote(): - # Check if we make to much calls - # https://api.github.com/rate_limit - remote_json = "" # We clear it so it doesnt get cached - request = urllib.request.Request(urlPath) - try: - context = ssl._create_unverified_context() - except: - # some blender packaged python versions don't have this, largely - # useful for local network setups otherwise minimal impact - context = None - - if context: - result = urllib.request.urlopen(request, context=context) - else: - result = urllib.request.urlopen(request) - try: -# gcontext = ssl.SSLContext() # Only for gangstars this actually works -# with urllib.request.urlopen(urlPath, context=gcontext) as response: -# remote_json = response.read() - remote_json = result.read() - except urllib.request.HTTPError as err: - print('Could not read tags from server.') - print(err) - return None - tags_json = json.loads(remote_json) - return tags_json - - -def check_update_exist(): - tags_json = get_json_from_remote() - remote_ver_str = tags_json[0]['tag_name'].strip('v.') - release_notes = tags_json[0]['body'] - - installed_ver_float = str_version_to_float(version) - remote_ver_float = str_version_to_float(remote_ver_str) - return remote_ver_float > installed_ver_float, remote_ver_str, release_notes - -def get_latest_version_url(): - tags_json = get_json_from_remote() - if len(tags_json) == 0: - print('remote releases list is empty') - return None - zip_url = tags_json[0]['html_url'] - - return zip_url - -def str_version_to_float(ver_str): - repi = ver_str.partition('.') - cc = repi[0]+'.' + repi[2].replace('.', '') - return float(cc) - - -class EIS_AddonCheckUpdateExist(bpy.types.Operator): - bl_idname = "qs.check_for_update" - bl_label = "Check for update" - bl_description = "Check for update" - bl_options = {"REGISTER", "UNDO"} - - def execute(self, context): - eis = bpy.context.scene.eis_props - if not is_connected(): - eis.update_text = 'Make sure you are connected to internet' - return {'CANCELLED'} - - update_exist, remote_ver_str, release_notes = check_update_exist() - curr_ver_f = str_version_to_float(version) - rem_ver_f = str_version_to_float(remote_ver_str) - - if update_exist: - self.report({'INFO'}, f'Found new update: {remote_ver_str}') - eis.update_text = f'New update: {remote_ver_str}\nRelease notes:\n{release_notes}' - eis.update_exist = True - eis.show_getBtn = True - elif curr_ver_f == rem_ver_f: - self.report({'INFO'}, 'You have the latest version') - eis.update_text = f'You have the latest version: {version}\nRelease notes:\n{release_notes}' - eis.update_exist = False - eis.show_getBtn = False - elif curr_ver_f > rem_ver_f: - self.report({'INFO'}, 'You are ahead of official releases') - eis.update_text = f'You seem to be ahead of official releases\nYour version: {version}\nremote Version: {remote_ver_str}\nThere is nothing to download' - eis.update_exist = False - eis.show_getBtn = False - - return {"FINISHED"} - - - -class EIS_get_update(bpy.types.Operator): - """go to the new update""" - bl_idname="qs.get_update" - bl_label="Get Update" - - def execute(self, context): - webbrowser.open(get_latest_version_url()) - - -def updateHide(self,context): - scn = context.scene - eis = context.scene.eis_props - if self: - eis.hide_update = True - else: - eis.hide_update = False - eis.update_text = "" - - -class EIS_props(bpy.types.PropertyGroup): - update_check_int : IntProperty(name="Update Checker", default=0) - change_log_int : IntProperty(name="Changelog Checker", default=0) - update_exist: bpy.props.BoolProperty(name="Update Exist", description="New update avialable", default=False) - update_text: bpy.props.StringProperty(name="Update text", default='', update=updateHide) - hide_update: bpy.props.BoolProperty(name="Hide Updates", default=False) - show_getBtn: bpy.props.BoolProperty(name="Show get button", default=True) - - -# class EISPanel(bpy.types.Panel): -# """QuickSwitch panel in properties windows""" -# bl_label = "QuickSwitch" -# bl_idname = "EIS_PT_Panel" -# bl_space_type = 'PROPERTIES' -# bl_region_type = 'WINDOW' -# bl_context = "scene" -class EISPreferences(bpy.types.AddonPreferences): - bl_idname = 'Extra-Image-List' - - def draw(self, context): - layout = self.layout - scn = context.scene - eis = context.scene.eis_props - - layout.use_property_split = True - layout.use_property_decorate = False - col = layout.column(align=True) - - if eis.hide_update: - iconHide = 'HIDE_ON' - else: - iconHide = 'HIDE_OFF' - - - row = col.row(align=True) - row.operator(EIS_AddonCheckUpdateExist.bl_idname, text="check for updates", icon="FILE_REFRESH") - row.prop(eis,"hide_update", text='',icon=iconHide) - - if eis.update_text: # If there's a new Update - if eis.hide_update: - layout = layout.box() - col = layout.column(align=True) - sub_row = col.row(align=True) - split_lines_text = eis.update_text.splitlines() - for line in split_lines_text: - sub_row = col.row(align=True) - sub_row.label(text=line) - if eis.show_getBtn: - layout = self.layout - col = layout.column(align=True) - col.operator(EIS_get_update.bl_idname, icon="URL") - - -classes = [ - EISPreferences, - EIS_props, - EIS_AddonCheckUpdateExist, - EIS_get_update, -] - -def register(): - - for cls in classes: - bpy.utils.register_class(cls) - - bpy.types.Scene.eis_props = PointerProperty(type = EIS_props) - - - -def unregister(): - for cls in classes: - bpy.utils.unregister_class(cls) - - del bpy.types.Scene.eis_props - - -if __name__ == "__main__": - register() - - # test call -# bpy.ops.object.update_checker() -