Giter Site home page Giter Site logo

blender-addon-updater's Introduction

Blender Addon Updater

With this Python module, developers can create auto-checking for updates with their blender addons as well as one-click version installs. Updates are retrieved using GitHub's, GitLab's, or Bitbucket's code api, so the addon must have it's updated code available on GitHub/GitLab/Bitbucket and be making use of either tags or releases.

alt

⚠️ Please see this page on known issues, including available workarounds

Want to add this code to your addon? See this tutorial here

This addon has been updated and still works from Blender 2.7 through 3.0, see this section below.

Key Features

From the user perspective

  • Uses GitHub, GitLab or Bitbucket repositories for source of versions and code
    • All mentions of GitHub hereafter also apply to GitLab and Bitbucket unless called out separately
  • One-click to check if update is available
  • Auto-check: Ability to automatically check for updates in the background (user must enable)
  • Ability to set the interval of time between background checks (if auto-check enabled)
  • On a background check for update, contextual popup to tell user update available
  • One-click button to install update
  • Ability to install other (e.g. older or dev) versions of the addon

With this module, there are essentially 3 different configurations:

  • Connect an addon to a repository's releases & be notified when new releases are out and allow 1-click install (with an option to install master or another branch if enabled)
  • Connect an addon to a repository's releases & be notified when new releases are out, but direct user to website or specific download page instead of one-click installing (code doesn't even need to be hosted in connected repo in this scenario, as it's only using the releases metadata)
  • Connect an addon to a repository that doesn't have any releases, and allow use to 1-click install to a default branch and select from other explicitly included branches to install (does not us any version checking, will always pull the latest code even if the same)

Note the repository is not currently setup to be used with single Python file addons, this must be used with a zip-installed addon. It also assumes the use of the user preferences panel dedicated to the addon.

High level setup

This module works by utilizing git releases on a repository. When a release or tag is created on GitHub/Bitbucket/Gitlab, the addon can check against the name of the tags/releases to know if an update is ready. The local addon version (in bl_info) is used to compare against that online name to know whether a more recent release is ready.

alt

This repository contains a fully working example of an addon with the updater code, but to integrate into another or existing addon, only the addon_updater.py and addon_updater_ops.py files are needed.

addon_updater.py is an independent Python module that is the brains of the updater. It is implemented as a singleton, so the module-level variables are the same wherever it is imported. This file should not need to be modified by a developer looking to integrate auto-updating into an addon. Local "private" variables starting with _ have corresponding @property interfaces for interacting with the singleton instance's variables.

addon_updater_ops.py links the states and settings of the addon_updater.py module and displays the according interface. This file is expected to be modified accordingly to be integrated with into another addon, and serves mostly as a working example of how to implement the updater code.

In this documentation, addon_updater.py is referred to by "the Python Module" and addon_updater_ops.py is referred to by "the Operator File".

About the example addon

Included in this repository is an example addon which is integrates the auto-updater feature. It is currently linked to this repository and it's tags for testing. To use in your own addon, you only need the addon_updater.py and addon_updater_ops.py files. Then, you simply need to make the according function calls and create a release or tag on the corresponding repository.

Step-by-step as-is integration with existing addons

These steps are for the configuration that provides notifications of new releases and allows one-click installation

These steps are also represented more thoroughly in this text tutorial

  1. Copy the Python Module (addon_updater.py) and the Operator File (addon_updater_ops.py) to the root folder of the existing addon folder

  2. import the updater operator file in __init__.py file e.g. from . import addon_updater_ops at the top with other module imports like import bpy

  3. In the register function of __init__.py, run the addon's def register() function by adding addon_updater_ops.register(bl_info).

  • Consider trying to place the updater register near the top of the addon's register function along with any preferences function so that if the user updates/reverts to a non-working version of the addon, they can still use the updater to restore backwards.
  1. Edit the according fields in the register function of the addon_updater_ops.py file. See the documentation below on these options, but at the bare minimum set the GitHub username and repository.
  • Note that many of the settings are assigned in the addon_updater_ops.py: register() function to avoid having excess updater-related code in the addon's __init__.py:register() function, however because the updater module is shared across the addon, these settings could be made in either place.
  • If using GitLab or Bitbucket, then you must also assign the according engine value, the rest is the same setup.
  1. To get the updater UI in the preferences draw panel and show all settings, add the line addon_updater_ops.update_settings_ui(self,context) to the end of the preferences class draw function.
  • Be sure to import the Operator File if preferences are defined in a file other than the addon's __init__.py where already imported, e.g. via from . import addon_updater_ops like before

  • Alternatively, a more condensed version of the UI preferences code may be draw with the sample function addon_updater_ops.update_settings_ui_condensed(self, context, col) instead of the above function.

  • Note that the col input is optional, but allows you to add this function into an existing structure of rows/columns. This condensed UI doesn't show settings for interval (just an auto-check toggle, will use default interval) nor does it provide the backup-restoring or target-install operations.

  1. Add the needed blender properties to make the sample updater preferences UI work by copying over the blender properties from the sample demo addon's DemoPreferences class, located in the __init__ file. Change the defaults as desired.
# 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_minutes = bpy.props.IntProperty(
        name='Minutes',
        description = "Number of minutes between checking for updates",
        default=0,
        min=0,
        max=59
        )
  1. To support Blender version > 2.80, make one (not necessairly both) of these changes:

    a. Add the decorator @addon_updater_ops.make_annotations before your addon's user preferences class (see here)

    b. Call make_annotations(), passing your addon's user preferences class as an input, inside a register function (see here)

  2. Add the draw call to any according panel to indicate there is an update by adding this line to the end of the panel or window: addon_updater_ops.update_notice_box_ui()

  • Again make sure to import the Operator File if this panel is defined in a file other than the addon's __init__.py file.
  • Note that this function will only be called once per blender session, and will only do anything if auto-check is enabled, thus triggering a background check for update provided the interval of time has passed since the last check for update. This is safe to trigger from draw as it is launched in a background thread and will not hang blender.
  1. Ensure at least one release or tag exists on the GitHub repository
  • As an alternative or in addition to using releases, the setting updater.include_branches = True in the addon_updater_ops.py register function allows you to update to specific git branches. You can then specify the list of branches for updating by using updater.include_branche_list = ['branch','names'] for which the default is set to ['master']
  • If no releases are found, the user preferences button will always show "Update to Master" without doing any version checking

Minimal example setup / use cases

If interested in implementing a purely customized UI implementation of this code, it is also possible to not use the included Operator File (addon_updater_ops.py). This section covers the typical steps required to accomplish the main tasks and what needs to be connected to an interface. This also exposes the underlying ideas implemented in the provided files.

Required settings Attributes to define before any other use case, to be defined in the registration of the addon

from .addon_updater import Updater as updater # for example
# updater.engine left at default assumes GitHub api/structure
updater.user = "cgcookie"
updater.repo = "blender-addon-updater"
updater.current_version = bl_info["version"]

Check for update (foreground using/blocking the main thread, after pressing an explicit "check for update button" - blender will hang)

updater.check_for_update_now()

# convenience returns, values also saved internally to updater object
(update_ready, version, link) = updater.check_for_update()

Check for update (foreground using background thread, i.e. after pressing an explicit "check for update button")

updater.check_for_update_now(callback=None)

Check for update (background using background thread, intended to trigger without notifying user - e.g. via auto-check after interval of time passed. Safe to call e.g. in a UI panel as it will at most run once per blender session)

updater.check_for_update_async(background_update_callback)
# callback could be the function object to trigger a popup if result has updater.update_ready == True

Update to newest version available (Must have already checked for an update. This uses/blocks the main thread)

if updater.update_ready == True:
  res = updater.run_update(force=False, revert_tag=None, callback=function_obj)
  if res == 0:
    print("Update ran successfully, restart blender")
  else:
    print("Updater returned " + str(res) + ", error occurred")
elif updater.update_ready == False:
  print("No update available")
elif updater.update_ready == None:
  print("You need to check for an update first")

Update to a target version of the addon (Perform the necessary error checking, updater.tags will == [] if a check has not yet been performed or releases are not found. Additional direct branch downloads will be inserted as the first entries if updater.include_branches == True. Pass in a function object function_obj to run code once the updater has finished if desired, or pass in None)

tag_version = updater.tags[2] # or otherwise select a valid tag
res = updater.run_update(force=False, revert_tag=None, callback=function_obj)
if res == 0:
  print("Update ran successfully, restart blender")
else:
  print("Updater returned " + str(res) + ", error occurred")

If utilizing updater.include_branches, you can grab the latest release tag by skipping the branches included (which appear first in the tags list)

n = len(updater.include_branch_list)
tag_version = updater.tags[n] # or otherwise select a valid tag
res = updater.run_update(force=False, revert_tag=None, callback=function_obj)
if res == 0:
  print("Update ran successfully, restart blender")
else:
  print("Updater returned " + str(res) + ", error occurred")

addon_updater module settings

This section provides documentation for all of the addon_updater module settings available and required. These are the settings applied directly to the addon_updater module itself, imported into any other python file.

Example changing or applying a setting:

from .addon_updater import Updater as updater
updater.addon = "addon_name"

Required settings

  • current_version: The current version of the installed addon, typically acquired from bl_info
    • Type: Tuple, e.g. (1,1,0) or (1,1) or bl_info["version"]
  • repo: The name of the repository as found in the GitHub link
  • user: The name of the user the repository belongs to
    • Type: String, e.g. "cgcookie"
    • Note: Required but not actually used with GitLab engine enabled

Optional settings

  • engine:
    • Type: String, one of: ["github","gitlab","bitbucket"], not case sensitive
    • Default: "github"
    • This selection sets the api back end for retrieving the code. This must be set to match the appropriate online repository where releases/tags are hosted
  • private_token:
    • Type: String
    • Default: None
    • Currently only supports private tokens for GitLab. Used only for granting access to private repositories for updating.
    • WARNING: Before providing or using a personal token, PLEASE READ SECURITY COCNERN SECTION BELOW
  • addon:
    • Type: String, e.g. "demo_addon_updater"
    • Default: derived from the __package__ global variable, but recommended to change to explicit string as __package__ can differ based on how the user installs the addon
    • Note this must be assigned once and at the very top of the UI file (addon_updater_ops.py) as the string is used in the bl_idname's for operator and panel registration.
  • auto_reload_post_update: If True, attempt to auto disable, refresh, and then re-enable the addon without needing to close blender
    • Type: Bool, e.g. False
    • Default: False
    • Notes: Depending on the addon and class setup, it may still be necessary or more stable to restart blender to fully load. In some cases, this may lead to instability and thus it is advised to keep as false and accordingly inform the user to restart blender unless confident otherwise.
      • If this is set to True, a common error is thinking that the update completed because the version number in the preferences panel appears to be updated, but it is very possible the actual python modules have not fully reloaded or restored to an initial startup state.
      • If it is set to True, a popup will appear just before it tries to reload, and then immediately after it reloads to confirm it worked.
  • fake_install: Used for debugging, to simulate in the user interface installing an update without actually modifying any files
    • Type: Bool, e.g. False
    • Default: False
    • Notes: Should be only used for debugging, and always set to false for production
  • updater_path: Path location of stored JSON state file, backups, and staging of installing a new version
    • Type: String, absolute path location
    • Default: "{path to blender files}/addons/{addon name}/{addon name}_updater/"
  • verbose: A debugging setting that prints additional information to the console
    • Type: Bool, e.g. False
    • Default: False
    • Notes: Messages will still be printed if errors occur, but verbose is helpful to keep enabled while developing or debugging this code. It may even be worthwhile to expose this option to the user through a blender interface property
  • website: Website for this addon, specifically for manually downloading the addon
    • Type: String, valid url
    • Default: None
    • Notes: Used for no purpose other than allowing a user to manually install an addon and its update. It should be very clear from this webpage where to get the download, and thus may not be a typical landing page.
    • backup_current Create a backup of the current code when performing an update or reversion.
  • overwrite_patterns: A list of patterns to match for which files of the local addon install should be overwritten by matching files in the downloaded version version
    • Type: List of strings, each item follows a match pattern supported by the python module fnmatch
    • Default: [], which is internally made equivalent to ["*.py","*.pyc"]
    • Notes: You can use wild card patterns, see documentation for fnmatch.filter. The new default behavior introduced here is setting ["*.py","*.pyc"] means it matches the default behavior of blender. Also note this only describes patterns to allow overwriting, if a file in the new update doesn't already exist locally, then it will be installed to the local addon.
    • Examples:
      • ["some.py"] In this method, only files matching the name some.py would be overwritten via the update. Thus, even if the updated addon had a newer init.py file, it would not replace the local version. This method could be used to build a file replacement whitelist.
      • ["*.json"] means all JSON files found in addon update will overwrite those of same name in current install. This would be useful if the addon only has configuration, read-only data that should be always updated with the addon. Note that default blender behavior would not overwrite such JSON files if already present in the local install, this gets around that
      • ["*"] means that all matching files found in the update would overwrite files in the local install. Note this was the behavior pre updater v1.0.4, this is also the safest option to use if you want to ensure all files always get updated with the newer version in the update, including resource files. Be mindful that any local or custom modified files may get overwritten. // also note that this is a new setting as of v1.0.4 of the updater; the previous behavior of the updater was using the equivalent setting of ["*"] which would mean that all files found in the update would overwrite files in the local install.
      • [] or ["*.py","*.pyc"] matches default blender behavior, ie same effect if user installs update manually through blender interface without deleting the existing addon first
  • remove_pre_update_patterns: A list of patterns to match for which files of the currently installed addon should be removed prior to running the update
    • Type: List of strings, each item follows a match pattern supported by the python module fnmatch
    • Default: [], recommended/as configured in demo addon: ["*.pyc"]
    • Notes: This explicitly will delete all files in the local addon install which match any of the rules, and will run after a backup is taken (so the backup is complete), but before the overwrite_patterns are applied. If the structure or files of an addon may change in the future, it may be wise to set remove_pre_update_patterns to [".py",".pyc"] which would ensure all python files are always removed prior to the update, thus ensuring no longer used files aren't present. Using it in this fashion would also negate the need to specify the same patterns in the overwrite_patterns option. Note this option only deletes files, not folders.
    • Examples:
      • ["*"] means all files in the addon (except those under the dedicated updater subfolder of the addon) will always be deleted prior to running the update. This is nearly equivalent to using clean=True in the run_update method (however that will also delete folders)
      • ["*.pyc"] means pycache files are always removed prior to update, which is a safe
  • backup_ignore_patterns: A setting to ignore certain files or folders when performing a backup prior to installing an update/target version, useful to avoid copying resources or large files that wouldn't be replaced by the update anyways (via not being included in the overwrite_patterns setting)
    • Type: List of strings
    • Default: None
    • Notes: You can use wild card patterns, see documentation for shutil.copytree ignore input parameter as this is where the list is passed into. This is similar but slightly different to the patterns used in overwrite_patterns and remove_pre_update_patterns, except these will also apply to folders
  • manual_only: A setting which will permit only manual installs and not one-click updates
    • Type: Bool, e.g. False
    • Default: False
    • Notes: This is useful if you always want to direct the user to a specific download page, but still want them to receive update notifications.
  • showpopups: A setting which when enabled will allow for popup notifications for new updates
    • Type: Bool, e.g. False
    • Default: True
    • Notes: This setting was introduced in v1.0.5, where previous functionality was equivalent to the setting being equal to True. Note that popups will only work if the proper configuration is provided to trigger them, ie triggering a background check for update in the appropriate location.
  • version_min_update: A setting which sets the minimum allowable version to target installing, so that any earlier numbered releases will not appear in the target install dropdown or appear as notifications for updating
    • Type: Tuple e.g. (1,2) or (1,2,3), should match the number of separators in bl_info
    • Default: None
    • Notes:
      • This behaves as an "equal to or greater", example: if version_min_update is set to (1,1,1), then (1,1,1) and (1,1,2) are valid targets, but (1,1,0) would not be listed as an available install target.
      • This also impacts what is considered as an update. Example: if the current addon version locally is v1.5 with version_min_update set to be (1,8), the addon will not perceive v1.6 as an update and thus would not notify the user.
      • The most logical use for this setting is to assign the earliest addon version with a functional updater, so that users cannot downgrade to a version before there was an updater and thus not be able to easily revert back.
  • version_max_update: A setting which sets the maximum allowable version to target installing, so the target version and any higher numbered releases will not appear in the target install dropdown or appear as notifications for updating
    • Type: Tuple e.g. (1,2) or (1,2,3), should match the number of separators in bl_info
    • Default: None
    • Notes:
      • This behaves as an "equal to or greater". Example: if version_max_update is set to (1,1,1), then (1,1,1) and (1,1,2) will be ignored targets (won't appear in target install dropdowns and won't trigger update notifications), but (1,1,0) would still be recognized as an available target and trigger update notifications.
      • This also impacts what is considered as an update. Example: if the current addon version locally is v1.5 with version_max_update set to be (1,6), the addon will not perceive v1.6 or v1.7 online as an update and thus would not notify the user.
  • skip_tag: A setting which defines how to pre-process tag names
    • Type: Function, see example method skip_tag_function in the Operator File
    • Default: skip_tag_function defined in addon_updater_ops.py
    • Notes: This is where the version_min_update and version_max_update settings are utilized. Additionally, the source function skip_tag_function could be modified e.g. to parse out any tags including the text "dev" or similar such rules to limit what is counted as an available update and also what is listed in the target install dropdown.
  • subfolder_path: Define the root location of the __init__.py file in the repository
    • Type: String
    • Default: "", meaning the root repository folder
    • Notes: Not required if your __init__.py file is in the root level of the addon. Otherwise, use this setting to indicate where it is located so the updater knows which folder to take updated files from
  • use_releases: (GitHub only) Choose to pull updates from releases only instead of tags, and use release names instead of tag numbers in target-install dropdowns
    • Type: Bool
    • Default: False
    • Notes: If true, any tags that are not "annotated" (ie have release notes or attachments) will be filtered out, as tags are not necessarily releases. Additional note: if set to false, cannot pull release notes for GitHub repository (whereas BitBucket and GitLab do have release notes available via tags). This means that if in the future in-line release notes are included in the UI, this setting will need to be set to True in order to show release logs (not yet implemented as of v1.0.5)

User preference defined (ie optional but good to expose to user)

  • check_interval_enable: Allow for background checking.
  • check_interval_minutes: Set the interval of minutes between the previous check for update and the next
  • check_interval_hours: Set the interval of hours between the previous check for update and the next
  • check_interval_days: Set the interval of days between the previous check for update and the next
  • check_interval_months: Set the interval of months between the previous check for update and the next

Internal values (read only by the Python Module)

  • addon_package: The package name of the addon, used for enabling or disabling the addon
    • Type: String
    • Default: __package__
    • Must use the provided default value of __package__ , automatically assigned
  • addon_root: The location of the root of the updater file
    • Type: String, path
    • Default: os.path.dirname(__file__)
  • async_checking: If a background thread is currently active checking for an update, this flag is set to True and prevents additional checks for updates. Otherwise, it is set to false
    • Type: Bool
    • Default: False
    • Notes:
      • This may be used as a flag for conditional drawing, e.g. to draw a "checking for update" button while checking in the background
      • However, even if the user were to still press a "check for update" button, the module would still prevent an additional thread being created until the existing one finishes by checking against this internal boolean
  • json: Contains important state information about the updater
    • Type: Dictionary with string keys
    • Default: {}
    • Notes: This is used by both the module and the operator file to store saved state information, such as when the last update is and caching update links / versions to prevent the need to check the internet more than necessary. The contents of this dictionary object are directly saved to a JSON file in the addon updater folder. The contents are periodically updated, such as to save timestamps after checking for update, or saving locally the update link of not updated immediately, or storing the "ignore update" decision by user.
  • source_zip: Once a version of the addon is downloaded directly from the server, this variable is set to the absolute path to the zip file created.
    • Type: String, OS path
    • Default: None
    • Notes: Path to the zip file named source.zip already downloaded
  • tag_latest Returns the most recent tag or version of the addon online
    • Type: String, URL
    • Default: None
  • tag_names Returns a list of the names (versions) for each tag of the addon online
    • Type: list
    • Default: []
    • Note: this is analogous to reading tags from outside the Python Module.
  • tags: Contains a list of the tags (version numbers) of the addon
    • Type: list
    • Default: []
    • Notes: Can be used if the user wants to download and install a version other than the most recent. Can be used to draw a dropdown of the available versions.
  • update_link: After check for update has completed and a version is found, this will be set to the direct download link of the new code zip file.
  • update_ready: Indicates if an update is ready
    • Type: Bool
    • Default: None
    • Notes:
      • Set to be True if a tag of a higher version number is found after checking for updates
      • Set to be False if a tag of a higher version number is not found after checking for updates
      • Set to be None before a check has been performed or cached
      • Using updater.update_ready == None is a good check for use in draw functions, e.g. to show different options if an update is ready or not or needs to be checked for still
  • update_version: The version of the update downloaded or targeted
    • Type: String
    • Default: None
    • Notes: This is set to the new addon version string, e.g. (1,0,1) and is used to compare against the installed addon version
  • error: If an error occurs, such as no internet or if the repo has no tags, this will be a string with the name of the error; otherwise, it is None
    • Type: String
    • Default: None
    • It may be useful for user interfaces to check e.g. updater.error != None to draw a label with an error message e.g. layout.label(updater.error_msg)
  • error_msg: If an error occurs, such as no internet or if the repo has no tags, this will be a string with the description of the error; otherwise, it is None
    • Type: String
    • Default: None
    • It may be useful for user interfaces to check e.g. updater.error != None to draw a label with an error message e.g. layout.label(updater.error_msg)

About addon_updater_ops

This is the code which acts as a bridge between the pure python addon_updater.py module and blender itself. It is safe and even advised to modify the Operator File to fit the UI/UX wishes. You should not need to modify the addon_updater.py file to make a customized updater experience.

User preferences UI

Alt

Most of the key settings for the user are available in the user preferences of the addon, including the ability to restore the addon, force check for an update now, and allowing the user to immediately check for an update (still runs in the background)

Alt

This is an alternate, more condensed preferences UI example which removes more granular options such as settings for the intervals between update checks, restoring from backups, and targeting versions to install

Integrated panel UI

Alt

If a check has been performed and an update is ready, this panel is displayed in the panel otherwise just dedicated to the addon's tools itself. The draw function can be appended to any panel.

Popup notice after new update found

Alt

After a check for update has occurred, either by the user interface or automatically in the background (with auto-check enabled and the interval passed), a popup is set to appear when the draw panel is first triggered. It will not re-trigger until blender is restarted. Pressing ignore on the integrate panel UI box will prevent popups in the future.

Install different addon versions

Alt

In addition to grabbing the code for the most recent release or tag of a GitHub repository, this updater can also install other target versions of the addon through the popup interface.

If your repository doesn't have any releases...

Alt

This is what you will find. See below on creating tags and releases

How to use git and tags/releases

What are they

From a good reference website, a tag acts much like a branch except it never changes - it is linked with a specific commit in time. Tags can be annotated to have information like release logs or binaries, but at the base they allow one to designate major versions of code. This addon updater uses tag names in order to base the comparison version numbers, and thus to also grab the code from those points in times.

Through the interface (GitHub specific)

View the releases tab at the top of any GitHub repository to create and view all releases and tags. Note that a release is just an annotated tag, and that this repository will function with both tags and releases.

Through command line (for any git-based system)

To show all tags on your local git repository use git tag

To create a new tag with the current local or pushed commit, use e.g. git tag -a v0.0.1 -m "v0.0.1 release" which will create an annotated tag.

To push this tag up to the server (which won't happen automatically via git push), use git push origin v0.0.1 or whichever according tag name

Configuring what files are removed, overwritten, or left alone during update

Since v1.0.4 of the updater module, logic exists to help control what is modified or left in place during the updating process. This is done through the overwrite_patterns and remove_pre_update_patterns settings detailed above. Below are the common scenarios or use cases

I don't understand this feature and I just want to use the default configuration which matches blender's install behavior

Fair enough, in that case use the following settings - or just remove the lines entirely from the Operator File as these are the default values assigned to the updater class object.

# only overwrite matching python files found in the update, files like .txt or .blend will not be overwritten even if newer versions are in the update
updater.overwrite_patterns = ["*.py","*.pyc"]
# don't delete any files preemptively
updater.remove_pre_update_patterns = [ ]

If you wanted to instead match the default behavior of the addon updater pre v1.0.4, then use the following

# overwrite any file found in the local install which has a corresponding file in the update
updater.overwrite_patterns = ["*"]
# don't delete any files files preemptively
updater.remove_pre_update_patterns = [ ]

I want to shoot myself in the foot and make updating not work at all

Or in other words... don't use the following setup, as it effectively prevents the updater from updating anything at all!

# don't overwrite any files matching the local install in the update
updater.overwrite_patterns = [ ]
# don't delete any files files preemptively
updater.remove_pre_update_patterns = [ ]

This would still add in new files present in the update not present in the local install. For this reason, this actually may be a valid setup if used in conjunction with clean_install set to True, which simulates a fresh install. When clean_install = True, these patterns are effectively rendered pointless, so it's still better to not define them in the way above.

Addon contains only py files, no resources (e.g. JSON files, images, blends), and against better judgment, not even licenses or readme files

In this example, we only need to worry about replacing the python files with the new python files. By default, this demo addon is configured so that new py files and pyc files will overwrite old files with matching paths/names in the local install. This is accomplished by setting updater.overwrite_patterns = ["*.py","*.pyc"] in the operator file. You could also be more explicit and specify all files which may be overwritten via updater.overwrite_patterns = ["__init__.py", "module.py", "*.pyc"] for example (noting the "*.pyc" is still there to ensure all caches are flushed).

Note that if in the future, a file is renamed e.g. from module.py to new_module.py, when the update runs (and assuming remove_pre_update_patterns has been left to it's empty list default), then the updater will copy in the new_module.py into the local install, while also leaving the previous version's module.py in place. The result will have both the module.py and new_module.py file in place.

If you wanted to future proof your updater to ensure no old python files are left around due to a changes in structure or filenames, it would be safe to instead set updater.remove_pre_update_patterns = ["*.py","*.pyc"] meaning all python files and cached files will always be removed prior to updating. After the update completes, the only python files that will be present are those that came directly from the update itself.

While you could also use updater.remove_pre_update_patterns = ["*"], it is not recommended unless absolutely necessary. You never know when a user may try to place files in the addon subfolder, or if sometime down in the future you might want the updater to not clear everything out, so it's best to only explicitly delete the minimum which is needed, and be sure to plan ahead.

Addon contains py files and resource files, but no user/local configuration files

This is the more common use case. It is similar to the above, except now there are also additional files such as the readme.md, the license.txt, and perhaps a blend file with some models or other resources.

If the user were to install the update manually through the blender UI with an older version of the addon in place, it would actually only overwrite the py files. The readme.md and licenses.txt that existed previously would not change, they would not be overwritten. However, any new files in the update not in the local install (such as a new blend file) will be moved into the local install folder. If a blend file is in the local install prior to updating but is not found in the new addon update, it would still be left in place. Essentially, blender's default behavior is to only overwrite and update python files, and when copying in new resources it favors the files already present in the local install.

Instead of this default behavior, the following settings would be more appropriate for the situation of readme's and asset blends, since they may change between versions.

updater.overwrite_patterns = ["README.md", "*.blend"]

In this setup, the updater is told to always replace the readme file explicitly (note the case sensitivity). No other files are indicated to be overwritten, indicating for example the license file will never be overwritten with an update - that shouldn't be changing anyways. This setup would actually mean not even the python files are overwritten if the update has matching files to the local install. Not even the init.py file would be updated, which is where the next setting becomes useful.

The "*.blend" will result in any blend file being overwritten if matching locally to the update. e.g. /addonroot/assets/resources.blend will be replaced with the e.g. /addonroot/assets/resources.blend found in update repository. This would make sense if the blend file is static and not expected to be ever user modified.

updater.remove_pre_update_patterns = ["*.py","*.pyc"]

The second line tells the updater to delete all .py and .pyc files prior to updating, no matter what. This why we don't need to also add *.py into the overwrite_patterns, because if the python files have already been removed, then there's no chance for the update to have a matching python file in the local install (and thus no need to check against overwriting rules). This setup also has the benefit of never leaving old, unused python code around. if module_new.py is used in one version but then removed in the next, this setup of pre-removing all py files ensures it is deleted. Note that this doesn't do anything to any other files. Meaning existing files such as blends, images, JSON etc will all be left alone. With the exception of blend files (as per overwrite_patterns above), they also won't be overwritten - even if there are updates.

Addon contains py files, resource files, and user/local configuration files

This is the most intricate setup, but layers on more useful behavior even in unique situations.

Imagine an addon has a changing python code structure, assets which should be updated with each update, but also configuration files with default settings provided in the master repository, but local changes wanted to be kept. Furthermore, the user may install custom image textures saved in the addon folder so you will not know the names ahead of time, but you also want to ensure custom icon file updates can be made.

# example addon setup
__init__.py
module.py
icons/custom_icon.png
images/   # folder where custom png images will be installed
README.md
assets/default.blend
assets/customizable.blend

To accomplish the mentioned behavior, use the below configuration.

updater.overwrite_patterns = ["README.md", "custom_icon.png"]
updater.remove_pre_update_patterns = ["*.py", "*.pyc", "default.blend"]

Breaking this down, we always specify to overwrite the README and custom_icon.png files explicitly. No need to remove either in pre update since we expect they will be found in the update, and the overwrite patterns ensures they always get overwritten and only those files.

Then, we specify to delete all python files before running the update, to ensure the only python files are part of the latest release. We also force delete the file matching the name default.blend. If this was added as an overwrite pattern instead and the default.blend file name were ever renamed in the master repository, the updater would not end up removing this extra asset. And so we delete it directly, and presume the update will contain the appropriately named and updated blend file.

Just as importantly, note how the customizable.blend is not mentioned in either line. This means that there are no rules which would allow for this file to be overwritten or removed. This is desired since the user could have modified this file per their own needs, and we don't want to reset it. If the file was manually removed by the user or otherwise not present in a previous version of the addon, the update would still copy it over as found in the master repository.

In conclusion

If you are planning to modify the overwrite_patterns or remove_pre_update_patterns settings, be sure to plan and test it works as you expect. It's important to have "*.py" in at least one of them, or alternatively individually name all python file basenames in either of the two settings.

It is redundant to have the same rule in both settings, behavior of the remove_pre_update_patterns will supersede the more passive overwriting permission rules of overwrite_patterns

The pattern matching is done on an "or" basis, meaning in the set [".py", "module.py"], the second list item is redundant as the ".py" already

The patterns only match to filenames, so there is no use in including in paths like assets/icon.png or directory names.

Finally, enabled verbose and check the console output after running an update! There are explicit printouts for when any files is "pre-removed", overwritten, or ignored for overwriting due to not matching a pattern. Use this to debug.

Blender 2.7 and 2.8

This repository and example addon has been updated to still work for Blender 2.7x, 2.8x, 2.9x, and (as of writing) early builds of 3.0. Optionally, addon developers could still choose to host dedicated 2.8x versions separate from 2.7x versions while using this updater system. Note that annotations are applied to class fields programmatically instead of through coding syntax (e.g. you will not see propname: bpy.props..., but the same effect will be in place and there should be no console warnings)

Note that, as an addon developer, you have different options for supporting Blender 2.7 and 2.8+ while still using this updater system. These are:

  1. Make the addon work for 2.7x and 2.8+ simultaneously (in the same way that this module and demo addon does).
    • This requires some extra work, in particular note the workaround of annotations as accomplished by the make_annotations function.
  2. Have dedicated, separate releases for Blender 2.7x and 2.8+ which are separated by a major version, and use min/max conversioning to isolate which users can update to which versions.
    • For instance, if an existing addon is version 1.5 and works on blender 2.79, then a feature-parity version for Blender 2.8 could be released as addon version 2.0; this 2.0 addon with have a version_min_update set to be 2.0 for the blender 2.8 code, and the Blender 2.7x code would set version_max_update to be 2.0 as well as a ceiling.
    • The next update to the Blender 2.79-compatible addon (released at the same time or earlier, to prevent 2.7x users from accidentally updating to breaking 2.8 code) should push this settings change to make sure users don't accidentally update to a version they shouldn't.
    • Note in this scenario, you also prevent being able to update Blender 2.7x version numbers to or beyond 2.0. Note that there is no obligation to simultaneously update the Blender 2.7x and 2.8x versions at the same time as the version numbers themselves are not actually linked in any way.
    • The 2.7x and 2.8x code would be kept in different branches, and tags would be made targeting those different branches accordingly. Given Blender 2.8x will be the long term future, it may make most sense to dedicate the master branch to be 2.8 and create a 2.7x branch for parallel legacy support, but the choice doesn't really matter as a tag is treated the same regardless of the source branch.
  3. Parallel version releases with build attachments for each new version.
    • This method is in one way simple as the same version numbers would work for both Blender 2.7x and 2.8x code, while still having separate code in different branches so you don't have to make code (such as annotation syntax) compatible for both at the same time in the same files. You could even have everything in the same branch with just duplicate files (e.g. a ui.py and ui_28.py).
    • The crux of this method is that instead of the updater pulling down the raw code associated with the tag/release, it uses release attachments instead. You would need to build
    • This does require releasing the 2.7x and 2.8 code at the same time
    • Extra logic will need to be programmed in the addon_updater_ops.py: select_link_function function to parse for the correct attachment given the running version of blender (instead of just the first release attachment, the default behavior), as well as enabling the use_releases setting in the ops file
    • For reference, this is essentially the method developers use to maintain and distribute updates for operating-specific builds of addons

Security concerns with private repositories

Support for private repositories is still a work in progress for Bitbucket and GitHub, while already available for GitLab. At this time, they are only supported via authentication through personal or private tokens. These are assigned to an individual user and while can be restricted what access they do or don't have, they can effectively act as an alternate to a password. While this updater module is configured to only read/download code, a private token would allow both read and write capabilities to anyone who knows how to use the according api. By nature of python modules, this private token is easily read in source code or can be reverse compiled in pyc code and used for malicious or unintended purposes.

For this reason, it is very important to be aware and setup tokens accordingly. As the authentication implementation advances here, the recommendations may change but in the meantime:

  • GitLab: Supported through Personal Tokens
    • Tokens are not needed and should not be used for public repositories
    • Personal access tokens can be viewed and created here
    • Consider whether to provide an expiration date. Once expired any existing installs using the token will no longer successfully pull updates from private repositories. Therefore, if a user has the updater-enabled addon installed but leverages an expired token, they will not be able to update.
    • Tokens should be enabled for api read access only, to limit (mis) uses.
    • This token is user specific, not repository specific; therefore, anyone with the token is able to read anything via the GitLab api to any repository this user has access to. For this reason, it is very important to NOT USE YOUR PERSONAL ACCOUNT to create a token. Rather, you are better suited to create a secondary "machine user" account which is used only for the purpose of api access. This 'user' should be assigned to the project as a "reporter" for minimum required capabilities.
    • Use at own risk and ensure to do according research to ensure there are no security risks or possible backlashes due to providing updating for private repositories on GitLab.
    • When in doubt, you can always revoke a personal token - but once revoked, it cannot be re-enabled and thus any existing installs using the token will no longer be able to pull from the private repo unless manually updating the addon themselves.
    • These are only recommendations. As indicated by the GPL license, software is provided as-is and developers are not held liable to mishandling which results in unwanted consequences such as malicious exploit of a badly implemented private repository updating.
  • GitHub: Not yet supported. Likely to only be included via community contribution.
  • Bitbucket: Not yet supported. Likely to only be included via community contribution.

Issues or help

If you are attempting to integrate this code into your addon and run into problems, please open a new issue. As the module improves, it will be easier for more developers to integrate updating and improve blender's user experience overall!

Please note that the updater code is built to be dependent on existing api's of the mentioned major source code repository sites. As these api's may be subject to change or interruption, updating capabilities may be impacted for existing users.

blender-addon-updater's People

Contributors

blanchg avatar calinou avatar darkblader24 avatar dragorn421 avatar ekaj2 avatar federicob avatar josuemtzmo avatar kant avatar keshismith avatar kromar avatar ndee85 avatar neomonkeus avatar nutti avatar ombre5733 avatar schroef avatar theduckcow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blender-addon-updater's Issues

[REQ] Add interval days in the hover info auto updater

Sweet new release! One thing i noticed is when we use the compact view, we have the auto-updater checkbox below that. When a user hovers over it states "auto check for updates using interval". But it doesnt state how long that interval is.

Perhaps this should be added so user know what interval is used?

screen shot 2018-04-04 at 8 02 36 pm

I did had an idea to get the data using;

 updater.set_check_interval(enable=auto_check_update,
					months=updater_intrval_months,
					days=updater_intrval_days,
					hours=updater_intrval_hours,
					minutes=updater_intrval_minutes
					)

But i got an error about tuple first. Then tried a different approach importing the updater from addon_updater.py (Singleton_updater) above the prefrerence panel. That way i could reach the _check_interval_days

from .addon_updater import Updater as updater

It grabs the standard days and shows this in the hover info.
screen shot 2018-04-04 at 8 40 45 pm

other option is to add in between after the boolean checkbox perhaps. Then the user will see the update interval directly. This also works, same method as i used above.
screen shot 2018-04-04 at 8 47 28 pm

It grabs the standard days set in the addon_updater.py file, it looks like this
screen shot 2018-04-04 at 8 42 01 pm

Reverting to prior version should clear out the "up to date" flag

If you revert to an older version, such as from 1.1.3 to 1.1.1 then the update status still reads as Add-on is up to date, which is now incorrect.

Upon reversion we need to be sure to clear out the updated status so that it properly shows that an update is available.

Error due to creating folders without permission

As referenced in this issue on CrowdMaster, it seems sometimes windows users run into an issue if they don't have the right permissions and if the updater path doesn't already exist.

Recommendation: Developers should always pre-include/pre-create the updater folder or perhaps look into a different method to create folders that doesn't do absolute paths.
johnroper100/CrowdMaster#57 (comment)

reload_addon in 2.8x

The issue

reload_addon() is failing in Blender 2.82:

  File "...\Blender\2.82\scripts\addons\...\addon_updater_ops.py", line 377, in execute
    clean=self.clean_install)
  File "...\Blender\2.82\scripts\addons\...\addon_updater.py", line 1349, in run_update
    res = self.unpack_staged_zip(clean)
  File "...\Blender\2.82\scripts\addons\...\addon_updater.py", line 933, in unpack_staged_zip
    self.reload_addon()
  File "...\Blender\2.82\scripts\addons\...\addon_updater.py", line 1054, in reload_addon
    bpy.ops.wm.addon_disable(module=self._addon_package)
  File "C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\modules\bpy\ops.py", line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
AttributeError: Calling operator "bpy.ops.wm.addon_disable" error, could not be found

The reason

reload_addon in addon_updater.py

		bpy.ops.wm.addon_disable(module=self._addon_package)
		bpy.ops.wm.addon_refresh()
		bpy.ops.wm.addon_enable(module=self._addon_package)

Apparently at some point those operators moved from bpy.ops.wm. to bpy.ops.preferences.

A fix

Replacing the previous code excerpt with this allowed the module to reload in Blender 2.82:

		try:
			# < 2.80
			bpy.ops.wm.addon_disable(module=self._addon_package)
			bpy.ops.wm.addon_refresh()
			bpy.ops.wm.addon_enable(module=self._addon_package)
		except AttributeError: # 2.80+
			bpy.ops.preferences.addon_disable(module=self._addon_package)
			bpy.ops.preferences.addon_refresh()
			bpy.ops.preferences.addon_enable(module=self._addon_package)

Not sure except AttributeError is the best check. hasattr doesn't seem to be a possibility under bpy.ops for reasons I don't know/understand

Version restriction

Previously there was a request to create or allow the developer to add a function which restricts the versions to be installed by the updater. This could, as one example, prevent the user from downgrading too far. Ultimately, we could also put checks in for blender versions but would be up to the developer how restrictive this is.

This feature is currently already implemented in the code via a function that the developer passes into the register function, assigning it to an updater class object which is used as a callable whenever checking the versions from the server.

Great feature, couple thoughts.

So we're integrating this to the RenderMan for Blender addon. Really think this is the missing piece for addons in Blender. Very clear code and instruction thanks!

Really my only question is the default of 7 days for the update. I'd claim that 1 day is fine! That's what we set.

404 error when trying to reach gitlab update

Hi !

Don't know if its an error on my side or a gitlab api change but I get an http error when trying to access release or master.

Console log :

Checking for update function
pipe_sync Updater: Read in JSON settings from file
Getting tags from server
HTTP error 404
master branch found, no releases {'name': 'Master', 'zipball_url': 'https://gitlab.com/api/v4/projects/pipe_sync/repository/archive.zip?sha=master'}
pipe_sync: Wrote out updater JSON settings to file, with the contents:
{'last_check': '2020-07-10 10:31:45.006835', 'backup_date': '', 'update_ready': False, 'ignore': False, 'just_restored': False, 'just_updated': False, 'version_text': {}}
pipe_sync BG thread: Finished checking for update, doing callback

here is my repo : https://gitlab.com/pullusb/pipe_sync

I specified this settings in updater_ops:

updater.engine = "GitLab"
updater.user = "pullusb"
updater.repo = "pipe_sync"
updater.website = "https://gitlab.com/pullusb/pipe_sync"

and up above :

# Must declare this before classes are loaded
# otherwise the bl_idname's will not match and have errors.
# Must be all lowercase and no spaces
updater.addon = "pipe_sync"

Can you tell me if I missed a step in the setup ?
I used the updater on another addon on github that works without issues...

Cancel background check for update

A previous proposal from @carter2422 from before was to see if we could add a "cancel button" for while the background thread is running/checking for an update. This way, if the request tis taking too long the user can cancel it.

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:720)

Hi,
I am trying to implement the addon updater into my addon. I have setup all basic steps. I left the repo and user name at defaults by now. Just to see if it gets a connection.

At work we use a proxy to connect to the internet. Could it be related to that?

Unfortunately I get the error message above. And within the blender console I get these errors:

Getting tags from server Exception in thread Thread-3: Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\threading.py ", line 914, in _bootstrap_inner self.run() File "C:\Program Files\Blender Foundation\Blender\2.79\python\lib\threading.py ", line 862, in run self._target(*self._args, **self._kwargs) File "C:\Users\g041481\AppData\Roaming\Blender Foundation\Blender\2.79\scripts \addons\coa_tools\addon_updater.py", line 1309, in async_check_update self.check_for_update(now=now) File "C:\Users\g041481\AppData\Roaming\Blender Foundation\Blender\2.79\scripts \addons\coa_tools\addon_updater.py", line 1035, in check_for_update self.get_tags() # sets self._tags and self._tag_latest File "C:\Users\g041481\AppData\Roaming\Blender Foundation\Blender\2.79\scripts \addons\coa_tools\addon_updater.py", line 523, in get_tags self._prefiltered_tag_count = len(all_tags) TypeError: object of type 'NoneType' has no len()

Later I will check this from home and see if it works. I will report back. Still would be great if this works with a proxy so my colleagues could update the addon without hassle in the future.

No module named 'blender-addon-updater-1'

This what I have when trying turn on the add-on after install.
blender\2.93\scripts\modules\addon_utils.py", line 351, in enable mod = __import__(module_name) ModuleNotFoundError: No module named 'blender-addon-updater-1'

Blender Version
Broken: version: 2.93.0, branch: master, commit date: 2021-06-02 11:21, hash: rB84da05a8b806

Account for different GitHub structures

Right now, the updater assumes a flat structure of an addon - that is, the root of the github repository is also the addon's root. I have added this to the tutorial to point this out:

on should have the init.py file and relative code structure at the root of the repository, not in a sub folder. The updater will try to install updates by directly installing the repository’s zip file.

The enhancement would be to more intelligently search for the relative addon's root within the zip file, perhaps just searchign by default one level deep or providing an option to the developer to specify which subfolder of the repository to treat as the addon itself.

Though this is more like an enhancement, I'm treating it like an issue as it could bar some developers from making use of the repository natively.

Removing Old Modules

The Add-on updater doesn't appear to remove old modules that have been deleted. From what I can see the zip file is just unpacked into the add-on directory. Are there any plans to clean up any files that have been removed?

Updating for multiple OSs

Now that we are moving CrowdMaster over to python, we need to make separate released for macOS, Windows, and Linux. Currently, the addon updater does not know the difference between OSes. Would it be possible to have a system that reads in three different release repositories and downloads the correct version for the user's OS?

Licensing

Let's get this thing licensed before going much further.

@TheDuckCow unless you feel strongly towards a different license, I vote we just for GPL3, same as RetopoFlow.

Error with 'include_master' option on

Hi,
I've integrated this updater with the Renderman for Blender addon. The versioning update works great but I've been seeing some odd behavior when the 'include_master' option is on.

If it is on and the auto update interval has passed, I am prompted to update to the latest master branch. However when I do that the updater does not install the latest version of master. Instead it pulls an older version (at least a commit or two prior), thus erasing new features and bugfixes.

However, if I ignore that prompt and manually select 'Master' from the 'install version/old version' dropdown then it will correctly install the latest master.

I haven't made any modifications to the two export modules other than changing the GitHub info and turning 'include_master' on.

Thanks for your help!

GitLab authentication errors

Recently, some change with communicating to the GitLab api is making all requests fail. The solution is to include a user-agent to the requests for the download archive api endpoint. This applies to both public and private repositories.

Need to test that this does not affect any of the other updates negatively, but providing a user agent generally is best practice and anyways should be done.

Certificate verify failed (_ssl.c:645)

I've got SSL certificate verify failed, when pressed the button, any hints fo this

below the error log

Traceback (most recent call last):
  File "/usr/local/blender/2.78/python/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/local/blender/2.78/python/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/home/aditia/.config/blender/2.78/scripts/addons/PSTools/addon_updater.py", line 1033, in async_check_update
    self.check_for_update(now=now)
  File "/home/aditia/.config/blender/2.78/scripts/addons/PSTools/addon_updater.py", line 783, in check_for_update
    self.get_tags() # sets self._tags and self._tag_latest
  File "/home/aditia/.config/blender/2.78/scripts/addons/PSTools/addon_updater.py", line 412, in get_tags
    self._prefiltered_tag_count = len(all_tags)
TypeError: object of type 'NoneType' has no len()

All addon updaters will not work on blender 2.79a and earlier (OSX only, SSL issue)

IMPORTANT UPDATE (via @TheDuckCow)

Due to a recent change in GitHub's allowed SSL standards, Blender 2.79a and earlier users on Mac OSX will not be able to use the updater, and will see the below screenshot. This only applies to users of Mac OSX blender versions 2.7X and GitHub hosted repositories. There are no issues for GitLab or Bitbucket hosted repositories, and Github-hosted addons continue to work fine on linux & windows. No fix is currently available for OSX blender <2.8 users.

Update February 2019: GitLab is now affected in the exact similar way. Note that Bitbucket-hosted repositories will still function in 2.79 and earlier; all work appropriately in 2.8.

ssl_error_updater
What OSX users would see prior to the v1.0.5 release

Update - release of v1.0.5

The latest release of the updater code does not fix this issue (since it is a server side/blender compiling lack of compatibility), but it does at least more directly acknowledge the error and provide the user with a manual-download solution if affected. Those not affected with continue to see the updater working as normal. Behavior for those affected is as follows:

ALT

ORIGINAL ISSUE POST

(Original issue title: After network downage is get a tlsv1 error)

rv 1.0.4
bl 2.78c
OSX

After my internet went down i see this error
ssl tlsv1_alert_protocol_version

Weird thing is internet works just fine and before that the updater worked just fine. I also see this in the console
Exception in thread Thread-3: Traceback (most recent call last): File "/Applications/blender-2.78c/blender.app/Contents/Resources/2.78/python/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/Applications/blender-2.78c/blender.app/Contents/Resources/2.78/python/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "/Users/PromotieSpullen/Library/Application Support/Blender/2.78/scripts/addons/addon_updater/addon_updater.py", line 1309, in async_check_update self.check_for_update(now=now) File "/Users/PromotieSpullen/Library/Application Support/Blender/2.78/scripts/addons/addon_updater/addon_updater.py", line 1035, in check_for_update self.get_tags() # sets self._tags and self._tag_latest File "/Users/PromotieSpullen/Library/Application Support/Blender/2.78/scripts/addons/addon_updater/addon_updater.py", line 523, in get_tags self._prefiltered_tag_count = len(all_tags) TypeError: object of type 'NoneType' has no len()

Version 1.2.0 doesn't work in Blender 2.82

Addon installs perfect. But doesn't let itself activate. After that the old one doesn't work anymore. Can't find what causes this. But not happy with this.

Error message in old version (1.1.0):
Error: Traceback (most recent call last):
File "C:\Users\gerar\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\chocofur_model_manager\controller.py", line 226, in execute
process_object(obj)
File "C:\Users\gerar\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\chocofur_model_manager\controller.py", line 221, in process_object
scn.update()
AttributeError: 'Scene' object has no attribute 'update'

Error message in new one I cannot reproduce anymore, because after first de-installation of the addon and adding it again, the error message changed. It now says the script doesn't exist.
But this is a different message then the first one.

Update to latest master

Could a function be added to update to the latest master version of the code? This would be for users who would like to try out different new features before the next release.

Blender 2.93a - ValueError: Enable must be a boolean value

Hi, thanks for this addon. It's a great addition to my addon.
It seems like there is an Error when running the updater on Blender 2.93a from the Blender build.

\blender-addon-updater-master\addon_updater.py", line 535, in set_check_interval
raise ValueError("Enable must be a boolean value")
ValueError: Enable must be a boolean value

I'm assuming there was some API change for property assignment. Does anyone knows something about it?

Failures to delete directories

Context

Some users and myself have been having issues, all linked to filesystem operations, on Windows, with different Blender 2.7x/2.8x versions.

Relevant Addon using blender-addon-updater / Latest revision at time of writing

This isn't a permissions issue as the addon can create the *_updater folder

Issue 1

A user encountered this when trying to update

Click to expand

error in ui

delete folder errors in console

Deleting the folder manually allowed the updater to function properly then.

Issue 2

I also had weird issues originating from shutil (I don't have the logs anymore sorry) which may have been due to paths being too long

The real issue being that those paths became too long because the addon was backuping its backups, after failing to delete previous backups. shutil failed midway through traversing the directory tree.

Fix

?

I think it would be better to not catch-all and ignore exceptions like here, because it clearly prevents us here to actually understand what's going on.

GitHub API shouldn't be trusted for tags order

Context

I'm using this updater for an addon (irrelevant I think but here it is https://github.com/CrookedPoe/io_export_objex )

Configuration part of addon_updater_ops.py : https://github.com/CrookedPoe/io_export_objex/blob/master/io_export_objex2/addon_updater_ops.py#L1354

Issue

At the moment there are two tags 2.79_only and 2.0.0, created in that order. The updater thinks 2.79_only is more recent though.

2.0.0 is indeed more recent as per the releases page https://github.com/CrookedPoe/io_export_objex/releases (screenshot below)

screenshot of releases on the 11th of august

What the GitHub API says

The API indeed puts 2.79_only first

https://api.github.com/repos/CrookedPoe/io_export_objex/tags

[
  {
    "name": "2.79_only",
    "zipball_url": "https://api.github.com/repos/CrookedPoe/io_export_objex/zipball/2.79_only",
    "tarball_url": "https://api.github.com/repos/CrookedPoe/io_export_objex/tarball/2.79_only",
    "commit": {
      "sha": "1af434a1c02f8c36f8930f64b192fba59fa68d93",
      "url": "https://api.github.com/repos/CrookedPoe/io_export_objex/commits/1af434a1c02f8c36f8930f64b192fba59fa68d93"
    },
    "node_id": "MDM6UmVmMTQ2MjMyOTAyOnJlZnMvdGFncy8yLjc5X29ubHk="
  },
  {
    "name": "2.0.0",
    "zipball_url": "https://api.github.com/repos/CrookedPoe/io_export_objex/zipball/2.0.0",
    "tarball_url": "https://api.github.com/repos/CrookedPoe/io_export_objex/tarball/2.0.0",
    "commit": {
      "sha": "7c5cf5879f92da930fec7f1b9df47ed346935e12",
      "url": "https://api.github.com/repos/CrookedPoe/io_export_objex/commits/7c5cf5879f92da930fec7f1b9df47ed346935e12"
    },
    "node_id": "MDM6UmVmMTQ2MjMyOTAyOnJlZnMvdGFncy8yLjAuMA=="
  }
]

As per the blender/blender tags more recent should indeed be first though: https://api.github.com/repos/blender/blender/tags

Cause

I pushed (git push --tags) the two tags in the same git push so that may be why this happens

Fix

I think the addon should somehow sort tags correctly, based on latest commit or somehow getting the tag time like on the releases page, since the GitHub API doesn't seem to sort tags as is thought

It may be best as an option since I guess it would take more requests over the internet

I am not familiar with the GitHub api, not sure what exactly can be done

In the mean time, is there an option to set in addon_updater_ops.py that could make 2.0.0 the chosen tag instead of 2.79_only?

Update for Gaffer gives URL error

Hitting "Check for update" on Gaffer giver the error "URL error, check internet connection"
gaff

Gaffer 3.03
4-06-2017 BlenderBot build
Mac OSX 10.12.4

Support for custom branch(s)

Having the ability to give the option to update from the master branch is awesome, but in some situations master may not be the actual development branch. It would be nice to be able to specify (in addition to master) other branches to add to the list of versions to update from.

Account for fatal error in updated add-on

Do we have any way to account for the scenario in which a developer releases a buggy update, which gets installed, and then fatals out?

Per Greg Zaal:

Greg Zaal [4:50 PM]
@jonathan @johnroper100 if there is some fatal error in my add-on that prevents it from registering, will the auto update still work? e.g. i accidentally release a broken update, which gets downloaded for all users - once i release a fixed version will the users have to manually update then?

Thoughts @TheDuckCow?

Trouble registering the updater

I'm no a coder so I might be missing or doing something stupid. Right now My addon is basically a collection on different scripts I collect and so I can load them all together every time I need. Sometime ago I found an init example which could register all scipts inside an addon folder by just adding the name of the script into a list, this init file is as follows:

 `bl_info = {
    "name" : "Lynchon Tools 2.80",
    "author" : "Lynchon",
    "description" : "",
    "version" : (1,0), 
    "blender" : (2, 80, 0),
    "location" : "",
    "warning" : "",
    "category" : "Generic"
}

import bpy
from . import addon_updater_ops

modulesNames = ['UI','y_up','xml_parse_particles', 'xml_parse_conformHeight', 'metal_compiler','edit_pivot','uv_tube_unwrap','Hidesato Offset Edges','fillet_280','addon_updater','addon_updater_ops',]

import sys
import importlib
 
modulesFullNames = {}
for currentModuleName in modulesNames:
    modulesFullNames[currentModuleName] = ('{}.{}'.format(__name__, currentModuleName))
 
for currentModuleFullName in modulesFullNames.values():
    if currentModuleFullName in sys.modules:
        importlib.reload(sys.modules[currentModuleFullName])
    else:
        globals()[currentModuleFullName] = importlib.import_module(currentModuleFullName)
        setattr(globals()[currentModuleFullName], 'modulesNames', modulesFullNames)
 
def register():
    
    for currentModuleName in modulesFullNames.values():
        if currentModuleName in sys.modules:
            if hasattr(sys.modules[currentModuleName], 'register'):
                sys.modules[currentModuleName].register()
 
def unregister():
    for currentModuleName in modulesFullNames.values():
        if currentModuleName in sys.modules:
            if hasattr(sys.modules[currentModuleName], 'unregister'):
                sys.modules[currentModuleName].unregister()`

As I try to include the updater (so my coworkers can get any update I do) into the addon problems arrive. My problem comes when I try to register the "addon_updater_ops" bl_info, seems that adding it into my register function in my init doesn't work, it keeps telling me it misses a positional argument even if I already have my bl_info inside the init ( I've also tried importing it from the addon_updater_ops as the tutorial explained).

How should I approach this issue, please ask me if you need any additional info or files.

Thanks in advance

Ignore update popup persistence

From previous feedback, if a user presses the "dismiss" button for an update, it should remove the entire panel on the view so they must move to the preferences to check or run updates.

Also, if the user presses ignore, verify whether it persists after future updates complete or if the ignore popup remains silent. My thought is that pressing ignore would set a property in the preference for silent background checks if auto-check is enabled. This value is then loaded/set based on the persistent json saved date so that whenever it is toggled, the state is saved regardless if the user presses save preferences or not.

Updating the updater module

Currently, when changes are made to addon_updater.py and or addon_updater_ops.py, the developer of each addon that it is used in has to manually updates the files. Is there a way that the updater could update it's own files? There may be some problems if a developer wants to customize the code though...

Question for generalized updater

This is not a requst or a bug but a thought i had about the updating of addons in general.
This addon is very useful but not many developers include it in their addons and i thought it might be possible to make a addon where the user is able to specify the addons he wants to update by providing a list of github links.
Do you think it would be possibe to do something like this and would this updater be able to be extended into a addon updater lime that?
From my experience the tagging and repository hirarchy different developers use might be a problem.
What do you think about this idea?

Show update logs if available

If there are update logs available, display the text of the log.

This would potentially entail parsing and finding a way to better display or show markdown in blender. Some thoughts/related considerations

  • Logs are only available with tags that are also "releases", but may still be blank
  • Currently the updater works based on tags and not releases (the setting "use_releases" still needs to be implemented to alternatively use releases over tags)
  • Be able to display the change log in a UI list
    • Here, we should strip down the markdown code in some meaningful way.
    • Should auto determine the "word wrapping" to generate multiple lines in a scrolling list view
    • If feeling super fancy, could even place inline buttons for web urls; certain icons could be used for things like bullets etc.
  • Remove or just provide direct links to things like images/video
  • There should also be easily available buttons to view the log in the text editor (generate a new text block with full markdown code) as well as to view the release logs online.
  • The first version of showing logs doesn't need the bells and whistles of parsing the markdown, but at minimum needs the word wrapping capabilities.
  • Save current version logs in the json file; upon running check, can even also grab the current version log if not already local (perhaps launch as a secondary background check so that getting the current status is quicker).

Current concept:

log_concept

Add option to install from local folder

Primarily useful for developers, create a configuration that allows reloading the addon from a local folder instead of from online. It may be useful to click inside the addon in blender directly to update code changes. This could be accomplished in a few ways, but an appropriate design may be:

  • If enabled, user pastes in a folderpath
    • This path is to the folder of the init file of where the code sits as it's being developed; need not be a git repo, but pretty much always would be I'd expect
  • Then from the install other/target option, you can select from the dropdown "Local" and press okay
    • Would be nice to even reduce those three clicks (button, dropdown, confirm) into just one without making to make weird UI choices
  • The addon then gets the list of python and resource files available in the blender addons folder, and does a comparison to the files in the target folder: if a file in /blender/addons/updater exists also in /devpath/updater/ then it will copy it over; this prevents the issue of copying .git folders or other files that perhaps you don't need in the target space
  • User would then still be advised to close/reopen blender, but they may also be able to get away with the "refresh" setting enabled.

Personally, I think this will be very useful! I hear there are some developers who already simply use the dev branch for reloading changes to test via committing to dev branch and reloading in blender, this would then be more direct meaning you don't have to push potentially broken code just to easily load into blender.

I'm sure there are also gists or snippets of python code out there for conveniently reloading addons, so perhaps something there could also be leveraged.

update shows wrong version

i added your updater to an addon and noticed that it shows the update to the already installed version.
i was wondering if i possibly did some mistake configuring the update conditions or if this is a issue with the updater.

image

i also had a user report a version downgrade as update
image

Can't install Addon

Im developing in vs code and connecting it to blender via Jacques Luckes extention.
Everything works nicely and no errors but when I push to git, download the release and try to install it from scratch I get this error if I try to enable the addon :

image

It seems that a -0 is added somewhere to the module name but I don't get where .

The repo is here : https://github.com/LorenzWieseke/GLBTextureTools/releases

Thanks in advance !

Support for Bitbucket

Goal: to support Bitbucket hosted code with minimal to no configuration change outside the python module.

Steps to take

  • Initial API exploration nd tests
  • Functional version and code grabbing for public repos
  • Functional with private repos using necessary keys etc

Setup for single-file addons

Currently, the addon updater only supports addons with a .zip configuration. While this is cleanest and most recommended for addons to include additional modules such as this one, it is feasible from a technical standpoint to integrate the updater all into a single file.

The goal here would be to make an additional python demo/source file which has all of the UI and updater module class squashed into one file. The steps to integrate into existing addons would be similar, except instead of including addition files, the developer could just copy-paste all the updater code to the end of their existing single-file addon.

This is just a thought and proposal. Maybe we shouldn't actively try to support this design since it entangles updater code with addon dev code.

GPL license.

So, kinda a high priority issue here. I just realized that the addon updater code is done under the GPL license. This makes it impossible to use under MIT license addons. (Without the addons being switched to GPL). Many people hate this, and it will become unviable very quickly. We are probably going to have to remove this from RenderMan for Blender actually sadly.

Have you thought about dual licensing MIT and GPL? Pretty common, jquery does it for instance.

Ignore operator adds wrong context

v1.0.4

When the Auto-check is in on we see a popup, which is actually already double notification, and then we see the panel with the options. At the bottom it says "X ignore", to my understanding of meaning of ignore. Ignore should ignore the update warning, yet it doesnt. I do see the warning error and that i should check the addon pref. But the menu doesnt go away.

I went on and checked the code. #1284 > addon_updater should be as this:

def ignore_update(self):
	self._json["ignore"] = True
	self.save_updater_json()

When i change this to True, the update panel warning will go away. A tleast i think this how it should have been working. See below screengrab, with example how it is standard and after i edit the code quickly.

autoupdate_warning

version_max_update default

Currently it's 9.9.9... I'd claim it should be higher, i.e if my version is 10.0.0 it won't pass the test.

or do something like set max to -1 or none for no max.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.