Example #1
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()

        try:
            branch_name = dload_archive_name or 'master'
            branch_origin = dload_archive_path or 'https://github.com/nortikin/sverchok/archive/'
            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
            bpy.context.scene.sv_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
        write_latest_sha_to_local(sha_value=latest_local_sha(),
                                  filename='sv_sha_downloaded.sv')
        write_latest_sha_to_local(sha_value=latest_local_sha())
        return {'FINISHED'}
Example #2
0
    def execute(self, context):
        global ADDON_LIST
        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 = self.master_branch_name
            branch_origin = 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
            wm.progress_update(100)
            wm.progress_end()
            bpy.ops.preferences.addon_refresh()
            ADDON_LIST = get_addons_folder()
            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'}

        return {'FINISHED'}