├── images ├── demo_gif.gif ├── condensed_ui.png ├── file_diagram.png ├── no_releases.png ├── popup_update.png ├── install_versions.png ├── integrated_panel.png ├── no_releases_found.png ├── updater_preferences.png └── checking_cancel_button.png ├── CONTRIBUTING.md ├── __init__.py ├── tests └── addon_updater_test.py ├── LICENSE.txt ├── README.md └── addon_updater_ops.py /images/demo_gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/demo_gif.gif -------------------------------------------------------------------------------- /images/condensed_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/condensed_ui.png -------------------------------------------------------------------------------- /images/file_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/file_diagram.png -------------------------------------------------------------------------------- /images/no_releases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/no_releases.png -------------------------------------------------------------------------------- /images/popup_update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/popup_update.png -------------------------------------------------------------------------------- /images/install_versions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/install_versions.png -------------------------------------------------------------------------------- /images/integrated_panel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/integrated_panel.png -------------------------------------------------------------------------------- /images/no_releases_found.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/no_releases_found.png -------------------------------------------------------------------------------- /images/updater_preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/updater_preferences.png -------------------------------------------------------------------------------- /images/checking_cancel_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CGCookie/blender-addon-updater/HEAD/images/checking_cancel_button.png -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute to the Blender Addon Updater. 2 | 3 | We use the standard GitHub forking workflow. You can fork this repostiory, make your changes, and then merge them back with a pull request. 4 | 5 | To ensure developers have easy access to the latest version of the addon updater, we only have a single branch. This should be the target of all pull requests. 6 | 7 | ## Running tests 8 | 9 | If you are making anything beyond a trivial change or documentation edit, please try to run the automated tests. There are two ways to run the tests, listed below. However these do not fully cover all behavior of the updater, especially the user interface flow, so be sure to manually test by installing your version of the addon too. Be sure to test the full update/revert flow, which you can manually force by artificially lowering the addon version number (e.g. to 0.1.0). 10 | 11 | Word to the wise: Don't shoot yourself in the foot! Be sure to make your edits to the updater in a place outside of the blender addons folder, and then install it like a normal addon (or use a script to copy the python files into place) between edits. This way you can test the full addon, without risking having your code delete (since the addon updater will indeed replace itself if you trigger an update/install version target). 12 | 13 | ### Run tests from Blender text editor 14 | 15 | Open up any (recent) version of blender, such that you have a console window visible (Windows users: Window > Toggle console, Mac/Linux: start blender from command line). Then, load in the `/tests/addon_updater_test.py` file. Press run, and verify "All tests pass" in the output. 16 | 17 | ### Run tests on command line 18 | 19 | You can run the tests by specifying it as a script to run on command line. For instance: 20 | 21 | ``` 22 | cd tests 23 | Blender -b -P addon_updater_test.py 24 | cd ../ 25 | 26 | ``` 27 | 28 | You should be able to validate you get tests outputs like so: 29 | 30 | ``` 31 | .. 32 | ---------------------------------------------------------------------- 33 | Ran 5 tests in 4.969s 34 | 35 | OK 36 | 37 | ``` 38 | 39 | If there are any errors, please correct these before submitting a pull request! -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | bl_info = { 20 | "name": "Addon Updater Demo", 21 | "description": "Demo addon for showcasing the blender-addon-updater module", 22 | "author": "Patrick W. Crawford, neomonkeus", 23 | "version": (1, 1, 1), 24 | "blender": (2, 80, 0), 25 | "location": "View 3D > Tool Shelf > Demo Updater", 26 | "warning": "", 27 | "wiki_url": "https://github.com/CGCookie/blender-addon-updater", 28 | "tracker_url": "https://github.com/CGCookie/blender-addon-updater/issues", 29 | "category": "System" 30 | } 31 | 32 | 33 | import bpy 34 | 35 | # Updater ops import, all setup in this file. 36 | from . import addon_updater_ops 37 | 38 | 39 | class DemoUpdaterPanel(bpy.types.Panel): 40 | """Panel to demo popup notice and ignoring functionality""" 41 | bl_label = "Updater Demo Panel" 42 | bl_idname = "OBJECT_PT_DemoUpdaterPanel_hello" 43 | bl_space_type = 'VIEW_3D' 44 | bl_region_type = 'TOOLS' if bpy.app.version < (2, 80) else 'UI' 45 | bl_context = "objectmode" 46 | bl_category = "Tools" 47 | 48 | def draw(self, context): 49 | layout = self.layout 50 | 51 | # Call to check for update in background. 52 | # Note: built-in checks ensure it runs at most once, and will run in 53 | # the background thread, not blocking or hanging blender. 54 | # Internally also checks to see if auto-check enabled and if the time 55 | # interval has passed. 56 | addon_updater_ops.check_for_update_background() 57 | 58 | layout.label(text="Demo Updater Addon") 59 | layout.label(text="") 60 | 61 | col = layout.column() 62 | col.scale_y = 0.7 63 | col.label(text="If an update is ready,") 64 | col.label(text="popup triggered by opening") 65 | col.label(text="this panel, plus a box ui") 66 | 67 | # Could also use your own custom drawing based on shared variables. 68 | if addon_updater_ops.updater.update_ready: 69 | layout.label(text="Custom update message", icon="INFO") 70 | layout.label(text="") 71 | 72 | # Call built-in function with draw code/checks. 73 | addon_updater_ops.update_notice_box_ui(self, context) 74 | 75 | 76 | @addon_updater_ops.make_annotations 77 | class DemoPreferences(bpy.types.AddonPreferences): 78 | """Demo bare-bones preferences""" 79 | bl_idname = __package__ 80 | 81 | # Addon updater preferences. 82 | 83 | auto_check_update = bpy.props.BoolProperty( 84 | name="Auto-check for Update", 85 | description="If enabled, auto-check for updates using an interval", 86 | default=False) 87 | 88 | updater_interval_months = bpy.props.IntProperty( 89 | name='Months', 90 | description="Number of months between checking for updates", 91 | default=0, 92 | min=0) 93 | 94 | updater_interval_days = bpy.props.IntProperty( 95 | name='Days', 96 | description="Number of days between checking for updates", 97 | default=7, 98 | min=0, 99 | max=31) 100 | 101 | updater_interval_hours = bpy.props.IntProperty( 102 | name='Hours', 103 | description="Number of hours between checking for updates", 104 | default=0, 105 | min=0, 106 | max=23) 107 | 108 | updater_interval_minutes = bpy.props.IntProperty( 109 | name='Minutes', 110 | description="Number of minutes between checking for updates", 111 | default=0, 112 | min=0, 113 | max=59) 114 | 115 | def draw(self, context): 116 | layout = self.layout 117 | 118 | # Works best if a column, or even just self.layout. 119 | mainrow = layout.row() 120 | col = mainrow.column() 121 | 122 | # Updater draw function, could also pass in col as third arg. 123 | addon_updater_ops.update_settings_ui(self, context) 124 | 125 | # Alternate draw function, which is more condensed and can be 126 | # placed within an existing draw function. Only contains: 127 | # 1) check for update/update now buttons 128 | # 2) toggle for auto-check (interval will be equal to what is set above) 129 | # addon_updater_ops.update_settings_ui_condensed(self, context, col) 130 | 131 | # Adding another column to help show the above condensed ui as one column 132 | # col = mainrow.column() 133 | # col.scale_y = 2 134 | # ops = col.operator("wm.url_open","Open webpage ") 135 | # ops.url=addon_updater_ops.updater.website 136 | 137 | 138 | classes = ( 139 | DemoPreferences, 140 | DemoUpdaterPanel 141 | ) 142 | 143 | 144 | def register(): 145 | # Addon updater code and configurations. 146 | # In case of a broken version, try to register the updater first so that 147 | # users can revert back to a working version. 148 | addon_updater_ops.register(bl_info) 149 | 150 | # Register the example panel, to show updater buttons. 151 | for cls in classes: 152 | addon_updater_ops.make_annotations(cls) # Avoid blender 2.8 warnings. 153 | bpy.utils.register_class(cls) 154 | 155 | 156 | def unregister(): 157 | # Addon updater unregister. 158 | addon_updater_ops.unregister() 159 | for cls in reversed(classes): 160 | bpy.utils.unregister_class(cls) 161 | -------------------------------------------------------------------------------- /tests/addon_updater_test.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | """Tests for the addon updater module python code 20 | 21 | Runs tests for each of the engines and major modules, including integration 22 | tests with the actual services. 23 | 24 | How to run inside blender interface (script editor): 25 | Open this file in a blender text editor, and press run. 26 | Because some code in the addon_updater.py file still require bpy, it must 27 | be run this way in the context of blender. However, tests will run by 28 | directly reading the code next this python file in the git repository. 29 | 30 | How to run from command line (run blender from within tests folder) 31 | # Run all tests 32 | blender -b -P addon_updater_test.py 33 | 34 | # Run all tests within single class 35 | blender -b -P addon_updater_test.py -- TestEngines 36 | 37 | # Run specific test 38 | blender -b -P addon_updater_test.py -- TestEngines.test_gitlab 39 | blender -b -P addon_updater_test.py -- TestFunctions.test_version_tuple_from_text 40 | 41 | Note! Running multiple tests in succession could lead to API rate limitations, 42 | which will manifest primarily as errors in the TestEngines unit tests. 43 | """ 44 | 45 | import os 46 | import sys 47 | import unittest 48 | 49 | import bpy 50 | 51 | if "text" in dir(bpy.context.space_data): 52 | # Running inside the python console in blender 53 | UPDATER_MODULE_DIR = os.path.dirname(os.path.dirname( 54 | bpy.path.abspath(bpy.context.space_data.text.filepath))) 55 | QUIT_ON_COMPLETE = False 56 | else: 57 | # Commandline script passed to blender, directory should be //tests/ 58 | UPDATER_MODULE_DIR = os.path.dirname(os.getcwd()) 59 | QUIT_ON_COMPLETE = True 60 | 61 | sys.path.append(UPDATER_MODULE_DIR) 62 | import addon_updater 63 | 64 | 65 | class TestEngines(unittest.TestCase): 66 | 67 | def test_gitlab(self): 68 | """Test the gitlab updater""" 69 | 70 | updater = addon_updater.SingletonUpdater() 71 | updater.engine = "GitLab" 72 | updater.private_token = None 73 | updater.user = "theduckcow" 74 | updater.repo = "3645616" 75 | updater.website = "https://gitlab.com/TheDuckCow/test-updater-gitlab" 76 | 77 | # Check rate limits 78 | # https://docs.gitlab.com/ee/api/README.html#rate-limits 79 | 80 | self.run_engine_test(updater) 81 | 82 | def test_github(self): 83 | """Test the Github updater""" 84 | 85 | updater = addon_updater.SingletonUpdater() 86 | updater.engine = "Github" 87 | updater.private_token = None 88 | updater.user = "cgcookie" 89 | updater.repo = "blender-addon-updater" 90 | updater.website = "https://github.com/CGCookie/blender-addon-updater" 91 | 92 | # Check rate limitations (command will show if local limit reached) 93 | # curl "https://api.github.com/rate_limit" 94 | # More info: https://developer.github.com/v3/rate_limit/ 95 | 96 | self.run_engine_test(updater) 97 | 98 | def test_bitbucket(self): 99 | """Test the Bitbucket updater""" 100 | 101 | updater = addon_updater.SingletonUpdater() 102 | updater.engine = "Bitbucket" 103 | updater.private_token = None 104 | updater.user = "theduckcow" 105 | updater.repo = "blender-addon-updater-bitbucket" 106 | updater.website = "https://bitbucket.org/TheDuckCow/blender-addon-updater-bitbucket" 107 | 108 | # Check rate limitations 109 | # https://confluence.atlassian.com/bitbucket/rate-limits-668173227.html 110 | 111 | self.run_engine_test(updater) 112 | 113 | def run_engine_test(self, updater): 114 | """Run a test for a single engine.""" 115 | 116 | # Redefine where updating occurs within testing framework 117 | os.path.join(UPDATER_MODULE_DIR, "") 118 | updater._addon = "test_updater" 119 | updater._addon_package = "" 120 | updater._updater_path = os.path.join(UPDATER_MODULE_DIR, "test_updater") 121 | updater._addon_root = UPDATER_MODULE_DIR 122 | updater.verbose = False 123 | 124 | updater.current_version = (1, 0, 0) 125 | updater.backup_current = False 126 | updater.include_branches = True 127 | updater.use_releases = False 128 | 129 | # Test raw API call 130 | tag_url = updater.form_tags_url() 131 | _ = updater.form_branch_url("master") 132 | # branch_url = updater.form_branch_url("master") 133 | # parsed_tag = updater._engine.parse_tags() 134 | 135 | # verify ths raw request doesn't fail 136 | res = updater.get_raw(tag_url) 137 | self.assertIsNotNone(res) 138 | self.assertNotEqual(res, "") 139 | 140 | # verify and check output of parse request 141 | res = updater.get_api(tag_url) 142 | self.assertIsNotNone(res) 143 | self.assertTrue(len(res) > 0) 144 | 145 | # Test the end to end get tag names request 146 | tags = updater._get_tag_names() 147 | self.assertTrue(len(tags) > 0) 148 | # print("Found {} tags".format(len(tags))) 149 | 150 | # Grab link to an archive (should be master for all) 151 | link = updater.select_link(updater, updater._tags[0]) 152 | self.assertIsNotNone(link) 153 | # print(link) 154 | 155 | # Test downloading to the staging folder, 156 | # clear folder first if needed 157 | staged_master = updater.stage_repository(link) 158 | self.assertTrue(staged_master) 159 | 160 | # now try downloading a non-master branch 161 | link = updater.select_link(updater, updater._tags[1]) 162 | self.assertIsNotNone(link) 163 | staged_tag = updater.stage_repository(link) 164 | self.assertTrue(staged_tag) 165 | 166 | # Test the synchronous check function, knowing it should have an update 167 | updater._update_ready = None 168 | updater.check_for_update() 169 | self.assertTrue(updater._update_ready) 170 | 171 | # Test the synchronous check function, knowing it should have no update 172 | updater.current_version = (99, 0, 0) 173 | updater._update_ready = None 174 | updater.check_for_update() 175 | self.assertFalse(updater._update_ready) 176 | 177 | 178 | class TestFunctions(unittest.TestCase): 179 | """Unit tests not dependent on specific updater engines. 180 | 181 | Test will run with the GitHub engine 182 | 183 | TODO, add: 184 | # set_check_interval 185 | # create_backup 186 | # run_update 187 | # restore_backup 188 | # unpack_staged_zip 189 | # deepMergeDirectory 190 | # set_updater_json 191 | # set_tag 192 | # test with different min/max update versions set 193 | """ 194 | 195 | def test_version_tuple_from_text(self): 196 | """Test tuple extraction examples""" 197 | 198 | updater = addon_updater.SingletonUpdater() 199 | updater.include_branches = False # otherwise could treat as branch name 200 | 201 | # structure of: input, expected 202 | test_cases = [ 203 | ["0.0.0", (0, 0, 0)], 204 | ["v0.0.0", (0, 0, 0)], 205 | ["v0.0", (0, 0)], 206 | ["v0.0 beta", (0, 0)], 207 | ["version 1,2,3 beta", (1, 2, 3)] 208 | ] 209 | 210 | for case in test_cases: 211 | res = updater.version_tuple_from_text(case[0]) 212 | self.assertEqual(res, case[1]) 213 | 214 | def test_reload_callback(self): 215 | """Test the reload function which disables and re-enables addon""" 216 | updater = addon_updater.SingletonUpdater() 217 | updater.auto_reload_post_update = True 218 | updater._addon_package = "blender-addon-updater" # test override 219 | updater.reload_addon() # assert no error 220 | 221 | 222 | if __name__ == '__main__': 223 | print("Running Updater Tests") 224 | if QUIT_ON_COMPLETE: 225 | # Running in command line, exclude blender startup args 226 | test_args = (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []) 227 | sys.argv = [os.path.basename(__file__)] + test_args 228 | unittest.main(exit=QUIT_ON_COMPLETE, argv=sys.argv) 229 | else: 230 | # Running within blender UI script 231 | unittest.main(exit=QUIT_ON_COMPLETE) 232 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | Blender Addon Updater 635 | Copyright (C) 2016 Patrick W. Crawford 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Blender Addon Updater Copyright (C) 2016 Patrick W. Crawford 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blender Addon Updater 2 | 3 | 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. 4 | 5 | ![alt](/images/demo_gif.gif) 6 | 7 | 8 | :warning: **Please [see this page on known issues](https://github.com/CGCookie/blender-addon-updater/issues?q=is%3Aissue+is%3Aopen+label%3A%22Known+Issue%22), including available workarounds** 9 | 10 | *Want to add this code to your addon? [See this tutorial here](http://theduckcow.com/2016/addon-updater-tutorial/)* 11 | 12 | This addon has been updated and still works from Blender 2.7 through 3.0, see [this section below](https://github.com/CGCookie/blender-addon-updater#blender-27-and-28). 13 | 14 | 15 | # Key Features 16 | *From the user perspective* 17 | 18 | - Uses [GitHub](https://github.com/), [GitLab](http://gitlab.com/) or [Bitbucket](https://bitbucket.org) repositories for source of versions and code 19 | - All mentions of GitHub hereafter also apply to GitLab and Bitbucket unless called out separately 20 | - One-click to check if update is available 21 | - Auto-check: Ability to automatically check for updates in the background (user must enable) 22 | - Ability to set the interval of time between background checks (if auto-check enabled) 23 | - On a background check for update, contextual popup to tell user update available 24 | - One-click button to install update 25 | - Ability to install other (e.g. older or dev) versions of the addon 26 | 27 | With this module, there are essentially 3 different configurations: 28 | - 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) 29 | - 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) 30 | - 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) 31 | 32 | 33 | *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.* 34 | 35 | # High level setup 36 | 37 | This module works by utilizing git releases on a repository. When a [release](https://github.com/CGCookie/blender-addon-updater/releases) or [tag](https://github.com/CGCookie/blender-addon-updater/tags) 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. 38 | 39 | ![alt](/images/file_diagram.png) 40 | 41 | 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. 42 | 43 | `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. 44 | 45 | `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. 46 | 47 | 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". 48 | 49 | # About the example addon 50 | 51 | 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. 52 | 53 | # Step-by-step as-is integration with existing addons 54 | 55 | *These steps are for the configuration that provides notifications of new releases and allows one-click installation* 56 | 57 | *These steps are also represented more thoroughly in [this text tutorial](http://theduckcow.com/2016/addon-updater-tutorial/)* 58 | 59 | 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 60 | 61 | 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` 62 | 63 | 3) In the register function of `__init__.py`, run the addon's def register() function by adding `addon_updater_ops.register(bl_info)`. 64 | - 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. 65 | 66 | 4) 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. 67 | - 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. 68 | - If using GitLab or Bitbucket, then you must also assign the according engine value, the rest is the same setup. 69 | 70 | 5) 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. 71 | - 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 72 | 73 | - 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. 74 | - 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. 75 | 76 | 6) 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. 77 | 78 | ``` 79 | # addon updater preferences from `__init__`, be sure to copy all of them 80 | 81 | auto_check_update = bpy.props.BoolProperty( 82 | name = "Auto-check for Update", 83 | description = "If enabled, auto-check for updates using an interval", 84 | default = False, 85 | ) 86 | 87 | .... 88 | 89 | updater_interval_minutes = bpy.props.IntProperty( 90 | name='Minutes', 91 | description = "Number of minutes between checking for updates", 92 | default=0, 93 | min=0, 94 | max=59 95 | ) 96 | ``` 97 | 98 | 7) To support Blender version > 2.80, make one (not necessairly both) of these changes: 99 | 100 | a. Add the decorator `@addon_updater_ops.make_annotations` before your addon's user preferences class ([see here](https://github.com/CGCookie/blender-addon-updater/blob/master/__init__.py#L76)) 101 | 102 | b. Call `make_annotations()`, passing your addon's user preferences class as an input, inside a register function ([see here](https://github.com/CGCookie/blender-addon-updater/blob/master/__init__.py#L152)) 103 | 104 | 8) 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()` 105 | - Again make sure to import the Operator File if this panel is defined in a file other than the addon's `__init__.py` file. 106 | - 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. 107 | 108 | 9) Ensure at least one [release or tag](https://help.github.com/articles/creating-releases/) exists on the GitHub repository 109 | - 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'] 110 | - If no releases are found, the user preferences button will always show "Update to Master" without doing any version checking 111 | 112 | 113 | # Minimal example setup / use cases 114 | 115 | 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. 116 | 117 | **Required settings** *Attributes to define before any other use case, to be defined in the registration of the addon* 118 | 119 | ``` 120 | from .addon_updater import Updater as updater # for example 121 | # updater.engine left at default assumes GitHub api/structure 122 | updater.user = "cgcookie" 123 | updater.repo = "blender-addon-updater" 124 | updater.current_version = bl_info["version"] 125 | ``` 126 | 127 | **Check for update** *(foreground using/blocking the main thread, after pressing an explicit "check for update button" - blender will hang)* 128 | 129 | ``` 130 | updater.check_for_update_now() 131 | 132 | # convenience returns, values also saved internally to updater object 133 | (update_ready, version, link) = updater.check_for_update() 134 | 135 | ``` 136 | 137 | **Check for update** *(foreground using background thread, i.e. after pressing an explicit "check for update button")* 138 | 139 | ``` 140 | updater.check_for_update_now(callback=None) 141 | ``` 142 | 143 | **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)* 144 | 145 | ``` 146 | updater.check_for_update_async(background_update_callback) 147 | # callback could be the function object to trigger a popup if result has updater.update_ready == True 148 | ``` 149 | 150 | **Update to newest version available** *(Must have already checked for an update. This uses/blocks the main thread)* 151 | 152 | ``` 153 | if updater.update_ready == True: 154 | res = updater.run_update(force=False, revert_tag=None, callback=function_obj) 155 | if res == 0: 156 | print("Update ran successfully, restart blender") 157 | else: 158 | print("Updater returned " + str(res) + ", error occurred") 159 | elif updater.update_ready == False: 160 | print("No update available") 161 | elif updater.update_ready == None: 162 | print("You need to check for an update first") 163 | ``` 164 | 165 | **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)* 166 | 167 | ``` 168 | tag_version = updater.tags[2] # or otherwise select a valid tag 169 | res = updater.run_update(force=False, revert_tag=None, callback=function_obj) 170 | if res == 0: 171 | print("Update ran successfully, restart blender") 172 | else: 173 | print("Updater returned " + str(res) + ", error occurred") 174 | ``` 175 | 176 | 177 | If utilizing updater.include_branches, you can grab the latest release tag by skipping the branches included (which appear first in the tags list) 178 | 179 | ``` 180 | n = len(updater.include_branch_list) 181 | tag_version = updater.tags[n] # or otherwise select a valid tag 182 | res = updater.run_update(force=False, revert_tag=None, callback=function_obj) 183 | if res == 0: 184 | print("Update ran successfully, restart blender") 185 | else: 186 | print("Updater returned " + str(res) + ", error occurred") 187 | ``` 188 | 189 | 190 | 191 | # addon_updater module settings 192 | 193 | 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. 194 | 195 | **Example changing or applying a setting:** 196 | 197 | ``` 198 | from .addon_updater import Updater as updater 199 | updater.addon = "addon_name" 200 | ``` 201 | 202 | *Required settings* 203 | 204 | - **current_version:** The current version of the installed addon, typically acquired from bl_info 205 | - Type: Tuple, e.g. (1,1,0) or (1,1) or bl_info["version"] 206 | - **repo:** The name of the repository as found in the GitHub link 207 | - Type: String, e.g. "blender-addon-updater" 208 | - Note: Make sure to use the correct repo name based on the api engine used; {repo_name} is found in the following places: 209 | - GitHub: Retrieved from the url of the repository link. Example: https://github.com/cgcookie/{repo_name} 210 | - Bitbucket: Retrieved from the url of the repository link. Example: https://bitbucket.org/cgcookie/{repo_name} 211 | - GitLab: You must go to the repository settings page, and use the *project ID* provided; note that this is a (string-formated) number, not a readable name. Example url where found: https://gitlab.com/TheDuckCow/test-updater-gitlab/edit, only visible to owner/editors. 212 | - **user:** The name of the user the repository belongs to 213 | - Type: String, e.g. "cgcookie" 214 | - Note: Required but not actually used with GitLab engine enabled 215 | 216 | *Optional settings* 217 | 218 | - **engine:** 219 | - Type: String, one of: ["github","gitlab","bitbucket"], not case sensitive 220 | - Default: "github" 221 | - 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 222 | - **private_token:** 223 | - Type: String 224 | - Default: None 225 | - Currently only supports private tokens for GitLab. Used only for granting access to private repositories for updating. 226 | - WARNING: Before providing or using a personal token, [PLEASE READ SECURITY COCNERN SECTION BELOW](https://github.com/CGCookie/blender-addon-updater/tree/dev#security-concerns-with-private-repositories) 227 | - **addon:** 228 | - Type: String, e.g. "demo_addon_updater" 229 | - 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 230 | - 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. 231 | - **auto_reload_post_update:** If True, attempt to auto disable, refresh, and then re-enable the addon without needing to close blender 232 | - Type: Bool, e.g. False 233 | - Default: False 234 | - 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. 235 | - 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. 236 | - 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. 237 | - **fake_install:** Used for debugging, to simulate in the user interface installing an update without actually modifying any files 238 | - Type: Bool, e.g. False 239 | - Default: False 240 | - Notes: Should be only used for debugging, and always set to false for production 241 | - **updater_path:** Path location of stored JSON state file, backups, and staging of installing a new version 242 | - Type: String, absolute path location 243 | - Default: "{path to blender files}/addons/{addon name}/{addon name}_updater/" 244 | - **verbose:** A debugging setting that prints additional information to the console 245 | - Type: Bool, e.g. False 246 | - Default: False 247 | - 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 248 | - **website:** Website for this addon, specifically for manually downloading the addon 249 | - Type: String, valid url 250 | - Default: None 251 | - 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. 252 | - **backup_current** Create a backup of the current code when performing an update or reversion. 253 | - **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 254 | - Type: List of strings, each item follows a match pattern supported by the python module fnmatch 255 | - Default: `[]`, which is internally made equivalent to `["*.py","*.pyc"]` 256 | - 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. 257 | - Examples: 258 | - `["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. 259 | - `["*.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 260 | - `["*"]` 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. 261 | // 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. 262 | - `[]` or `["*.py","*.pyc"]` matches default blender behavior, ie same effect if user installs update manually through blender interface without deleting the existing addon first 263 | - **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 264 | - Type: List of strings, each item follows a match pattern supported by the python module fnmatch 265 | - Default: `[]`, recommended/as configured in demo addon: ["*.pyc"] 266 | - 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. 267 | - Examples: 268 | - `["*"]` 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) 269 | - `["*.pyc"]` means pycache files are always removed prior to update, which is a safe 270 | - **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) 271 | - Type: List of strings 272 | - Default: None 273 | - 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 274 | - **manual_only:** A setting which will permit only manual installs and not one-click updates 275 | - Type: Bool, e.g. False 276 | - Default: False 277 | - 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. 278 | - **showpopups:** A setting which when enabled will allow for popup notifications for new updates 279 | - Type: Bool, e.g. False 280 | - Default: True 281 | - 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. 282 | - **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 283 | - Type: Tuple e.g. (1,2) or (1,2,3), should match the number of separators in bl_info 284 | - Default: None 285 | - Notes: 286 | - 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. 287 | - 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. 288 | - 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. 289 | - **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 290 | - Type: Tuple e.g. (1,2) or (1,2,3), should match the number of separators in bl_info 291 | - Default: None 292 | - Notes: 293 | - 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. 294 | - 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. 295 | - **skip_tag:** A setting which defines how to pre-process tag names 296 | - Type: Function, see example method `skip_tag_function` in the Operator File 297 | - Default: `skip_tag_function` defined in `addon_updater_ops.py` 298 | - 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. 299 | - **subfolder_path:** Define the root location of the `__init__.py` file in the repository 300 | - Type: String 301 | - Default: "", meaning the root repository folder 302 | - 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 303 | - **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 304 | - Type: Bool 305 | - Default: False 306 | - 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) 307 | 308 | *User preference defined (ie optional but good to expose to user)* 309 | 310 | - **check_interval_enable:** Allow for background checking. 311 | - **check_interval_minutes:** Set the interval of minutes between the previous check for update and the next 312 | - **check_interval_hours:** Set the interval of hours between the previous check for update and the next 313 | - **check_interval_days:** Set the interval of days between the previous check for update and the next 314 | - **check_interval_months:** Set the interval of months between the previous check for update and the next 315 | 316 | *Internal values (read only by the Python Module)* 317 | 318 | - **addon_package:** The package name of the addon, used for enabling or disabling the addon 319 | - Type: String 320 | - Default: `__package__` 321 | - Must use the provided default value of `__package__` , automatically assigned 322 | - **addon_root:** The location of the root of the updater file 323 | - Type: String, path 324 | - Default: `os.path.dirname(__file__)` 325 | - **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 326 | - Type: Bool 327 | - Default: False 328 | - Notes: 329 | - This may be used as a flag for conditional drawing, e.g. to draw a "checking for update" button while checking in the background 330 | - 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 331 | - **json:** Contains important state information about the updater 332 | - Type: Dictionary with string keys 333 | - Default: {} 334 | - 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. 335 | - **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. 336 | - Type: String, OS path 337 | - Default: None 338 | - Notes: Path to the zip file named source.zip already downloaded 339 | - **tag_latest** Returns the most recent tag or version of the addon online 340 | - Type: String, URL 341 | - Default: None 342 | - **tag_names** Returns a list of the names (versions) for each tag of the addon online 343 | - Type: list 344 | - Default: [] 345 | - Note: this is analogous to reading tags from outside the Python Module. 346 | - **tags:** Contains a list of the tags (version numbers) of the addon 347 | - Type: list 348 | - Default: [] 349 | - 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. 350 | - **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. 351 | - **update_ready:** Indicates if an update is ready 352 | - Type: Bool 353 | - Default: None 354 | - Notes: 355 | - Set to be True if a tag of a higher version number is found after checking for updates 356 | - Set to be False if a tag of a higher version number is not found after checking for updates 357 | - Set to be None before a check has been performed or cached 358 | - 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 359 | - **update_version:** The version of the update downloaded or targeted 360 | - Type: String 361 | - Default: None 362 | - 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 363 | - **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` 364 | - Type: String 365 | - Default: None 366 | - 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)` 367 | - **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` 368 | - Type: String 369 | - Default: None 370 | - 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)` 371 | 372 | 373 | 374 | # About addon_updater_ops 375 | 376 | 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. 377 | 378 | ### User preferences UI 379 | 380 | ![Alt](/images/updater_preferences.png) 381 | 382 | 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) 383 | 384 | ![Alt](/images/condensed_ui.png) 385 | 386 | 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 387 | 388 | ### Integrated panel UI 389 | 390 | ![Alt](/images/integrated_panel.png) 391 | 392 | *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.* 393 | 394 | ### Popup notice after new update found 395 | 396 | ![Alt](/images/popup_update.png) 397 | 398 | *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.* 399 | 400 | 401 | ### Install different addon versions 402 | 403 | ![Alt](/images/install_versions.png) 404 | 405 | *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.* 406 | 407 | 408 | ### If your repository doesn't have any releases... 409 | 410 | ![Alt](/images/no_releases.png) 411 | 412 | *This is what you will find. See below on creating tags and releases* 413 | 414 | 415 | # How to use git and tags/releases 416 | 417 | ## What are they 418 | 419 | From a [good reference website](https://git-scm.com/book/en/v2/Git-Basics-Tagging), 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. 420 | 421 | ## Through the interface (GitHub specific) 422 | 423 | 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. 424 | 425 | ## Through command line (for any git-based system) 426 | 427 | To show all tags on your local git repository use `git tag` 428 | 429 | 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. 430 | 431 | 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 432 | 433 | # Configuring what files are removed, overwritten, or left alone during update 434 | 435 | 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 436 | 437 | **I don't understand this feature and I just want to use the default configuration which matches blender's install behavior** 438 | 439 | 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. 440 | 441 | ``` 442 | # 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 443 | updater.overwrite_patterns = ["*.py","*.pyc"] 444 | # don't delete any files preemptively 445 | updater.remove_pre_update_patterns = [ ] 446 | ``` 447 | 448 | If you wanted to instead match the default behavior of the addon updater pre v1.0.4, then use the following 449 | ``` 450 | # overwrite any file found in the local install which has a corresponding file in the update 451 | updater.overwrite_patterns = ["*"] 452 | # don't delete any files files preemptively 453 | updater.remove_pre_update_patterns = [ ] 454 | ``` 455 | 456 | **I want to shoot myself in the foot and make updating not work at all** 457 | 458 | Or in other words... *don't* use the following setup, as it effectively prevents the updater from updating anything at all! 459 | 460 | ``` 461 | # don't overwrite any files matching the local install in the update 462 | updater.overwrite_patterns = [ ] 463 | # don't delete any files files preemptively 464 | updater.remove_pre_update_patterns = [ ] 465 | ``` 466 | 467 | 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. 468 | 469 | 470 | **Addon contains only py files, no resources (e.g. JSON files, images, blends), and against better judgment, not even licenses or readme files** 471 | 472 | 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). 473 | 474 | 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. 475 | 476 | 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. 477 | 478 | 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. 479 | 480 | **Addon contains py files and resource files, but no user/local configuration files** 481 | 482 | 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. 483 | 484 | 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. 485 | 486 | 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. 487 | 488 | ``` 489 | updater.overwrite_patterns = ["README.md", "*.blend"] 490 | ``` 491 | 492 | 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. 493 | 494 | 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. 495 | 496 | ``` 497 | updater.remove_pre_update_patterns = ["*.py","*.pyc"] 498 | ``` 499 | 500 | 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. 501 | 502 | **Addon contains py files, resource files, and user/local configuration files** 503 | 504 | This is the most intricate setup, but layers on more useful behavior even in unique situations. 505 | 506 | 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. 507 | 508 | ``` 509 | # example addon setup 510 | __init__.py 511 | module.py 512 | icons/custom_icon.png 513 | images/ # folder where custom png images will be installed 514 | README.md 515 | assets/default.blend 516 | assets/customizable.blend 517 | 518 | ``` 519 | 520 | To accomplish the mentioned behavior, use the below configuration. 521 | 522 | ``` 523 | updater.overwrite_patterns = ["README.md", "custom_icon.png"] 524 | updater.remove_pre_update_patterns = ["*.py", "*.pyc", "default.blend"] 525 | ``` 526 | 527 | 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. 528 | 529 | 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. 530 | 531 | 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. 532 | 533 | 534 | **In conclusion** 535 | 536 | 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. 537 | 538 | 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` 539 | 540 | 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 541 | 542 | The patterns only match to filenames, so there is no use in including in paths like assets/icon.png or directory names. 543 | 544 | 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. 545 | 546 | 547 | # Blender 2.7 and 2.8 548 | 549 | 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) 550 | 551 | 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: 552 | 553 | 1) Make the addon work for 2.7x and 2.8+ simultaneously (in the same way that this module and demo addon does). 554 | - This requires some extra work, in particular note the workaround of annotations as accomplished by the `make_annotations` function. 555 | 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. 556 | - 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. 557 | - 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. 558 | - 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. 559 | - 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. 560 | 3) Parallel version releases with build attachments for each new version. 561 | - 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). 562 | - 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 563 | - This does require releasing the 2.7x and 2.8 code at the same time 564 | - 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 565 | - For reference, this is essentially the method developers use to maintain and distribute updates for operating-specific builds of addons 566 | 567 | 568 | # Security concerns with private repositories 569 | 570 | 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. 571 | 572 | 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: 573 | - GitLab: Supported through Personal Tokens 574 | - Tokens are not needed and should not be used for public repositories 575 | - Personal access tokens can be [viewed and created here](https://gitlab.com/profile/personal_access_tokens) 576 | - 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. 577 | - Tokens should be enabled for api *read access* only, to limit (mis) uses. 578 | - 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. 579 | - 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. 580 | - 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. 581 | - 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. 582 | - GitHub: Not yet supported. Likely to only be included via community contribution. 583 | - Bitbucket: Not yet supported. Likely to only be included via community contribution. 584 | 585 | # Issues or help 586 | 587 | If you are attempting to integrate this code into your addon and run into problems, [please open a new issue](https://github.com/CGCookie/blender-addon-updater/issues). As the module improves, it will be easier for more developers to integrate updating and improve blender's user experience overall! 588 | 589 | 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. 590 | -------------------------------------------------------------------------------- /addon_updater_ops.py: -------------------------------------------------------------------------------- 1 | # ##### BEGIN GPL LICENSE BLOCK ##### 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software Foundation, 15 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | # 17 | # ##### END GPL LICENSE BLOCK ##### 18 | 19 | """Blender UI integrations for the addon updater. 20 | 21 | Implements draw calls, popups, and operators that use the addon_updater. 22 | """ 23 | 24 | import os 25 | import traceback 26 | 27 | import bpy 28 | from bpy.app.handlers import persistent 29 | 30 | # Safely import the updater. 31 | # Prevents popups for users with invalid python installs e.g. missing libraries 32 | # and will replace with a fake class instead if it fails (so UI draws work). 33 | try: 34 | from .addon_updater import Updater as updater 35 | except Exception as e: 36 | print("ERROR INITIALIZING UPDATER") 37 | print(str(e)) 38 | traceback.print_exc() 39 | 40 | class SingletonUpdaterNone(object): 41 | """Fake, bare minimum fields and functions for the updater object.""" 42 | 43 | def __init__(self): 44 | self.invalid_updater = True # Used to distinguish bad install. 45 | 46 | self.addon = None 47 | self.verbose = False 48 | self.use_print_traces = True 49 | self.error = None 50 | self.error_msg = None 51 | self.async_checking = None 52 | 53 | def clear_state(self): 54 | self.addon = None 55 | self.verbose = False 56 | self.invalid_updater = True 57 | self.error = None 58 | self.error_msg = None 59 | self.async_checking = None 60 | 61 | def run_update(self, force, callback, clean): 62 | pass 63 | 64 | def check_for_update(self, now): 65 | pass 66 | 67 | updater = SingletonUpdaterNone() 68 | updater.error = "Error initializing updater module" 69 | updater.error_msg = str(e) 70 | 71 | # Must declare this before classes are loaded, otherwise the bl_idname's will 72 | # not match and have errors. Must be all lowercase and no spaces! Should also 73 | # be unique among any other addons that could exist (using this updater code), 74 | # to avoid clashes in operator registration. 75 | updater.addon = "addon_updater_demo" 76 | 77 | 78 | # ----------------------------------------------------------------------------- 79 | # Blender version utils 80 | # ----------------------------------------------------------------------------- 81 | def make_annotations(cls): 82 | """Add annotation attribute to fields to avoid Blender 2.8+ warnings""" 83 | if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80): 84 | return cls 85 | if bpy.app.version < (2, 93, 0): 86 | bl_props = {k: v for k, v in cls.__dict__.items() 87 | if isinstance(v, tuple)} 88 | else: 89 | bl_props = {k: v for k, v in cls.__dict__.items() 90 | if isinstance(v, bpy.props._PropertyDeferred)} 91 | if bl_props: 92 | if '__annotations__' not in cls.__dict__: 93 | setattr(cls, '__annotations__', {}) 94 | annotations = cls.__dict__['__annotations__'] 95 | for k, v in bl_props.items(): 96 | annotations[k] = v 97 | delattr(cls, k) 98 | return cls 99 | 100 | 101 | def layout_split(layout, factor=0.0, align=False): 102 | """Intermediate method for pre and post blender 2.8 split UI function""" 103 | if not hasattr(bpy.app, "version") or bpy.app.version < (2, 80): 104 | return layout.split(percentage=factor, align=align) 105 | return layout.split(factor=factor, align=align) 106 | 107 | 108 | def get_user_preferences(context=None): 109 | """Intermediate method for pre and post blender 2.8 grabbing preferences""" 110 | if not context: 111 | context = bpy.context 112 | prefs = None 113 | if hasattr(context, "user_preferences"): 114 | prefs = context.user_preferences.addons.get(__package__, None) 115 | elif hasattr(context, "preferences"): 116 | prefs = context.preferences.addons.get(__package__, None) 117 | if prefs: 118 | return prefs.preferences 119 | # To make the addon stable and non-exception prone, return None 120 | # raise Exception("Could not fetch user preferences") 121 | return None 122 | 123 | 124 | # ----------------------------------------------------------------------------- 125 | # Updater operators 126 | # ----------------------------------------------------------------------------- 127 | 128 | 129 | # Simple popup to prompt use to check for update & offer install if available. 130 | class AddonUpdaterInstallPopup(bpy.types.Operator): 131 | """Check and install update if available""" 132 | bl_label = "Update {x} addon".format(x=updater.addon) 133 | bl_idname = updater.addon + ".updater_install_popup" 134 | bl_description = "Popup to check and display current updates available" 135 | bl_options = {'REGISTER', 'INTERNAL'} 136 | 137 | # if true, run clean install - ie remove all files before adding new 138 | # equivalent to deleting the addon and reinstalling, except the 139 | # updater folder/backup folder remains 140 | clean_install = bpy.props.BoolProperty( 141 | name="Clean install", 142 | description=("If enabled, completely clear the addon's folder before " 143 | "installing new update, creating a fresh install"), 144 | default=False, 145 | options={'HIDDEN'} 146 | ) 147 | 148 | ignore_enum = bpy.props.EnumProperty( 149 | name="Process update", 150 | description="Decide to install, ignore, or defer new addon update", 151 | items=[ 152 | ("install", "Update Now", "Install update now"), 153 | ("ignore", "Ignore", "Ignore this update to prevent future popups"), 154 | ("defer", "Defer", "Defer choice till next blender session") 155 | ], 156 | options={'HIDDEN'} 157 | ) 158 | 159 | def check(self, context): 160 | return True 161 | 162 | def invoke(self, context, event): 163 | return context.window_manager.invoke_props_dialog(self) 164 | 165 | def draw(self, context): 166 | layout = self.layout 167 | if updater.invalid_updater: 168 | layout.label(text="Updater module error") 169 | return 170 | elif updater.update_ready: 171 | col = layout.column() 172 | col.scale_y = 0.7 173 | col.label(text="Update {} ready!".format(updater.update_version), 174 | icon="LOOP_FORWARDS") 175 | col.label(text="Choose 'Update Now' & press OK to install, ", 176 | icon="BLANK1") 177 | col.label(text="or click outside window to defer", icon="BLANK1") 178 | row = col.row() 179 | row.prop(self, "ignore_enum", expand=True) 180 | col.split() 181 | elif not updater.update_ready: 182 | col = layout.column() 183 | col.scale_y = 0.7 184 | col.label(text="No updates available") 185 | col.label(text="Press okay to dismiss dialog") 186 | # add option to force install 187 | else: 188 | # Case: updater.update_ready = None 189 | # we have not yet checked for the update. 190 | layout.label(text="Check for update now?") 191 | 192 | # Potentially in future, UI to 'check to select/revert to old version'. 193 | 194 | def execute(self, context): 195 | # In case of error importing updater. 196 | if updater.invalid_updater: 197 | return {'CANCELLED'} 198 | 199 | if updater.manual_only: 200 | bpy.ops.wm.url_open(url=updater.website) 201 | elif updater.update_ready: 202 | 203 | # Action based on enum selection. 204 | if self.ignore_enum == 'defer': 205 | return {'FINISHED'} 206 | elif self.ignore_enum == 'ignore': 207 | updater.ignore_update() 208 | return {'FINISHED'} 209 | 210 | res = updater.run_update(force=False, 211 | callback=post_update_callback, 212 | clean=self.clean_install) 213 | 214 | # Should return 0, if not something happened. 215 | if updater.verbose: 216 | if res == 0: 217 | print("Updater returned successful") 218 | else: 219 | print("Updater returned {}, error occurred".format(res)) 220 | elif updater.update_ready is None: 221 | _ = updater.check_for_update(now=True) 222 | 223 | # Re-launch this dialog. 224 | atr = AddonUpdaterInstallPopup.bl_idname.split(".") 225 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 226 | else: 227 | updater.print_verbose("Doing nothing, not ready for update") 228 | return {'FINISHED'} 229 | 230 | 231 | # User preference check-now operator 232 | class AddonUpdaterCheckNow(bpy.types.Operator): 233 | bl_label = "Check now for " + updater.addon + " update" 234 | bl_idname = updater.addon + ".updater_check_now" 235 | bl_description = "Check now for an update to the {} addon".format( 236 | updater.addon) 237 | bl_options = {'REGISTER', 'INTERNAL'} 238 | 239 | def execute(self, context): 240 | if updater.invalid_updater: 241 | return {'CANCELLED'} 242 | 243 | if updater.async_checking and updater.error is None: 244 | # Check already happened. 245 | # Used here to just avoid constant applying settings below. 246 | # Ignoring if error, to prevent being stuck on the error screen. 247 | return {'CANCELLED'} 248 | 249 | # apply the UI settings 250 | settings = get_user_preferences(context) 251 | if not settings: 252 | updater.print_verbose( 253 | "Could not get {} preferences, update check skipped".format( 254 | __package__)) 255 | return {'CANCELLED'} 256 | 257 | updater.set_check_interval( 258 | enabled=settings.auto_check_update, 259 | months=settings.updater_interval_months, 260 | days=settings.updater_interval_days, 261 | hours=settings.updater_interval_hours, 262 | minutes=settings.updater_interval_minutes) 263 | 264 | # Input is an optional callback function. This function should take a 265 | # bool input. If true: update ready, if false: no update ready. 266 | updater.check_for_update_now(ui_refresh) 267 | 268 | return {'FINISHED'} 269 | 270 | 271 | class AddonUpdaterUpdateNow(bpy.types.Operator): 272 | bl_label = "Update " + updater.addon + " addon now" 273 | bl_idname = updater.addon + ".updater_update_now" 274 | bl_description = "Update to the latest version of the {x} addon".format( 275 | x=updater.addon) 276 | bl_options = {'REGISTER', 'INTERNAL'} 277 | 278 | # If true, run clean install - ie remove all files before adding new 279 | # equivalent to deleting the addon and reinstalling, except the updater 280 | # folder/backup folder remains. 281 | clean_install = bpy.props.BoolProperty( 282 | name="Clean install", 283 | description=("If enabled, completely clear the addon's folder before " 284 | "installing new update, creating a fresh install"), 285 | default=False, 286 | options={'HIDDEN'} 287 | ) 288 | 289 | def execute(self, context): 290 | 291 | # in case of error importing updater 292 | if updater.invalid_updater: 293 | return {'CANCELLED'} 294 | 295 | if updater.manual_only: 296 | bpy.ops.wm.url_open(url=updater.website) 297 | if updater.update_ready: 298 | # if it fails, offer to open the website instead 299 | try: 300 | res = updater.run_update(force=False, 301 | callback=post_update_callback, 302 | clean=self.clean_install) 303 | 304 | # Should return 0, if not something happened. 305 | if updater.verbose: 306 | if res == 0: 307 | print("Updater returned successful") 308 | else: 309 | print("Updater error response: {}".format(res)) 310 | except Exception as expt: 311 | updater._error = "Error trying to run update" 312 | updater._error_msg = str(expt) 313 | updater.print_trace() 314 | atr = AddonUpdaterInstallManually.bl_idname.split(".") 315 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 316 | elif updater.update_ready is None: 317 | (update_ready, version, link) = updater.check_for_update(now=True) 318 | # Re-launch this dialog. 319 | atr = AddonUpdaterInstallPopup.bl_idname.split(".") 320 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 321 | 322 | elif not updater.update_ready: 323 | self.report({'INFO'}, "Nothing to update") 324 | return {'CANCELLED'} 325 | else: 326 | self.report( 327 | {'ERROR'}, "Encountered a problem while trying to update") 328 | return {'CANCELLED'} 329 | 330 | return {'FINISHED'} 331 | 332 | 333 | class AddonUpdaterUpdateTarget(bpy.types.Operator): 334 | bl_label = updater.addon + " version target" 335 | bl_idname = updater.addon + ".updater_update_target" 336 | bl_description = "Install a targeted version of the {x} addon".format( 337 | x=updater.addon) 338 | bl_options = {'REGISTER', 'INTERNAL'} 339 | 340 | def target_version(self, context): 341 | # In case of error importing updater. 342 | if updater.invalid_updater: 343 | ret = [] 344 | 345 | ret = [] 346 | i = 0 347 | for tag in updater.tags: 348 | ret.append((tag, tag, "Select to install " + tag)) 349 | i += 1 350 | return ret 351 | 352 | target = bpy.props.EnumProperty( 353 | name="Target version to install", 354 | description="Select the version to install", 355 | items=target_version 356 | ) 357 | 358 | # If true, run clean install - ie remove all files before adding new 359 | # equivalent to deleting the addon and reinstalling, except the 360 | # updater folder/backup folder remains. 361 | clean_install = bpy.props.BoolProperty( 362 | name="Clean install", 363 | description=("If enabled, completely clear the addon's folder before " 364 | "installing new update, creating a fresh install"), 365 | default=False, 366 | options={'HIDDEN'} 367 | ) 368 | 369 | @classmethod 370 | def poll(cls, context): 371 | if updater.invalid_updater: 372 | return False 373 | return updater.update_ready is not None and len(updater.tags) > 0 374 | 375 | def invoke(self, context, event): 376 | return context.window_manager.invoke_props_dialog(self) 377 | 378 | def draw(self, context): 379 | layout = self.layout 380 | if updater.invalid_updater: 381 | layout.label(text="Updater error") 382 | return 383 | split = layout_split(layout, factor=0.5) 384 | sub_col = split.column() 385 | sub_col.label(text="Select install version") 386 | sub_col = split.column() 387 | sub_col.prop(self, "target", text="") 388 | 389 | def execute(self, context): 390 | # In case of error importing updater. 391 | if updater.invalid_updater: 392 | return {'CANCELLED'} 393 | 394 | res = updater.run_update( 395 | force=False, 396 | revert_tag=self.target, 397 | callback=post_update_callback, 398 | clean=self.clean_install) 399 | 400 | # Should return 0, if not something happened. 401 | if res == 0: 402 | updater.print_verbose("Updater returned successful") 403 | else: 404 | updater.print_verbose( 405 | "Updater returned {}, , error occurred".format(res)) 406 | return {'CANCELLED'} 407 | 408 | return {'FINISHED'} 409 | 410 | 411 | class AddonUpdaterInstallManually(bpy.types.Operator): 412 | """As a fallback, direct the user to download the addon manually""" 413 | bl_label = "Install update manually" 414 | bl_idname = updater.addon + ".updater_install_manually" 415 | bl_description = "Proceed to manually install update" 416 | bl_options = {'REGISTER', 'INTERNAL'} 417 | 418 | error = bpy.props.StringProperty( 419 | name="Error Occurred", 420 | default="", 421 | options={'HIDDEN'} 422 | ) 423 | 424 | def invoke(self, context, event): 425 | return context.window_manager.invoke_popup(self) 426 | 427 | def draw(self, context): 428 | layout = self.layout 429 | 430 | if updater.invalid_updater: 431 | layout.label(text="Updater error") 432 | return 433 | 434 | # Display error if a prior autoamted install failed. 435 | if self.error != "": 436 | col = layout.column() 437 | col.scale_y = 0.7 438 | col.label(text="There was an issue trying to auto-install", 439 | icon="ERROR") 440 | col.label(text="Press the download button below and install", 441 | icon="BLANK1") 442 | col.label(text="the zip file like a normal addon.", icon="BLANK1") 443 | else: 444 | col = layout.column() 445 | col.scale_y = 0.7 446 | col.label(text="Install the addon manually") 447 | col.label(text="Press the download button below and install") 448 | col.label(text="the zip file like a normal addon.") 449 | 450 | # If check hasn't happened, i.e. accidentally called this menu, 451 | # allow to check here. 452 | 453 | row = layout.row() 454 | 455 | if updater.update_link is not None: 456 | row.operator( 457 | "wm.url_open", 458 | text="Direct download").url = updater.update_link 459 | else: 460 | row.operator( 461 | "wm.url_open", 462 | text="(failed to retrieve direct download)") 463 | row.enabled = False 464 | 465 | if updater.website is not None: 466 | row = layout.row() 467 | ops = row.operator("wm.url_open", text="Open website") 468 | ops.url = updater.website 469 | else: 470 | row = layout.row() 471 | row.label(text="See source website to download the update") 472 | 473 | def execute(self, context): 474 | return {'FINISHED'} 475 | 476 | 477 | class AddonUpdaterUpdatedSuccessful(bpy.types.Operator): 478 | """Addon in place, popup telling user it completed or what went wrong""" 479 | bl_label = "Installation Report" 480 | bl_idname = updater.addon + ".updater_update_successful" 481 | bl_description = "Update installation response" 482 | bl_options = {'REGISTER', 'INTERNAL', 'UNDO'} 483 | 484 | error = bpy.props.StringProperty( 485 | name="Error Occurred", 486 | default="", 487 | options={'HIDDEN'} 488 | ) 489 | 490 | def invoke(self, context, event): 491 | return context.window_manager.invoke_props_popup(self, event) 492 | 493 | def draw(self, context): 494 | layout = self.layout 495 | 496 | if updater.invalid_updater: 497 | layout.label(text="Updater error") 498 | return 499 | 500 | saved = updater.json 501 | if self.error != "": 502 | col = layout.column() 503 | col.scale_y = 0.7 504 | col.label(text="Error occurred, did not install", icon="ERROR") 505 | if updater.error_msg: 506 | msg = updater.error_msg 507 | else: 508 | msg = self.error 509 | col.label(text=str(msg), icon="BLANK1") 510 | rw = col.row() 511 | rw.scale_y = 2 512 | rw.operator( 513 | "wm.url_open", 514 | text="Click for manual download.", 515 | icon="BLANK1").url = updater.website 516 | elif not updater.auto_reload_post_update: 517 | # Tell user to restart blender after an update/restore! 518 | if "just_restored" in saved and saved["just_restored"]: 519 | col = layout.column() 520 | col.label(text="Addon restored", icon="RECOVER_LAST") 521 | alert_row = col.row() 522 | alert_row.alert = True 523 | alert_row.operator( 524 | "wm.quit_blender", 525 | text="Restart blender to reload", 526 | icon="BLANK1") 527 | updater.json_reset_restore() 528 | else: 529 | col = layout.column() 530 | col.label( 531 | text="Addon successfully installed", icon="FILE_TICK") 532 | alert_row = col.row() 533 | alert_row.alert = True 534 | alert_row.operator( 535 | "wm.quit_blender", 536 | text="Restart blender to reload", 537 | icon="BLANK1") 538 | 539 | else: 540 | # reload addon, but still recommend they restart blender 541 | if "just_restored" in saved and saved["just_restored"]: 542 | col = layout.column() 543 | col.scale_y = 0.7 544 | col.label(text="Addon restored", icon="RECOVER_LAST") 545 | col.label( 546 | text="Consider restarting blender to fully reload.", 547 | icon="BLANK1") 548 | updater.json_reset_restore() 549 | else: 550 | col = layout.column() 551 | col.scale_y = 0.7 552 | col.label( 553 | text="Addon successfully installed", icon="FILE_TICK") 554 | col.label( 555 | text="Consider restarting blender to fully reload.", 556 | icon="BLANK1") 557 | 558 | def execute(self, context): 559 | return {'FINISHED'} 560 | 561 | 562 | class AddonUpdaterRestoreBackup(bpy.types.Operator): 563 | """Restore addon from backup""" 564 | bl_label = "Restore backup" 565 | bl_idname = updater.addon + ".updater_restore_backup" 566 | bl_description = "Restore addon from backup" 567 | bl_options = {'REGISTER', 'INTERNAL'} 568 | 569 | @classmethod 570 | def poll(cls, context): 571 | try: 572 | return os.path.isdir(os.path.join(updater.stage_path, "backup")) 573 | except: 574 | return False 575 | 576 | def execute(self, context): 577 | # in case of error importing updater 578 | if updater.invalid_updater: 579 | return {'CANCELLED'} 580 | updater.restore_backup() 581 | return {'FINISHED'} 582 | 583 | 584 | class AddonUpdaterIgnore(bpy.types.Operator): 585 | """Ignore update to prevent future popups""" 586 | bl_label = "Ignore update" 587 | bl_idname = updater.addon + ".updater_ignore" 588 | bl_description = "Ignore update to prevent future popups" 589 | bl_options = {'REGISTER', 'INTERNAL'} 590 | 591 | @classmethod 592 | def poll(cls, context): 593 | if updater.invalid_updater: 594 | return False 595 | elif updater.update_ready: 596 | return True 597 | else: 598 | return False 599 | 600 | def execute(self, context): 601 | # in case of error importing updater 602 | if updater.invalid_updater: 603 | return {'CANCELLED'} 604 | updater.ignore_update() 605 | self.report({"INFO"}, "Open addon preferences for updater options") 606 | return {'FINISHED'} 607 | 608 | 609 | class AddonUpdaterEndBackground(bpy.types.Operator): 610 | """Stop checking for update in the background""" 611 | bl_label = "End background check" 612 | bl_idname = updater.addon + ".end_background_check" 613 | bl_description = "Stop checking for update in the background" 614 | bl_options = {'REGISTER', 'INTERNAL'} 615 | 616 | def execute(self, context): 617 | # in case of error importing updater 618 | if updater.invalid_updater: 619 | return {'CANCELLED'} 620 | updater.stop_async_check_update() 621 | return {'FINISHED'} 622 | 623 | 624 | # ----------------------------------------------------------------------------- 625 | # Handler related, to create popups 626 | # ----------------------------------------------------------------------------- 627 | 628 | 629 | # global vars used to prevent duplicate popup handlers 630 | ran_auto_check_install_popup = False 631 | ran_update_success_popup = False 632 | 633 | # global var for preventing successive calls 634 | ran_background_check = False 635 | 636 | 637 | @persistent 638 | def updater_run_success_popup_handler(scene): 639 | global ran_update_success_popup 640 | ran_update_success_popup = True 641 | 642 | # in case of error importing updater 643 | if updater.invalid_updater: 644 | return 645 | 646 | try: 647 | if "scene_update_post" in dir(bpy.app.handlers): 648 | bpy.app.handlers.scene_update_post.remove( 649 | updater_run_success_popup_handler) 650 | else: 651 | bpy.app.handlers.depsgraph_update_post.remove( 652 | updater_run_success_popup_handler) 653 | except: 654 | pass 655 | 656 | atr = AddonUpdaterUpdatedSuccessful.bl_idname.split(".") 657 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 658 | 659 | 660 | @persistent 661 | def updater_run_install_popup_handler(scene): 662 | global ran_auto_check_install_popup 663 | ran_auto_check_install_popup = True 664 | updater.print_verbose("Running the install popup handler.") 665 | 666 | # in case of error importing updater 667 | if updater.invalid_updater: 668 | return 669 | 670 | try: 671 | if "scene_update_post" in dir(bpy.app.handlers): 672 | bpy.app.handlers.scene_update_post.remove( 673 | updater_run_install_popup_handler) 674 | else: 675 | bpy.app.handlers.depsgraph_update_post.remove( 676 | updater_run_install_popup_handler) 677 | except: 678 | pass 679 | 680 | if "ignore" in updater.json and updater.json["ignore"]: 681 | return # Don't do popup if ignore pressed. 682 | elif "version_text" in updater.json and updater.json["version_text"].get("version"): 683 | version = updater.json["version_text"]["version"] 684 | ver_tuple = updater.version_tuple_from_text(version) 685 | 686 | if ver_tuple < updater.current_version: 687 | # User probably manually installed to get the up to date addon 688 | # in here. Clear out the update flag using this function. 689 | updater.print_verbose( 690 | "{} updater: appears user updated, clearing flag".format( 691 | updater.addon)) 692 | updater.json_reset_restore() 693 | return 694 | atr = AddonUpdaterInstallPopup.bl_idname.split(".") 695 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 696 | 697 | 698 | def background_update_callback(update_ready): 699 | """Passed into the updater, background thread updater""" 700 | global ran_auto_check_install_popup 701 | updater.print_verbose("Running background update callback") 702 | 703 | # In case of error importing updater. 704 | if updater.invalid_updater: 705 | return 706 | if not updater.show_popups: 707 | return 708 | if not update_ready: 709 | return 710 | 711 | # See if we need add to the update handler to trigger the popup. 712 | handlers = [] 713 | if "scene_update_post" in dir(bpy.app.handlers): # 2.7x 714 | handlers = bpy.app.handlers.scene_update_post 715 | else: # 2.8+ 716 | handlers = bpy.app.handlers.depsgraph_update_post 717 | in_handles = updater_run_install_popup_handler in handlers 718 | 719 | if in_handles or ran_auto_check_install_popup: 720 | return 721 | 722 | if "scene_update_post" in dir(bpy.app.handlers): # 2.7x 723 | bpy.app.handlers.scene_update_post.append( 724 | updater_run_install_popup_handler) 725 | else: # 2.8+ 726 | bpy.app.handlers.depsgraph_update_post.append( 727 | updater_run_install_popup_handler) 728 | ran_auto_check_install_popup = True 729 | updater.print_verbose("Attempted popup prompt") 730 | 731 | 732 | def post_update_callback(module_name, res=None): 733 | """Callback for once the run_update function has completed. 734 | 735 | Only makes sense to use this if "auto_reload_post_update" == False, 736 | i.e. don't auto-restart the addon. 737 | 738 | Arguments: 739 | module_name: returns the module name from updater, but unused here. 740 | res: If an error occurred, this is the detail string. 741 | """ 742 | 743 | # In case of error importing updater. 744 | if updater.invalid_updater: 745 | return 746 | 747 | if res is None: 748 | # This is the same code as in conditional at the end of the register 749 | # function, ie if "auto_reload_post_update" == True, skip code. 750 | updater.print_verbose( 751 | "{} updater: Running post update callback".format(updater.addon)) 752 | 753 | atr = AddonUpdaterUpdatedSuccessful.bl_idname.split(".") 754 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 755 | global ran_update_success_popup 756 | ran_update_success_popup = True 757 | else: 758 | # Some kind of error occurred and it was unable to install, offer 759 | # manual download instead. 760 | atr = AddonUpdaterUpdatedSuccessful.bl_idname.split(".") 761 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT', error=res) 762 | return 763 | 764 | 765 | def ui_refresh(update_status): 766 | """Redraw the ui once an async thread has completed""" 767 | for windowManager in bpy.data.window_managers: 768 | for window in windowManager.windows: 769 | for area in window.screen.areas: 770 | area.tag_redraw() 771 | 772 | 773 | def check_for_update_background(): 774 | """Function for asynchronous background check. 775 | 776 | *Could* be called on register, but would be bad practice as the bare 777 | minimum code should run at the moment of registration (addon ticked). 778 | """ 779 | if updater.invalid_updater: 780 | return 781 | global ran_background_check 782 | if ran_background_check: 783 | # Global var ensures check only happens once. 784 | return 785 | elif updater.update_ready is not None or updater.async_checking: 786 | # Check already happened. 787 | # Used here to just avoid constant applying settings below. 788 | return 789 | 790 | # Apply the UI settings. 791 | settings = get_user_preferences(bpy.context) 792 | if not settings: 793 | return 794 | updater.set_check_interval(enabled=settings.auto_check_update, 795 | months=settings.updater_interval_months, 796 | days=settings.updater_interval_days, 797 | hours=settings.updater_interval_hours, 798 | minutes=settings.updater_interval_minutes) 799 | 800 | # Input is an optional callback function. This function should take a bool 801 | # input, if true: update ready, if false: no update ready. 802 | updater.check_for_update_async(background_update_callback) 803 | ran_background_check = True 804 | 805 | 806 | def check_for_update_nonthreaded(self, context): 807 | """Can be placed in front of other operators to launch when pressed""" 808 | if updater.invalid_updater: 809 | return 810 | 811 | # Only check if it's ready, ie after the time interval specified should 812 | # be the async wrapper call here. 813 | settings = get_user_preferences(bpy.context) 814 | if not settings: 815 | if updater.verbose: 816 | print("Could not get {} preferences, update check skipped".format( 817 | __package__)) 818 | return 819 | updater.set_check_interval(enabled=settings.auto_check_update, 820 | months=settings.updater_interval_months, 821 | days=settings.updater_interval_days, 822 | hours=settings.updater_interval_hours, 823 | minutes=settings.updater_interval_minutes) 824 | 825 | (update_ready, version, link) = updater.check_for_update(now=False) 826 | if update_ready: 827 | atr = AddonUpdaterInstallPopup.bl_idname.split(".") 828 | getattr(getattr(bpy.ops, atr[0]), atr[1])('INVOKE_DEFAULT') 829 | else: 830 | updater.print_verbose("No update ready") 831 | self.report({'INFO'}, "No update ready") 832 | 833 | 834 | def show_reload_popup(): 835 | """For use in register only, to show popup after re-enabling the addon. 836 | 837 | Must be enabled by developer. 838 | """ 839 | if updater.invalid_updater: 840 | return 841 | saved_state = updater.json 842 | global ran_update_success_popup 843 | 844 | has_state = saved_state is not None 845 | just_updated = "just_updated" in saved_state 846 | updated_info = saved_state["just_updated"] 847 | 848 | if not (has_state and just_updated and updated_info): 849 | return 850 | 851 | updater.json_reset_postupdate() # So this only runs once. 852 | 853 | # No handlers in this case. 854 | if not updater.auto_reload_post_update: 855 | return 856 | 857 | # See if we need add to the update handler to trigger the popup. 858 | handlers = [] 859 | if "scene_update_post" in dir(bpy.app.handlers): # 2.7x 860 | handlers = bpy.app.handlers.scene_update_post 861 | else: # 2.8+ 862 | handlers = bpy.app.handlers.depsgraph_update_post 863 | in_handles = updater_run_success_popup_handler in handlers 864 | 865 | if in_handles or ran_update_success_popup: 866 | return 867 | 868 | if "scene_update_post" in dir(bpy.app.handlers): # 2.7x 869 | bpy.app.handlers.scene_update_post.append( 870 | updater_run_success_popup_handler) 871 | else: # 2.8+ 872 | bpy.app.handlers.depsgraph_update_post.append( 873 | updater_run_success_popup_handler) 874 | ran_update_success_popup = True 875 | 876 | 877 | # ----------------------------------------------------------------------------- 878 | # Example UI integrations 879 | # ----------------------------------------------------------------------------- 880 | def update_notice_box_ui(self, context): 881 | """Update notice draw, to add to the end or beginning of a panel. 882 | 883 | After a check for update has occurred, this function will draw a box 884 | saying an update is ready, and give a button for: update now, open website, 885 | or ignore popup. Ideal to be placed at the end / beginning of a panel. 886 | """ 887 | 888 | if updater.invalid_updater: 889 | return 890 | 891 | saved_state = updater.json 892 | if not updater.auto_reload_post_update: 893 | if "just_updated" in saved_state and saved_state["just_updated"]: 894 | layout = self.layout 895 | box = layout.box() 896 | col = box.column() 897 | alert_row = col.row() 898 | alert_row.alert = True 899 | alert_row.operator( 900 | "wm.quit_blender", 901 | text="Restart blender", 902 | icon="ERROR") 903 | col.label(text="to complete update") 904 | return 905 | 906 | # If user pressed ignore, don't draw the box. 907 | if "ignore" in updater.json and updater.json["ignore"]: 908 | return 909 | if not updater.update_ready: 910 | return 911 | 912 | layout = self.layout 913 | box = layout.box() 914 | col = box.column(align=True) 915 | col.alert = True 916 | col.label(text="Update ready!", icon="ERROR") 917 | col.alert = False 918 | col.separator() 919 | row = col.row(align=True) 920 | split = row.split(align=True) 921 | colL = split.column(align=True) 922 | colL.scale_y = 1.5 923 | colL.operator(AddonUpdaterIgnore.bl_idname, icon="X", text="Ignore") 924 | colR = split.column(align=True) 925 | colR.scale_y = 1.5 926 | if not updater.manual_only: 927 | colR.operator(AddonUpdaterUpdateNow.bl_idname, 928 | text="Update", icon="LOOP_FORWARDS") 929 | col.operator("wm.url_open", text="Open website").url = updater.website 930 | # ops = col.operator("wm.url_open",text="Direct download") 931 | # ops.url=updater.update_link 932 | col.operator(AddonUpdaterInstallManually.bl_idname, 933 | text="Install manually") 934 | else: 935 | # ops = col.operator("wm.url_open", text="Direct download") 936 | # ops.url=updater.update_link 937 | col.operator("wm.url_open", text="Get it now").url = updater.website 938 | 939 | 940 | def update_settings_ui(self, context, element=None): 941 | """Preferences - for drawing with full width inside user preferences 942 | 943 | A function that can be run inside user preferences panel for prefs UI. 944 | Place inside UI draw using: 945 | addon_updater_ops.update_settings_ui(self, context) 946 | or by: 947 | addon_updater_ops.update_settings_ui(context) 948 | """ 949 | 950 | # Element is a UI element, such as layout, a row, column, or box. 951 | if element is None: 952 | element = self.layout 953 | box = element.box() 954 | 955 | # In case of error importing updater. 956 | if updater.invalid_updater: 957 | box.label(text="Error initializing updater code:") 958 | box.label(text=updater.error_msg) 959 | return 960 | settings = get_user_preferences(context) 961 | if not settings: 962 | box.label(text="Error getting updater preferences", icon='ERROR') 963 | return 964 | 965 | # auto-update settings 966 | box.label(text="Updater Settings") 967 | row = box.row() 968 | 969 | # special case to tell user to restart blender, if set that way 970 | if not updater.auto_reload_post_update: 971 | saved_state = updater.json 972 | if "just_updated" in saved_state and saved_state["just_updated"]: 973 | row.alert = True 974 | row.operator("wm.quit_blender", 975 | text="Restart blender to complete update", 976 | icon="ERROR") 977 | return 978 | 979 | split = layout_split(row, factor=0.4) 980 | sub_col = split.column() 981 | sub_col.prop(settings, "auto_check_update") 982 | sub_col = split.column() 983 | 984 | if not settings.auto_check_update: 985 | sub_col.enabled = False 986 | sub_row = sub_col.row() 987 | sub_row.label(text="Interval between checks") 988 | sub_row = sub_col.row(align=True) 989 | check_col = sub_row.column(align=True) 990 | check_col.prop(settings, "updater_interval_months") 991 | check_col = sub_row.column(align=True) 992 | check_col.prop(settings, "updater_interval_days") 993 | check_col = sub_row.column(align=True) 994 | 995 | # Consider un-commenting for local dev (e.g. to set shorter intervals) 996 | # check_col.prop(settings,"updater_interval_hours") 997 | # check_col = sub_row.column(align=True) 998 | # check_col.prop(settings,"updater_interval_minutes") 999 | 1000 | # Checking / managing updates. 1001 | row = box.row() 1002 | col = row.column() 1003 | if updater.error is not None: 1004 | sub_col = col.row(align=True) 1005 | sub_col.scale_y = 1 1006 | split = sub_col.split(align=True) 1007 | split.scale_y = 2 1008 | if "ssl" in updater.error_msg.lower(): 1009 | split.enabled = True 1010 | split.operator(AddonUpdaterInstallManually.bl_idname, 1011 | text=updater.error) 1012 | else: 1013 | split.enabled = False 1014 | split.operator(AddonUpdaterCheckNow.bl_idname, 1015 | text=updater.error) 1016 | split = sub_col.split(align=True) 1017 | split.scale_y = 2 1018 | split.operator(AddonUpdaterCheckNow.bl_idname, 1019 | text="", icon="FILE_REFRESH") 1020 | 1021 | elif updater.update_ready is None and not updater.async_checking: 1022 | col.scale_y = 2 1023 | col.operator(AddonUpdaterCheckNow.bl_idname) 1024 | elif updater.update_ready is None: # async is running 1025 | sub_col = col.row(align=True) 1026 | sub_col.scale_y = 1 1027 | split = sub_col.split(align=True) 1028 | split.enabled = False 1029 | split.scale_y = 2 1030 | split.operator(AddonUpdaterCheckNow.bl_idname, text="Checking...") 1031 | split = sub_col.split(align=True) 1032 | split.scale_y = 2 1033 | split.operator(AddonUpdaterEndBackground.bl_idname, text="", icon="X") 1034 | 1035 | elif updater.include_branches and \ 1036 | len(updater.tags) == len(updater.include_branch_list) and not \ 1037 | updater.manual_only: 1038 | # No releases found, but still show the appropriate branch. 1039 | sub_col = col.row(align=True) 1040 | sub_col.scale_y = 1 1041 | split = sub_col.split(align=True) 1042 | split.scale_y = 2 1043 | update_now_txt = "Update directly to {}".format( 1044 | updater.include_branch_list[0]) 1045 | split.operator(AddonUpdaterUpdateNow.bl_idname, text=update_now_txt) 1046 | split = sub_col.split(align=True) 1047 | split.scale_y = 2 1048 | split.operator(AddonUpdaterCheckNow.bl_idname, 1049 | text="", icon="FILE_REFRESH") 1050 | 1051 | elif updater.update_ready and not updater.manual_only: 1052 | sub_col = col.row(align=True) 1053 | sub_col.scale_y = 1 1054 | split = sub_col.split(align=True) 1055 | split.scale_y = 2 1056 | split.operator(AddonUpdaterUpdateNow.bl_idname, 1057 | text="Update now to " + str(updater.update_version)) 1058 | split = sub_col.split(align=True) 1059 | split.scale_y = 2 1060 | split.operator(AddonUpdaterCheckNow.bl_idname, 1061 | text="", icon="FILE_REFRESH") 1062 | 1063 | elif updater.update_ready and updater.manual_only: 1064 | col.scale_y = 2 1065 | dl_now_txt = "Download " + str(updater.update_version) 1066 | col.operator("wm.url_open", 1067 | text=dl_now_txt).url = updater.website 1068 | else: # i.e. that updater.update_ready == False. 1069 | sub_col = col.row(align=True) 1070 | sub_col.scale_y = 1 1071 | split = sub_col.split(align=True) 1072 | split.enabled = False 1073 | split.scale_y = 2 1074 | split.operator(AddonUpdaterCheckNow.bl_idname, 1075 | text="Addon is up to date") 1076 | split = sub_col.split(align=True) 1077 | split.scale_y = 2 1078 | split.operator(AddonUpdaterCheckNow.bl_idname, 1079 | text="", icon="FILE_REFRESH") 1080 | 1081 | if not updater.manual_only: 1082 | col = row.column(align=True) 1083 | if updater.include_branches and len(updater.include_branch_list) > 0: 1084 | branch = updater.include_branch_list[0] 1085 | col.operator(AddonUpdaterUpdateTarget.bl_idname, 1086 | text="Install {} / old version".format(branch)) 1087 | else: 1088 | col.operator(AddonUpdaterUpdateTarget.bl_idname, 1089 | text="(Re)install addon version") 1090 | last_date = "none found" 1091 | backup_path = os.path.join(updater.stage_path, "backup") 1092 | if "backup_date" in updater.json and os.path.isdir(backup_path): 1093 | if updater.json["backup_date"] == "": 1094 | last_date = "Date not found" 1095 | else: 1096 | last_date = updater.json["backup_date"] 1097 | backup_text = "Restore addon backup ({})".format(last_date) 1098 | col.operator(AddonUpdaterRestoreBackup.bl_idname, text=backup_text) 1099 | 1100 | row = box.row() 1101 | row.scale_y = 0.7 1102 | last_check = updater.json["last_check"] 1103 | if updater.error is not None and updater.error_msg is not None: 1104 | row.label(text=updater.error_msg) 1105 | elif last_check: 1106 | last_check = last_check[0: last_check.index(".")] 1107 | row.label(text="Last update check: " + last_check) 1108 | else: 1109 | row.label(text="Last update check: Never") 1110 | 1111 | 1112 | def update_settings_ui_condensed(self, context, element=None): 1113 | """Preferences - Condensed drawing within preferences. 1114 | 1115 | Alternate draw for user preferences or other places, does not draw a box. 1116 | """ 1117 | 1118 | # Element is a UI element, such as layout, a row, column, or box. 1119 | if element is None: 1120 | element = self.layout 1121 | row = element.row() 1122 | 1123 | # In case of error importing updater. 1124 | if updater.invalid_updater: 1125 | row.label(text="Error initializing updater code:") 1126 | row.label(text=updater.error_msg) 1127 | return 1128 | settings = get_user_preferences(context) 1129 | if not settings: 1130 | row.label(text="Error getting updater preferences", icon='ERROR') 1131 | return 1132 | 1133 | # Special case to tell user to restart blender, if set that way. 1134 | if not updater.auto_reload_post_update: 1135 | saved_state = updater.json 1136 | if "just_updated" in saved_state and saved_state["just_updated"]: 1137 | row.alert = True # mark red 1138 | row.operator( 1139 | "wm.quit_blender", 1140 | text="Restart blender to complete update", 1141 | icon="ERROR") 1142 | return 1143 | 1144 | col = row.column() 1145 | if updater.error is not None: 1146 | sub_col = col.row(align=True) 1147 | sub_col.scale_y = 1 1148 | split = sub_col.split(align=True) 1149 | split.scale_y = 2 1150 | if "ssl" in updater.error_msg.lower(): 1151 | split.enabled = True 1152 | split.operator(AddonUpdaterInstallManually.bl_idname, 1153 | text=updater.error) 1154 | else: 1155 | split.enabled = False 1156 | split.operator(AddonUpdaterCheckNow.bl_idname, 1157 | text=updater.error) 1158 | split = sub_col.split(align=True) 1159 | split.scale_y = 2 1160 | split.operator(AddonUpdaterCheckNow.bl_idname, 1161 | text="", icon="FILE_REFRESH") 1162 | 1163 | elif updater.update_ready is None and not updater.async_checking: 1164 | col.scale_y = 2 1165 | col.operator(AddonUpdaterCheckNow.bl_idname) 1166 | elif updater.update_ready is None: # Async is running. 1167 | sub_col = col.row(align=True) 1168 | sub_col.scale_y = 1 1169 | split = sub_col.split(align=True) 1170 | split.enabled = False 1171 | split.scale_y = 2 1172 | split.operator(AddonUpdaterCheckNow.bl_idname, text="Checking...") 1173 | split = sub_col.split(align=True) 1174 | split.scale_y = 2 1175 | split.operator(AddonUpdaterEndBackground.bl_idname, text="", icon="X") 1176 | 1177 | elif updater.include_branches and \ 1178 | len(updater.tags) == len(updater.include_branch_list) and not \ 1179 | updater.manual_only: 1180 | # No releases found, but still show the appropriate branch. 1181 | sub_col = col.row(align=True) 1182 | sub_col.scale_y = 1 1183 | split = sub_col.split(align=True) 1184 | split.scale_y = 2 1185 | now_txt = "Update directly to " + str(updater.include_branch_list[0]) 1186 | split.operator(AddonUpdaterUpdateNow.bl_idname, text=now_txt) 1187 | split = sub_col.split(align=True) 1188 | split.scale_y = 2 1189 | split.operator(AddonUpdaterCheckNow.bl_idname, 1190 | text="", icon="FILE_REFRESH") 1191 | 1192 | elif updater.update_ready and not updater.manual_only: 1193 | sub_col = col.row(align=True) 1194 | sub_col.scale_y = 1 1195 | split = sub_col.split(align=True) 1196 | split.scale_y = 2 1197 | split.operator(AddonUpdaterUpdateNow.bl_idname, 1198 | text="Update now to " + str(updater.update_version)) 1199 | split = sub_col.split(align=True) 1200 | split.scale_y = 2 1201 | split.operator(AddonUpdaterCheckNow.bl_idname, 1202 | text="", icon="FILE_REFRESH") 1203 | 1204 | elif updater.update_ready and updater.manual_only: 1205 | col.scale_y = 2 1206 | dl_txt = "Download " + str(updater.update_version) 1207 | col.operator("wm.url_open", text=dl_txt).url = updater.website 1208 | else: # i.e. that updater.update_ready == False. 1209 | sub_col = col.row(align=True) 1210 | sub_col.scale_y = 1 1211 | split = sub_col.split(align=True) 1212 | split.enabled = False 1213 | split.scale_y = 2 1214 | split.operator(AddonUpdaterCheckNow.bl_idname, 1215 | text="Addon is up to date") 1216 | split = sub_col.split(align=True) 1217 | split.scale_y = 2 1218 | split.operator(AddonUpdaterCheckNow.bl_idname, 1219 | text="", icon="FILE_REFRESH") 1220 | 1221 | row = element.row() 1222 | row.prop(settings, "auto_check_update") 1223 | 1224 | row = element.row() 1225 | row.scale_y = 0.7 1226 | last_check = updater.json["last_check"] 1227 | if updater.error is not None and updater.error_msg is not None: 1228 | row.label(text=updater.error_msg) 1229 | elif last_check != "" and last_check is not None: 1230 | last_check = last_check[0: last_check.index(".")] 1231 | row.label(text="Last check: " + last_check) 1232 | else: 1233 | row.label(text="Last check: Never") 1234 | 1235 | 1236 | def skip_tag_function(self, tag): 1237 | """A global function for tag skipping. 1238 | 1239 | A way to filter which tags are displayed, e.g. to limit downgrading too 1240 | long ago. 1241 | 1242 | Args: 1243 | self: The instance of the singleton addon update. 1244 | tag: the text content of a tag from the repo, e.g. "v1.2.3". 1245 | 1246 | Returns: 1247 | bool: True to skip this tag name (ie don't allow for downloading this 1248 | version), or False if the tag is allowed. 1249 | """ 1250 | 1251 | # In case of error importing updater. 1252 | if self.invalid_updater: 1253 | return False 1254 | 1255 | # ---- write any custom code here, return true to disallow version ---- # 1256 | # 1257 | # # Filter out e.g. if 'beta' is in name of release 1258 | # if 'beta' in tag.lower(): 1259 | # return True 1260 | # ---- write any custom code above, return true to disallow version --- # 1261 | 1262 | if self.include_branches: 1263 | for branch in self.include_branch_list: 1264 | if tag["name"].lower() == branch: 1265 | return False 1266 | 1267 | # Function converting string to tuple, ignoring e.g. leading 'v'. 1268 | # Be aware that this strips out other text that you might otherwise 1269 | # want to be kept and accounted for when checking tags (e.g. v1.1a vs 1.1b) 1270 | tupled = self.version_tuple_from_text(tag["name"]) 1271 | if not isinstance(tupled, tuple): 1272 | return True 1273 | 1274 | # Select the min tag version - change tuple accordingly. 1275 | if self.version_min_update is not None: 1276 | if tupled < self.version_min_update: 1277 | return True # Skip if current version below this. 1278 | 1279 | # Select the max tag version. 1280 | if self.version_max_update is not None: 1281 | if tupled >= self.version_max_update: 1282 | return True # Skip if current version at or above this. 1283 | 1284 | # In all other cases, allow showing the tag for updating/reverting. 1285 | # To simply and always show all tags, this return False could be moved 1286 | # to the start of the function definition so all tags are allowed. 1287 | return False 1288 | 1289 | 1290 | def select_link_function(self, tag): 1291 | """Only customize if trying to leverage "attachments" in *GitHub* releases. 1292 | 1293 | A way to select from one or multiple attached downloadable files from the 1294 | server, instead of downloading the default release/tag source code. 1295 | """ 1296 | 1297 | # -- Default, universal case (and is the only option for GitLab/Bitbucket) 1298 | link = tag["zipball_url"] 1299 | 1300 | # -- Example: select the first (or only) asset instead source code -- 1301 | # if "assets" in tag and "browser_download_url" in tag["assets"][0]: 1302 | # link = tag["assets"][0]["browser_download_url"] 1303 | 1304 | # -- Example: select asset based on OS, where multiple builds exist -- 1305 | # # not tested/no error checking, modify to fit your own needs! 1306 | # # assume each release has three attached builds: 1307 | # # release_windows.zip, release_OSX.zip, release_linux.zip 1308 | # # This also would logically not be used with "branches" enabled 1309 | # if platform.system() == "Darwin": # ie OSX 1310 | # link = [asset for asset in tag["assets"] if 'OSX' in asset][0] 1311 | # elif platform.system() == "Windows": 1312 | # link = [asset for asset in tag["assets"] if 'windows' in asset][0] 1313 | # elif platform.system() == "Linux": 1314 | # link = [asset for asset in tag["assets"] if 'linux' in asset][0] 1315 | 1316 | return link 1317 | 1318 | 1319 | # ----------------------------------------------------------------------------- 1320 | # Register, should be run in the register module itself 1321 | # ----------------------------------------------------------------------------- 1322 | classes = ( 1323 | AddonUpdaterInstallPopup, 1324 | AddonUpdaterCheckNow, 1325 | AddonUpdaterUpdateNow, 1326 | AddonUpdaterUpdateTarget, 1327 | AddonUpdaterInstallManually, 1328 | AddonUpdaterUpdatedSuccessful, 1329 | AddonUpdaterRestoreBackup, 1330 | AddonUpdaterIgnore, 1331 | AddonUpdaterEndBackground 1332 | ) 1333 | 1334 | 1335 | def register(bl_info): 1336 | """Registering the operators in this module""" 1337 | # Safer failure in case of issue loading module. 1338 | if updater.error: 1339 | print("Exiting updater registration, " + updater.error) 1340 | return 1341 | updater.clear_state() # Clear internal vars, avoids reloading oddities. 1342 | 1343 | # Confirm your updater "engine" (Github is default if not specified). 1344 | updater.engine = "Github" 1345 | # updater.engine = "GitLab" 1346 | # updater.engine = "Bitbucket" 1347 | 1348 | # If using private repository, indicate the token here. 1349 | # Must be set after assigning the engine. 1350 | # **WARNING** Depending on the engine, this token can act like a password!! 1351 | # Only provide a token if the project is *non-public*, see readme for 1352 | # other considerations and suggestions from a security standpoint. 1353 | updater.private_token = None # "tokenstring" 1354 | 1355 | # Choose your own username, must match website (not needed for GitLab). 1356 | updater.user = "cgcookie" 1357 | 1358 | # Choose your own repository, must match git name for GitHUb and Bitbucket, 1359 | # for GitLab use project ID (numbers only). 1360 | updater.repo = "blender-addon-updater" 1361 | 1362 | # updater.addon = # define at top of module, MUST be done first 1363 | 1364 | # Website for manual addon download, optional but recommended to set. 1365 | updater.website = "https://github.com/CGCookie/blender-addon-updater/" 1366 | 1367 | # Addon subfolder path. 1368 | # "sample/path/to/addon" 1369 | # default is "" or None, meaning root 1370 | updater.subfolder_path = "" 1371 | 1372 | # Used to check/compare versions. 1373 | updater.current_version = bl_info["version"] 1374 | 1375 | # Optional, to hard-set update frequency, use this here - however, this 1376 | # demo has this set via UI properties. 1377 | # updater.set_check_interval(enabled=False, months=0, days=0, hours=0, minutes=2) 1378 | 1379 | # Optional, consider turning off for production or allow as an option 1380 | # This will print out additional debugging info to the console 1381 | updater.verbose = True # make False for production default 1382 | 1383 | # Optional, customize where the addon updater processing subfolder is, 1384 | # essentially a staging folder used by the updater on its own 1385 | # Needs to be within the same folder as the addon itself 1386 | # Need to supply a full, absolute path to folder 1387 | # updater.updater_path = # set path of updater folder, by default: 1388 | # /addons/{__package__}/{__package__}_updater 1389 | 1390 | # Auto create a backup of the addon when installing other versions. 1391 | updater.backup_current = True # True by default 1392 | 1393 | # Sample ignore patterns for when creating backup of current during update. 1394 | updater.backup_ignore_patterns = ["__pycache__"] 1395 | # Alternate example patterns: 1396 | # updater.backup_ignore_patterns = [".git", "__pycache__", "*.bat", ".gitignore", "*.exe"] 1397 | 1398 | # Patterns for files to actively overwrite if found in new update file and 1399 | # are also found in the currently installed addon. Note that by default 1400 | # (ie if set to []), updates are installed in the same way as blender: 1401 | # .py files are replaced, but other file types (e.g. json, txt, blend) 1402 | # will NOT be overwritten if already present in current install. Thus 1403 | # if you want to automatically update resources/non py files, add them as a 1404 | # part of the pattern list below so they will always be overwritten by an 1405 | # update. If a pattern file is not found in new update, no action is taken 1406 | # NOTE: This does NOT delete anything proactively, rather only defines what 1407 | # is allowed to be overwritten during an update execution. 1408 | updater.overwrite_patterns = ["*.png", "*.jpg", "README.md", "LICENSE.txt"] 1409 | # updater.overwrite_patterns = [] 1410 | # other examples: 1411 | # ["*"] means ALL files/folders will be overwritten by update, was the 1412 | # behavior pre updater v1.0.4. 1413 | # [] or ["*.py","*.pyc"] matches default blender behavior, ie same effect 1414 | # if user installs update manually without deleting the existing addon 1415 | # first e.g. if existing install and update both have a resource.blend 1416 | # file, the existing installed one will remain. 1417 | # ["some.py"] means if some.py is found in addon update, it will overwrite 1418 | # any existing some.py in current addon install, if any. 1419 | # ["*.json"] means all json files found in addon update will overwrite 1420 | # those of same name in current install. 1421 | # ["*.png","README.md","LICENSE.txt"] means the readme, license, and all 1422 | # pngs will be overwritten by update. 1423 | 1424 | # Patterns for files to actively remove prior to running update. 1425 | # Useful if wanting to remove old code due to changes in filenames 1426 | # that otherwise would accumulate. Note: this runs after taking 1427 | # a backup (if enabled) but before placing in new update. If the same 1428 | # file name removed exists in the update, then it acts as if pattern 1429 | # is placed in the overwrite_patterns property. Note this is effectively 1430 | # ignored if clean=True in the run_update method. 1431 | updater.remove_pre_update_patterns = ["*.py", "*.pyc"] 1432 | # Note setting ["*"] here is equivalent to always running updates with 1433 | # clean = True in the run_update method, ie the equivalent of a fresh, 1434 | # new install. This would also delete any resources or user-made/modified 1435 | # files setting ["__pycache__"] ensures the pycache folder always removed. 1436 | # The configuration of ["*.py", "*.pyc"] is a safe option as this 1437 | # will ensure no old python files/caches remain in event different addon 1438 | # versions have different filenames or structures. 1439 | 1440 | # Allow branches like 'master' as an option to update to, regardless 1441 | # of release or version. 1442 | # Default behavior: releases will still be used for auto check (popup), 1443 | # but the user has the option from user preferences to directly 1444 | # update to the master branch or any other branches specified using 1445 | # the "install {branch}/older version" operator. 1446 | updater.include_branches = True 1447 | 1448 | # (GitHub only) This options allows using "releases" instead of "tags", 1449 | # which enables pulling down release logs/notes, as well as installs update 1450 | # from release-attached zips (instead of the auto-packaged code generated 1451 | # with a release/tag). Setting has no impact on BitBucket or GitLab repos. 1452 | updater.use_releases = False 1453 | # Note: Releases always have a tag, but a tag may not always be a release. 1454 | # Therefore, setting True above will filter out any non-annotated tags. 1455 | # Note 2: Using this option will also display (and filter by) the release 1456 | # name instead of the tag name, bear this in mind given the 1457 | # skip_tag_function filtering above. 1458 | 1459 | # Populate if using "include_branches" option above. 1460 | # Note: updater.include_branch_list defaults to ['master'] branch if set to 1461 | # none. Example targeting another multiple branches allowed to pull from: 1462 | # updater.include_branch_list = ['master', 'dev'] 1463 | updater.include_branch_list = None # None is the equivalent = ['master'] 1464 | 1465 | # Only allow manual install, thus prompting the user to open 1466 | # the addon's web page to download, specifically: updater.website 1467 | # Useful if only wanting to get notification of updates but not 1468 | # directly install. 1469 | updater.manual_only = False 1470 | 1471 | # Used for development only, "pretend" to install an update to test 1472 | # reloading conditions. 1473 | updater.fake_install = False # Set to true to test callback/reloading. 1474 | 1475 | # Show popups, ie if auto-check for update is enabled or a previous 1476 | # check for update in user preferences found a new version, show a popup 1477 | # (at most once per blender session, and it provides an option to ignore 1478 | # for future sessions); default behavior is set to True. 1479 | updater.show_popups = True 1480 | # note: if set to false, there will still be an "update ready" box drawn 1481 | # using the `update_notice_box_ui` panel function. 1482 | 1483 | # Override with a custom function on what tags 1484 | # to skip showing for updater; see code for function above. 1485 | # Set the min and max versions allowed to install. 1486 | # Optional, default None 1487 | # min install (>=) will install this and higher 1488 | updater.version_min_update = (0, 0, 0) 1489 | # updater.version_min_update = None # None or default for no minimum. 1490 | 1491 | # Max install (<) will install strictly anything lower than this version 1492 | # number, useful to limit the max version a given user can install (e.g. 1493 | # if support for a future version of blender is going away, and you don't 1494 | # want users to be prompted to install a non-functioning addon) 1495 | # updater.version_max_update = (9,9,9) 1496 | updater.version_max_update = None # None or default for no max. 1497 | 1498 | # Function defined above, customize as appropriate per repository 1499 | updater.skip_tag = skip_tag_function # min and max used in this function 1500 | 1501 | # Function defined above, optionally customize as needed per repository. 1502 | updater.select_link = select_link_function 1503 | 1504 | # Recommended false to encourage blender restarts on update completion 1505 | # Setting this option to True is NOT as stable as false (could cause 1506 | # blender crashes). 1507 | updater.auto_reload_post_update = False 1508 | 1509 | # The register line items for all operators/panels. 1510 | # If using bpy.utils.register_module(__name__) to register elsewhere 1511 | # in the addon, delete these lines (also from unregister). 1512 | for cls in classes: 1513 | # Apply annotations to remove Blender 2.8+ warnings, no effect on 2.7 1514 | make_annotations(cls) 1515 | # Comment out this line if using bpy.utils.register_module(__name__) 1516 | bpy.utils.register_class(cls) 1517 | 1518 | # Special situation: we just updated the addon, show a popup to tell the 1519 | # user it worked. Could enclosed in try/catch in case other issues arise. 1520 | show_reload_popup() 1521 | 1522 | 1523 | def unregister(): 1524 | for cls in reversed(classes): 1525 | # Comment out this line if using bpy.utils.unregister_module(__name__). 1526 | bpy.utils.unregister_class(cls) 1527 | 1528 | # Clear global vars since they may persist if not restarting blender. 1529 | updater.clear_state() # Clear internal vars, avoids reloading oddities. 1530 | 1531 | global ran_auto_check_install_popup 1532 | ran_auto_check_install_popup = False 1533 | 1534 | global ran_update_success_popup 1535 | ran_update_success_popup = False 1536 | 1537 | global ran_background_check 1538 | ran_background_check = False 1539 | --------------------------------------------------------------------------------