Add decorator for handing child-process side of pipe
This commit is contained in:
@@ -5,7 +5,7 @@ import logging
|
||||
import bpy
|
||||
from bpy.props import CollectionProperty
|
||||
from bpy.types import PropertyGroup, Panel, UIList, AddonPreferences, Operator
|
||||
from .subprocess_adapter import subprocess_operator
|
||||
from .subprocess_adapter import subprocess_operator, subprocess_function
|
||||
from . import bpackage as bpkg
|
||||
|
||||
class RepositoryProperty(PropertyGroup):
|
||||
@@ -42,27 +42,30 @@ class PackagePreferences(AddonPreferences):
|
||||
|
||||
@subprocess_operator
|
||||
class PACKAGE_OT_refresh(Operator):
|
||||
"""
|
||||
Operator which checks for updates to known package lists
|
||||
"""
|
||||
bl_idname = "package.refresh"
|
||||
bl_label = "Update package list(s)"
|
||||
bl_label = "Refresh package list(s)"
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
def invoke(self, context, event):
|
||||
prefs = context.user_preferences.addons[__package__].preferences
|
||||
|
||||
if 'repositories' not in prefs:
|
||||
return {'FINISHED'}
|
||||
|
||||
# HACK: just do the active repo for now
|
||||
repo = bpkg.Repository(prefs['repositories'][prefs.active_repository].to_dict())
|
||||
self.proc_args = []
|
||||
self.proc_kwargs = {'target': repo.refresh}
|
||||
|
||||
def execute(self, context, event):
|
||||
pass
|
||||
|
||||
self.proc_kwargs = {'target': subprocess_function(repo.refresh, pipe=self.pipe)}
|
||||
|
||||
def modal(self, context, event):
|
||||
# try:
|
||||
self.poll_subprocess()
|
||||
# except:
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def handle_response(self, resp):
|
||||
self.report({'INFO'}, "Request returned %s" % resp)
|
||||
|
Reference in New Issue
Block a user