Decorator for sarge that translate async to async_
Should work around issues with third party plugins that haven't yet adapted.
This commit is contained in:
1 parent
7d7cbb1760
commit
db8d420860
2 files changed
+41
No files matched your search
@@ -595,6 +595,9 @@ def main():
|
||||
# cut off stuff from the beginning
|
||||
args = args[-1 * sys_args_length:] if sys_args_length else []
|
||||
|
||||
from octoprint.util.fixes import fix_sarge_async
|
||||
fix_sarge_async()
|
||||
|
||||
from octoprint.cli import octo
|
||||
octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
This module contains a functions that monkey patch third party dependencies in the one or other way.
|
||||
"""
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import functools
|
||||
import warnings
|
||||
|
||||
def fix_sarge_async():
|
||||
def move_async(f):
|
||||
@functools.wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
if "async" in kwargs:
|
||||
warnings.warn("sarge's \"async\" parameter is deprecated. Use \"_async\" instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2)
|
||||
kwargs["async_"] = kwargs.pop("async")
|
||||
return f(*args, **kwargs)
|
||||
return decorated_function
|
||||
|
||||
import sarge
|
||||
|
||||
# wrap helper
|
||||
sarge.run = move_async(sarge.run)
|
||||
|
||||
# wrap Command
|
||||
sarge.Command.run = move_async(sarge.Command.run)
|
||||
|
||||
# wrap Pipeline
|
||||
sarge.Pipeline.run = move_async(sarge.Pipeline.run)
|
||||
sarge.Pipeline.run_command_node = move_async(sarge.Pipeline.run_command_node)
|
||||
sarge.Pipeline.run_list_node = move_async(sarge.Pipeline.run_list_node)
|
||||
sarge.Pipeline.run_logical_node = move_async(sarge.Pipeline.run_logical_node)
|
||||
sarge.Pipeline.run_node = move_async(sarge.Pipeline.run_node)
|
||||
sarge.Pipeline.run_node_in_thread = move_async(sarge.Pipeline.run_node_in_thread)
|
||||
sarge.Pipeline.run_pipeline_node = move_async(sarge.Pipeline.run_pipeline_node)
|
||||
Reference in new issue
Block a user