blenderbim addon updater accommodations

This commit is contained in:
Andrej730
2023-03-07 19:25:19 +05:00
parent 5630e9a0ad
commit 1cf11f7bb0
5 changed files with 67 additions and 10 deletions
+2
View File
@@ -36,9 +36,11 @@ if sys.modules.get("bpy", None):
# This is 3 levels deep as required by the static RPATH of ../../ from dependencies taken from Anaconda
site.addsitedir(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
import blenderbim.addon_updater_ops
import blenderbim.bim
def register():
blenderbim.addon_updater_ops.register(bl_info)
blenderbim.bim.register()
def unregister():
+1 -1
View File
@@ -1741,4 +1741,4 @@ class GitlabEngine:
# should be what's imported to other files
# -----------------------------------------------------------------------------
Updater = SingletonUpdater()
Updater = SingletonUpdater()
+23 -7
View File
@@ -72,7 +72,7 @@ except Exception as e:
# not match and have errors. Must be all lowercase and no spaces! Should also
# be unique among any other addons that could exist (using this updater code),
# to avoid clashes in operator registration.
updater.addon = "addon_updater_demo"
updater.addon = "blenderbim"
# -----------------------------------------------------------------------------
@@ -1284,6 +1284,12 @@ def skip_tag_function(self, tag):
# In all other cases, allow showing the tag for updating/reverting.
# To simply and always show all tags, this return False could be moved
# to the start of the function definition so all tags are allowed.
if not tag['name'].startswith('blenderbim-'):
return True
else:
version_number = tag['name'].split('-', 1)[1]
tag['name'] = 'v0.0.%s' % version_number
return False
@@ -1295,7 +1301,15 @@ def select_link_function(self, tag):
"""
# -- Default, universal case (and is the only option for GitLab/Bitbucket)
link = tag["zipball_url"]
# link = tag["zipball_url"]
# TODO: remove requests dependency?
# TODO: get repo name procedurally
# TODO: figure platform
tag_name = tag['name']
import requests
json_data = requests.get('https://api.github.com/repos/Ifcopenshell/Ifcopenshell/releases').json()
download_url = [release for release in json_data if release['tag_name'] == tag_name][0]['assets'][0]['browser_download_url']
# -- Example: select the first (or only) asset instead source code --
# if "assets" in tag and "browser_download_url" in tag["assets"][0]:
@@ -1313,7 +1327,7 @@ def select_link_function(self, tag):
# elif platform.system() == "Linux":
# link = [asset for asset in tag["assets"] if 'linux' in asset][0]
return link
return download_url
# -----------------------------------------------------------------------------
@@ -1353,20 +1367,22 @@ def register(bl_info):
updater.private_token = None # "tokenstring"
# Choose your own username, must match website (not needed for GitLab).
updater.user = "cgcookie"
updater.user = "IfcOpenShell"
# Choose your own repository, must match git name for GitHUb and Bitbucket,
# for GitLab use project ID (numbers only).
updater.repo = "blender-addon-updater"
updater.repo = "IfcOpenShell"
# updater.addon = # define at top of module, MUST be done first
# Website for manual addon download, optional but recommended to set.
updater.website = "https://github.com/CGCookie/blender-addon-updater/"
updater.website = "https://github.com/IfcOpenShell/IfcOpenShell/"
# Addon subfolder path.
# "sample/path/to/addon"
# default is "" or None, meaning root
# We leave this empty as we redefine `select_link_function`
# and will download the zip with addon, not the release source code
updater.subfolder_path = ""
# Used to check/compare versions.
@@ -1535,4 +1551,4 @@ def unregister():
ran_update_success_popup = False
global ran_background_check
ran_background_check = False
ran_background_check = False
@@ -21,7 +21,7 @@ from blenderbim.bim.helper import prop_with_search
from bpy.types import Panel, UIList
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.project.data import ProjectData
import blenderbim.addon_updater_ops
class BIM_PT_project(Panel):
bl_label = "IFC Project"
@@ -166,6 +166,9 @@ class BIM_PT_project(Panel):
row.operator("bim.unload_project", text="", icon="X")
def draw_create_project_ui(self, context):
blenderbim.addon_updater_ops.check_for_update_background()
blenderbim.addon_updater_ops.update_notice_box_ui(self, context)
props = context.scene.BIMProperties
pprops = context.scene.BIMProjectProperties
prop_with_search(self.layout, pprops, "export_schema")
+37 -1
View File
@@ -28,11 +28,11 @@ from ifcopenshell.util.doc import (
get_attribute_doc,
)
from . import ifc
import blenderbim.addon_updater_ops
import blenderbim.tool as tool
from blenderbim.bim.helper import IfcHeaderExtractor
from blenderbim.bim.prop import Attribute
class IFCFileSelector:
def is_existing_ifc_file(self, filepath=None):
if filepath is None:
@@ -123,6 +123,40 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
)
lock_grids_on_import: BoolProperty(name="Should Lock Grids By Default", default=True)
# addon updater preferences from `__init__`, be sure to copy all of them
auto_check_update : bpy.props.BoolProperty(
name = "Auto-check for Update",
description = "If enabled, auto-check for updates using an interval",
default = False,
)
updater_interval_months : bpy.props.IntProperty(
name='Months',
description = "Number of months between checking for updates",
default=0,
min=0
)
updater_interval_days : bpy.props.IntProperty(
name='Days',
description = "Number of days between checking for updates",
default=7,
min=0,
)
updater_interval_hours : bpy.props.IntProperty(
name='Hours',
description = "Number of hours between checking for updates",
default=0,
min=0,
max=23
)
updater_interval_minutes : bpy.props.IntProperty(
name='Minutes',
description = "Number of minutes between checking for updates",
default=0,
min=0,
max=59
)
def draw(self, context):
layout = self.layout
@@ -187,6 +221,8 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
row = layout.row()
row.operator("bim.configure_visibility")
blenderbim.addon_updater_ops.update_settings_ui(self, context)
def ifc_units(self, context):
scene = context.scene