Send repolist to blender and list contents
This commit is contained in:
@@ -258,6 +258,7 @@ class BPKG_OT_refresh(SubprocMixin, bpy.types.Operator):
|
|||||||
subproc.SubprocError: self._subproc_error,
|
subproc.SubprocError: self._subproc_error,
|
||||||
subproc.DownloadError: self._subproc_download_error,
|
subproc.DownloadError: self._subproc_download_error,
|
||||||
subproc.Success: self._subproc_success,
|
subproc.Success: self._subproc_success,
|
||||||
|
subproc.Result: self._subproc_result,
|
||||||
subproc.Aborted: self._subproc_aborted,
|
subproc.Aborted: self._subproc_aborted,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,6 +286,12 @@ class BPKG_OT_refresh(SubprocMixin, bpy.types.Operator):
|
|||||||
self.report({'INFO'}, 'Package list retrieved successfully')
|
self.report({'INFO'}, 'Package list retrieved successfully')
|
||||||
self.quit()
|
self.quit()
|
||||||
|
|
||||||
|
def _subproc_result(self, result: subproc.Result):
|
||||||
|
prefs = bpy.context.user_preferences.addons[__package__].preferences
|
||||||
|
prefs['repo'] = result.data
|
||||||
|
self.report({'INFO'}, 'Package list retrieved successfully')
|
||||||
|
self.quit()
|
||||||
|
|
||||||
def _subproc_aborted(self, aborted: subproc.Aborted):
|
def _subproc_aborted(self, aborted: subproc.Aborted):
|
||||||
self.report({'ERROR'}, 'Package list retrieval aborted per your request')
|
self.report({'ERROR'}, 'Package list retrieval aborted per your request')
|
||||||
self.quit()
|
self.quit()
|
||||||
@@ -322,6 +329,40 @@ class BPKG_OT_hang(SubprocMixin, bpy.types.Operator):
|
|||||||
def report_process_died(self):
|
def report_process_died(self):
|
||||||
self.report({'ERROR'}, 'Process died, exit code %s' % self.process.exitcode)
|
self.report({'ERROR'}, 'Process died, exit code %s' % self.process.exitcode)
|
||||||
|
|
||||||
|
class USERPREF_PT_packages(bpy.types.Panel):
|
||||||
|
bl_label = "Package Management"
|
||||||
|
bl_space_type = 'USER_PREFERENCES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_options = {'HIDE_HEADER'}
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + '.USERPREF_PT_packages')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
userpref = context.user_preferences
|
||||||
|
return (userpref.active_section == 'PACKAGES')
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
repo = context.user_preferences.addons[__package__].preferences['repo']
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
# top = layout.row()
|
||||||
|
# top.prop(context.window_manager, "addon_search", text="", icon='VIEWZOOM')
|
||||||
|
# top.prop(
|
||||||
|
|
||||||
|
def draw_package(layout):
|
||||||
|
pass
|
||||||
|
|
||||||
|
for pkg in repo['packages']:
|
||||||
|
row = layout.row()
|
||||||
|
|
||||||
|
pkgbox = row.box()
|
||||||
|
left = pkgbox.split(.7)
|
||||||
|
row1 = left.row()
|
||||||
|
row2 = left.row()
|
||||||
|
row1.label(text=pkg['bl_info'].get('name', "MISSING NAME"))
|
||||||
|
row2.label(text=pkg['bl_info'].get('description', "MISSING DESCRIPTION"))
|
||||||
|
|
||||||
|
|
||||||
class PackageManagerPreferences(bpy.types.AddonPreferences):
|
class PackageManagerPreferences(bpy.types.AddonPreferences):
|
||||||
bl_idname = __package__
|
bl_idname = __package__
|
||||||
@@ -348,6 +389,7 @@ def register():
|
|||||||
bpy.utils.register_class(BPKG_OT_install)
|
bpy.utils.register_class(BPKG_OT_install)
|
||||||
bpy.utils.register_class(BPKG_OT_refresh)
|
bpy.utils.register_class(BPKG_OT_refresh)
|
||||||
bpy.utils.register_class(BPKG_OT_hang)
|
bpy.utils.register_class(BPKG_OT_hang)
|
||||||
|
bpy.utils.register_class(USERPREF_PT_packages)
|
||||||
bpy.utils.register_class(PackageManagerPreferences)
|
bpy.utils.register_class(PackageManagerPreferences)
|
||||||
|
|
||||||
|
|
||||||
@@ -355,4 +397,5 @@ def unregister():
|
|||||||
bpy.utils.unregister_class(BPKG_OT_install)
|
bpy.utils.unregister_class(BPKG_OT_install)
|
||||||
bpy.utils.unregister_class(BPKG_OT_refresh)
|
bpy.utils.unregister_class(BPKG_OT_refresh)
|
||||||
bpy.utils.unregister_class(BPKG_OT_hang)
|
bpy.utils.unregister_class(BPKG_OT_hang)
|
||||||
|
bpy.utils.unregister_class(USERPREF_PT_packages)
|
||||||
bpy.utils.unregister_class(PackageManagerPreferences)
|
bpy.utils.unregister_class(PackageManagerPreferences)
|
||||||
|
@@ -66,6 +66,11 @@ class DownloadError(SubprocMessage):
|
|||||||
class Success(SubprocMessage):
|
class Success(SubprocMessage):
|
||||||
"""Sent when an operation finished sucessfully."""
|
"""Sent when an operation finished sucessfully."""
|
||||||
|
|
||||||
|
class Result(SubprocMessage):
|
||||||
|
"""Sent when an operation returns data to be used on the parent process."""
|
||||||
|
|
||||||
|
def __init__(self, data):
|
||||||
|
self.data = data
|
||||||
|
|
||||||
class Aborted(SubprocMessage):
|
class Aborted(SubprocMessage):
|
||||||
"""Sent as response to Abort message."""
|
"""Sent as response to Abort message."""
|
||||||
@@ -492,7 +497,7 @@ def refresh(pipe_to_blender, storage_path: pathlib.Path, repository_url: str):
|
|||||||
pipe_to_blender.send(DownloadError(err.status_code, err.message))
|
pipe_to_blender.send(DownloadError(err.status_code, err.message))
|
||||||
|
|
||||||
repo.to_file(repo_path) # TODO: this always writes even if repo wasn't changed
|
repo.to_file(repo_path) # TODO: this always writes even if repo wasn't changed
|
||||||
pipe_to_blender.send(Success())
|
pipe_to_blender.send(Result(repo.to_dict()))
|
||||||
|
|
||||||
def debug_hang():
|
def debug_hang():
|
||||||
"""Hangs for an hour. For testing purposes only."""
|
"""Hangs for an hour. For testing purposes only."""
|
||||||
|
Reference in New Issue
Block a user