Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions contrib/debug/actions/print_ctx.py
Original file line number Diff line number Diff line change
@@ -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"})
20 changes: 20 additions & 0 deletions contrib/debug/actions/print_ctx.yaml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions contrib/debug/actions/python_version.py
Original file line number Diff line number Diff line change
@@ -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()))
7 changes: 7 additions & 0 deletions contrib/debug/actions/python_version.yaml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions contrib/debug/actions/pythonpath.py
Original file line number Diff line number Diff line change
@@ -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,
}
7 changes: 7 additions & 0 deletions contrib/debug/actions/pythonpath.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: pythonpath
description: Prints out the PYTHONPATH
pack: debug
runner_type: python-script
entry_point: pythonpath.py
enabled: true
8 changes: 8 additions & 0 deletions contrib/debug/pack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: debug
description: Debug utilities for StackStorm
ref: debug
author: StackStorm Authors
email: [email protected]
version: "0.0.1"
python_versions:
- "3"