Exemplo n.º 1
0
    def execute(self, context):
        report = self.report

        local_sha = latest_local_sha(addon_name=self.addon_name)
        latest_sha = latest_github_sha(self.commits_link)

        with addon_preferences(self.addon_name) as prefs:
            prefs.available_new_version = False
            if not local_sha:
                prefs.available_new_version = True
            else:
                if not local_sha == latest_sha:
                    prefs.available_new_version = True

            write_latest_sha_to_local(sha_value=latest_sha, addon_name=self.addon_name)
            downloaded_sha = latest_local_sha(filename=SHA_DOWNLOADED, addon_name=self.addon_name)
            if not downloaded_sha == latest_sha:
                prefs.available_new_version = True

            if prefs.available_new_version:
                report({'INFO'}, "New commits available, update at own risk ({0})".format(latest_sha[:7]))
            else:
                report({'INFO'}, "No new commits to download")

        return {'FINISHED'}
Exemplo n.º 2
0
    def execute(self, context):

        os.curdir = bl_addons_path
        os.chdir(os.curdir)

        # wm = bpy.context.window_manager  should be this i think....
        wm = bpy.data.window_managers[0]
        wm.progress_begin(0, 100)
        wm.progress_update(20)

        dload_archive_path, dload_archive_name = get_archive_path(self.addon_name)

        try:
            branch_name = dload_archive_name or self.master_branch_name
            branch_origin = dload_archive_path or self.archive_link
            zipname = '{0}.zip'.format(branch_name)
            url = branch_origin + zipname

            to_path = os.path.normpath(os.path.join(os.curdir, zipname))

            print('> obtaining: [{0}]\n> sending to path: [{1}]'.format(url, to_path))
            # return {'CANCELLED'}

            file = requests.urlretrieve(url, to_path)
            wm.progress_update(50)
        except Exception as err:
            self.report({'ERROR'}, "Cannot get archive from Internet")
            print(err)
            wm.progress_end()
            return {'CANCELLED'}

        try:
            err = 0
            ZipFile(file[0]).extractall(path=os.curdir, members=None, pwd=None)
            wm.progress_update(90)
            err = 1
            os.remove(file[0])
            err = 2
            with addon_preferences(self.addon_name) as prefs:
                prefs.available_new_version = False
            wm.progress_update(100)
            wm.progress_end()
            self.report({'INFO'}, "Unzipped, reload addons with F8 button, maybe restart Blender")
        except:
            self.report({'ERROR'}, "Cannot extract files errno {0}".format(str(err)))
            wm.progress_end()
            os.remove(file[0])
            return {'CANCELLED'}

        # write to both sv_sha_download and sv_shafile.sv
        lastest_local_sha = latest_local_sha(addon_name=self.addon_name)
        write_latest_sha_to_local(sha_value=lastest_local_sha, filename=SHA_DOWNLOADED, addon_name=self.addon_name)
        write_latest_sha_to_local(sha_value=lastest_local_sha, addon_name=self.addon_name)
        return {'FINISHED'}
Exemplo n.º 3
0
def update_addon_ui(layout):
    layout.operator('node.sv_show_latest_commits', text='Show Last Commits').commits_link = COMMITS_LINK
    with addon_preferences(ADDON_NAME) as prefs:

        if not prefs.available_new_version:
            check = layout.operator('node.sverchok_check_for_upgrades_wsha', text='Check for Upgrades')
            check.commits_link = COMMITS_LINK
            check.addon_name = ADDON_NAME
        else:
            update_op = layout.operator('node.sverchok_update_addon', text=f'Upgrade {ADDON_PRETTY_NAME}')
            update_op.addon_name = ADDON_NAME
            update_op.master_branch_name = MASTER_BRANCH_NAME
            update_op.archive_link = ARCHIVE_LINK
Exemplo n.º 4
0
def get_archive_path(addon_name):
    with addon_preferences(addon_name) as prefs:
        return prefs.dload_archive_path, prefs.dload_archive_name