diff --git a/contrib/debug/actions/print_ctx.py b/contrib/debug/actions/print_ctx.py new file mode 100644 index 0000000000..6d39ad6c99 --- /dev/null +++ b/contrib/debug/actions/print_ctx.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +# Copyright 2020 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +try: + from st2common.runners.base_action import Action +except ImportError: + Action = object + + +class PrintCtxAction(Action): + def run(self, ctx=None, *args, **kwargs): + print(ctx) + + +if __name__ == "__main__": + pca = PrintCtxAction() + pca.run({"Hello": "World", "Foo": "Bar"}) diff --git a/contrib/debug/actions/print_ctx.yaml b/contrib/debug/actions/print_ctx.yaml new file mode 100644 index 0000000000..30610fddbe --- /dev/null +++ b/contrib/debug/actions/print_ctx.yaml @@ -0,0 +1,20 @@ +--- +name: print_ctx +description: | + Prints the entire ctx() of a workflow task to stdout. Use like this: + + tasks: + ... + print_context: + action: debug.print_ctx + input: + ctx: <% ctx() %> # or {{ ctx() }} + +pack: debug +runner_type: python-script +entry_point: print_ctx.py +enabled: true +parameters: + ctx: + required: true + type: object diff --git a/contrib/debug/actions/python_version.py b/contrib/debug/actions/python_version.py new file mode 100644 index 0000000000..f27120cded --- /dev/null +++ b/contrib/debug/actions/python_version.py @@ -0,0 +1,44 @@ +#!/usr/bin/python + +# Copyright 2020 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +try: + from st2common.runners.base_action import Action +except ImportError: + Action = object + + +class PythonVersionAction(Action): + def run(self, *args, **kwargs): + return { + "version": sys.version_info, + "details": { + "major": sys.version_info.major, + "minor": sys.version_info.minor, + "micro": sys.version_info.micro, + "releaselevel": sys.version_info.releaselevel, + "serial": sys.version_info.serial, + }, + } + + +if __name__ == "__main__": + import json + + pva = PythonVersionAction() + print(json.dumps(pva.run())) diff --git a/contrib/debug/actions/python_version.yaml b/contrib/debug/actions/python_version.yaml new file mode 100644 index 0000000000..bf4b72b298 --- /dev/null +++ b/contrib/debug/actions/python_version.yaml @@ -0,0 +1,7 @@ +--- +name: python_version +description: Returns the version of Python +pack: debug +runner_type: python-script +entry_point: python_version.py +enabled: true diff --git a/contrib/debug/actions/pythonpath.py b/contrib/debug/actions/pythonpath.py new file mode 100644 index 0000000000..1af41a558a --- /dev/null +++ b/contrib/debug/actions/pythonpath.py @@ -0,0 +1,31 @@ +#!/usr/bin/python + +# Copyright 2020 The StackStorm Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +from st2common.runners.base_action import Action + + +class PythonPathAction(Action): + def run(self, *args, **kwargs): + pythonpath = os.environ.get("PYTHONPATH") + if pythonpath: + pythonpath = pythonpath.split(":") + return { + "PYTHONPATH": pythonpath, + "sys.path": sys.path, + } diff --git a/contrib/debug/actions/pythonpath.yaml b/contrib/debug/actions/pythonpath.yaml new file mode 100644 index 0000000000..c685f3b2bf --- /dev/null +++ b/contrib/debug/actions/pythonpath.yaml @@ -0,0 +1,7 @@ +--- +name: pythonpath +description: Prints out the PYTHONPATH +pack: debug +runner_type: python-script +entry_point: pythonpath.py +enabled: true diff --git a/contrib/debug/pack.yaml b/contrib/debug/pack.yaml new file mode 100644 index 0000000000..41dd36b3d6 --- /dev/null +++ b/contrib/debug/pack.yaml @@ -0,0 +1,8 @@ +name: debug +description: Debug utilities for StackStorm +ref: debug +author: StackStorm Authors +email: info@stackstorm.com +version: "0.0.1" +python_versions: + - "3"