Add decorator for handing child-process side of pipe

This commit is contained in:
gandalf3
2017-07-09 14:40:56 -07:00
parent 1188f91b7b
commit 8cc606b263
3 changed files with 49 additions and 12 deletions

View File

@@ -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)