[Bf-extensions-cvs] [05fe57e] temp-blend-utils: Add command_complete callback to subprocess helper
Campbell Barton
noreply at git.blender.org
Fri Jan 29 06:33:58 CET 2016
Commit: 05fe57e7ae47470d96f82361a7193d9a4f277cb2
Author: Campbell Barton
Date: Fri Jan 29 16:25:08 2016 +1100
Branches: temp-blend-utils
https://developer.blender.org/rBA05fe57e7ae47470d96f82361a7193d9a4f277cb2
Add command_complete callback to subprocess helper
Useful for running cleanup operations when the subprocess is terminated.
===================================================================
M io_blend_utils/bl_utils/subprocess_helper.py
===================================================================
diff --git a/io_blend_utils/bl_utils/subprocess_helper.py b/io_blend_utils/bl_utils/subprocess_helper.py
index 8133f6a..a19031b 100644
--- a/io_blend_utils/bl_utils/subprocess_helper.py
+++ b/io_blend_utils/bl_utils/subprocess_helper.py
@@ -36,6 +36,10 @@ class SubprocessHelper:
command: List of arguments to pass to subprocess.Popen
report_interval: Time in seconds between updating reports.
+
+ command_complete(returncode): Callback that runs
+ when the process has ended.
+ returncode is -1 if the process was terminated.
"""
@staticmethod
@@ -107,6 +111,8 @@ class SubprocessHelper:
wm.event_timer_remove(self._timer)
window.cursor_set('DEFAULT')
+ def command_complete(self, returncode):
+ pass
def modal(self, context, event):
wm = context.window_manager
@@ -121,6 +127,7 @@ class SubprocessHelper:
if p.poll() is not None:
self._report_output()
self._wm_exit(context)
+ self.command_complete(p.returncode)
return {'FINISHED'}
self._report_output()
@@ -156,4 +163,5 @@ class SubprocessHelper:
def cancel(self, context):
self._wm_exit(context)
self._process.kill()
+ self.command_complete(-1)
More information about the Bf-extensions-cvs
mailing list