codecraftai-taskplus 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccai/taskplus/__init__.py +0 -0
- ccai/taskplus/cli/__init__.py +0 -0
- ccai/taskplus/cli/cmdtree/__init__.py +0 -0
- ccai/taskplus/cli/cmdtree/workflow.py +153 -0
- ccai/taskplus/cli/taskpluscommand.py +25 -0
- ccai/taskplus/entrypoints.py +68 -0
- ccai/taskplus/execution.py +132 -0
- ccai/taskplus/initialize.py +44 -0
- ccai/taskplus/model/__init__.py +0 -0
- ccai/taskplus/model/flowengine.py +106 -0
- ccai/taskplus/model/flownode.py +40 -0
- ccai/taskplus/model/task.py +61 -0
- ccai/taskplus/model/taskgroup.py +27 -0
- ccai/taskplus/model/workflow.py +142 -0
- ccai/taskplus/py.typed +0 -0
- ccai/taskplus/tasks/__init__.py +0 -0
- ccai/taskplus/tasks/createenvironment.py +96 -0
- ccai/taskplus/tasks/embeddedpython.py +49 -0
- ccai/taskplus/tasks/gitcheckout.py +28 -0
- ccai/taskplus/tasks/runcommand.py +68 -0
- ccai/taskplus/tasks/shellscript.py +85 -0
- codecraftai_taskplus-1.3.0.dist-info/METADATA +25 -0
- codecraftai_taskplus-1.3.0.dist-info/RECORD +26 -0
- codecraftai_taskplus-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_taskplus-1.3.0.dist-info/entry_points.txt +3 -0
- codecraftai_taskplus-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
__author__ = "Myron Walker"
|
|
4
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
5
|
+
__credits__ = []
|
|
6
|
+
|
|
7
|
+
from typing import Any, Dict, List
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
|
|
15
|
+
from io import TextIOWrapper
|
|
16
|
+
from pprint import pformat
|
|
17
|
+
|
|
18
|
+
import yaml
|
|
19
|
+
|
|
20
|
+
from ccai.errors.exceptions import ConfigurationError
|
|
21
|
+
|
|
22
|
+
from ccai.xmodules.ximport import import_by_name
|
|
23
|
+
from ccai.xmodules.xformatting import indent_lines
|
|
24
|
+
|
|
25
|
+
from ccai.taskplus.model.flownode import FlowNode
|
|
26
|
+
from ccai.taskplus.model.task import Task
|
|
27
|
+
from ccai.taskplus.model.taskgroup import TaskGroup
|
|
28
|
+
|
|
29
|
+
logger = logging.getLogger()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Workflow:
|
|
33
|
+
|
|
34
|
+
def __init__(self, environment: Dict[str, str], parameters: Dict[str, Any], flow: List[FlowNode]):
|
|
35
|
+
self._environment = environment
|
|
36
|
+
self._parameters = parameters
|
|
37
|
+
self._flow = flow
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def environment(self) -> Dict[str, str]:
|
|
42
|
+
return self._environment
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def flow(self) -> List[FlowNode]:
|
|
46
|
+
return self._flow
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def parameters(self) -> Dict[str, Any]:
|
|
50
|
+
return self._parameters
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def parse(cls, workflow_stream: TextIOWrapper) -> "Workflow":
|
|
54
|
+
|
|
55
|
+
workflow_info = yaml.safe_load(workflow_stream)
|
|
56
|
+
|
|
57
|
+
environment = {}
|
|
58
|
+
if "environment" in workflow_info:
|
|
59
|
+
environment = workflow_info["environment"]
|
|
60
|
+
|
|
61
|
+
parameters = {}
|
|
62
|
+
if "parameters" in workflow_info:
|
|
63
|
+
parameters = workflow_info["parameters"]
|
|
64
|
+
|
|
65
|
+
if "name" not in workflow_info:
|
|
66
|
+
errmsg = "A workflow document must have a 'name' element."
|
|
67
|
+
raise ConfigurationError(errmsg)
|
|
68
|
+
|
|
69
|
+
if "flow" not in workflow_info:
|
|
70
|
+
errmsg = "A workflow document must have a 'flow' element which contains the tasks to be performed."
|
|
71
|
+
raise ConfigurationError(errmsg)
|
|
72
|
+
|
|
73
|
+
fnode_info_items = workflow_info["flow"]
|
|
74
|
+
|
|
75
|
+
flow_items = cls._process_flow_info_items(fnode_info_items)
|
|
76
|
+
|
|
77
|
+
workflow = Workflow(environment, parameters, flow_items)
|
|
78
|
+
|
|
79
|
+
return workflow
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def _process_flow_info_items(cls, fnode_info_items: List[Dict[str, Any]], ordinal_prefix: str="") -> List[FlowNode]:
|
|
83
|
+
|
|
84
|
+
flow_items: List[FlowNode] = []
|
|
85
|
+
|
|
86
|
+
ordinal_position = 0
|
|
87
|
+
|
|
88
|
+
for fnode_info in fnode_info_items:
|
|
89
|
+
|
|
90
|
+
ordinal_position += 1
|
|
91
|
+
|
|
92
|
+
next_ordinal = str(ordinal_position)
|
|
93
|
+
if len(ordinal_prefix) > 0:
|
|
94
|
+
next_ordinal = f"{ordinal_prefix}.{str(ordinal_position)}"
|
|
95
|
+
|
|
96
|
+
if "task" in fnode_info:
|
|
97
|
+
task_label = fnode_info["task"]
|
|
98
|
+
|
|
99
|
+
if "taskgroup" in fnode_info:
|
|
100
|
+
errmsg = "A 'task' node should not have a 'taskgroup' field."
|
|
101
|
+
raise ConfigurationError(errmsg)
|
|
102
|
+
|
|
103
|
+
task_type = fnode_info["tasktype"]
|
|
104
|
+
|
|
105
|
+
task_module_name, task_module_class = task_type.split("@")
|
|
106
|
+
task_module = import_by_name(task_module_name)
|
|
107
|
+
|
|
108
|
+
if hasattr(task_module, task_module_class):
|
|
109
|
+
task_class = getattr(task_module, task_module_class)
|
|
110
|
+
|
|
111
|
+
task_inst: Task = task_class(next_ordinal, task_label, fnode_info, logger)
|
|
112
|
+
flow_items.append(task_inst)
|
|
113
|
+
else:
|
|
114
|
+
error_msg = "The specified task module %r does not contain a class %r" % (
|
|
115
|
+
task_module_name, task_module_class)
|
|
116
|
+
raise ConfigurationError(error_msg) from None
|
|
117
|
+
|
|
118
|
+
elif "taskgroup" in fnode_info:
|
|
119
|
+
|
|
120
|
+
tg_label = fnode_info["taskgroup"]
|
|
121
|
+
|
|
122
|
+
if "items" not in fnode_info:
|
|
123
|
+
errmsg = "A 'taskgroup' node must have an 'items' field."
|
|
124
|
+
raise ConfigurationError(errmsg)
|
|
125
|
+
|
|
126
|
+
tg_items_info_list = fnode_info["items"]
|
|
127
|
+
|
|
128
|
+
tg_titems = cls._process_flow_info_items(tg_items_info_list, ordinal_prefix=next_ordinal)
|
|
129
|
+
|
|
130
|
+
tgroup_inst = TaskGroup(next_ordinal, tg_label, fnode_info, tg_titems, logger)
|
|
131
|
+
flow_items.append(tgroup_inst)
|
|
132
|
+
|
|
133
|
+
else:
|
|
134
|
+
errmsg_lines = [
|
|
135
|
+
"Unknown workflow node encountered."
|
|
136
|
+
]
|
|
137
|
+
errmsg_lines.append(indent_lines(pformat(fnode_info, indent=4, depth=2), level=1))
|
|
138
|
+
|
|
139
|
+
errmsg = os.linesep.join(errmsg_lines)
|
|
140
|
+
raise ConfigurationError(errmsg)
|
|
141
|
+
|
|
142
|
+
return flow_items
|
ccai/taskplus/py.typed
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: createenvironment
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: A module that provides the CreateEnvironment task class which implements
|
|
5
|
+
the execution of environment creation commands.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, Optional
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import subprocess
|
|
19
|
+
|
|
20
|
+
from ccai.taskplus.model.task import Task
|
|
21
|
+
|
|
22
|
+
class CreateEnvironment(Task):
|
|
23
|
+
"""
|
|
24
|
+
A task class that is used to create environment variables that persist and
|
|
25
|
+
are consumable over the entire workflow.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, ordinal: int, label: str, task_info: dict, logger):
|
|
29
|
+
super(CreateEnvironment, self).__init__(ordinal, label, task_info, logger)
|
|
30
|
+
self._variables = task_info["variables"]
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def variables(self) -> Dict[str, str]:
|
|
35
|
+
return self._variables
|
|
36
|
+
|
|
37
|
+
def perform_task(self, environment: Dict[str, str], parameters: Optional[Dict[str, Any]], flowstate: Dict[str, Any]) -> int:
|
|
38
|
+
|
|
39
|
+
status_code = 0
|
|
40
|
+
|
|
41
|
+
for var_info in self._variables:
|
|
42
|
+
var_name = var_info["name"]
|
|
43
|
+
|
|
44
|
+
if "command" in var_info:
|
|
45
|
+
var_command = var_info["command"]
|
|
46
|
+
|
|
47
|
+
command_env = dict(os.environ)
|
|
48
|
+
|
|
49
|
+
# If "VIRTUAL_ENV" is set then we are running in a virtual environment, run the shell command
|
|
50
|
+
# with the same virtual environment active. Activation is expressed through the environment
|
|
51
|
+
# of the child process (what an 'activate' script does) rather than a POSIX wrapper script, so
|
|
52
|
+
# it works with both 'bin' (POSIX) and 'Scripts' (Windows) virtual environment layouts.
|
|
53
|
+
if "VIRTUAL_ENV" in os.environ:
|
|
54
|
+
virtual_env = os.environ["VIRTUAL_ENV"]
|
|
55
|
+
|
|
56
|
+
if os.name == "nt":
|
|
57
|
+
virtual_env_bin = os.path.join(virtual_env, 'Scripts')
|
|
58
|
+
else:
|
|
59
|
+
virtual_env_bin = os.path.join(virtual_env, 'bin')
|
|
60
|
+
|
|
61
|
+
command_env["VIRTUAL_ENV"] = virtual_env
|
|
62
|
+
command_env["PATH"] = os.pathsep.join([virtual_env_bin, os.environ.get("PATH", "")])
|
|
63
|
+
if "PYTHONHOME" in command_env:
|
|
64
|
+
del command_env["PYTHONHOME"]
|
|
65
|
+
|
|
66
|
+
# The command is a shell line, so it must be handed to the shell as a single string. Wrapping it
|
|
67
|
+
# in a list makes Windows re-quote the whole line into one token that is not recognized.
|
|
68
|
+
proc = subprocess.Popen(var_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=command_env)
|
|
69
|
+
stdout, stderr = proc.communicate()
|
|
70
|
+
exit_code = proc.wait()
|
|
71
|
+
|
|
72
|
+
if exit_code == 0:
|
|
73
|
+
var_val = stdout.decode().strip()
|
|
74
|
+
os.environ[var_name] = var_val
|
|
75
|
+
else:
|
|
76
|
+
stderr_text = stderr.decode()
|
|
77
|
+
errmsg_lines = [
|
|
78
|
+
"Error creating environment variable '{}' with:".format(var_name),
|
|
79
|
+
"COMMAND: {}".format(var_command),
|
|
80
|
+
"STDERR: {}".format(stderr_text)
|
|
81
|
+
]
|
|
82
|
+
errmsg = os.linesep.join(errmsg_lines)
|
|
83
|
+
self._logger.error(errmsg)
|
|
84
|
+
status_code = 1
|
|
85
|
+
elif "value" in var_info:
|
|
86
|
+
var_val = os.path.expandvars(os.path.expanduser(var_info["value"]))
|
|
87
|
+
os.environ[var_name] = var_val
|
|
88
|
+
else:
|
|
89
|
+
errmsg_lines = [
|
|
90
|
+
"Error creating environment variable '{}': neither 'command' nor 'value' was specified.".format(var_name)
|
|
91
|
+
]
|
|
92
|
+
errmsg = os.linesep.join(errmsg_lines)
|
|
93
|
+
self._logger.error(errmsg)
|
|
94
|
+
status_code = 1
|
|
95
|
+
|
|
96
|
+
return status_code
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: shellscript
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: A module that provides the EmbeddedPython task class which implements
|
|
5
|
+
the execution of inline python based tasks in a workpacket.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, List, Optional
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
from ccai.taskplus.model.task import Task
|
|
20
|
+
|
|
21
|
+
class EmbeddedPython(Task):
|
|
22
|
+
"""
|
|
23
|
+
A task class that is used to setup the running of an embedded python script
|
|
24
|
+
in the context of the automation worker.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, ordinal: str, label: str, task_info: dict, logger):
|
|
28
|
+
super(EmbeddedPython, self).__init__(ordinal, label, task_info, logger)
|
|
29
|
+
self._script = task_info["script"]
|
|
30
|
+
return
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def script(self) -> List[str]:
|
|
34
|
+
return self._script
|
|
35
|
+
|
|
36
|
+
def perform_task(self, environment: Dict[str, str], parameters: Optional[Dict[str, Any]], flowstate: Dict[str, Any]) -> int:
|
|
37
|
+
|
|
38
|
+
script_content = os.linesep.join(self._script)
|
|
39
|
+
|
|
40
|
+
exit_status = 0
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
# Execute the inline python script in the context of the current
|
|
44
|
+
# globals and locals.
|
|
45
|
+
exec(script_content, globals(), locals())
|
|
46
|
+
except Exception:
|
|
47
|
+
exit_status = 1
|
|
48
|
+
|
|
49
|
+
return exit_status
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: gitcheckout
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: A module that provides the ShellScript task class which implements
|
|
5
|
+
the execution of shell based tasks in a workpacket.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, Optional
|
|
16
|
+
|
|
17
|
+
from ccai.taskplus.model.task import Task
|
|
18
|
+
|
|
19
|
+
class GitCheckout(Task):
|
|
20
|
+
|
|
21
|
+
def __init__(self, ordinal: str, label: str, task_info: dict, logger):
|
|
22
|
+
super(GitCheckout, self).__init__(ordinal, label, task_info, logger)
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
def perform_task(self, environment: Dict[str, str], parameters: Optional[Dict[str, Any]], flowstate: Dict[str, Any]) -> int:
|
|
26
|
+
|
|
27
|
+
exit_code = 0
|
|
28
|
+
return exit_code
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: runcommand
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: A module that provides the RunCommand task class which implements
|
|
5
|
+
the execution of a singular command based tasks in a workpacket.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from typing import Any, Dict, Optional
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import subprocess
|
|
19
|
+
|
|
20
|
+
from ccai.xmodules.xformatting import indent_lines
|
|
21
|
+
|
|
22
|
+
from ccai.taskplus.model.task import Task
|
|
23
|
+
|
|
24
|
+
class RunCommand(Task):
|
|
25
|
+
"""
|
|
26
|
+
A task class that runs a single command line through the platform shell
|
|
27
|
+
('/bin/sh' on POSIX systems, 'cmd.exe' on Windows). The 'command' entry
|
|
28
|
+
of the task information is a shell line, not an argument vector, so shell
|
|
29
|
+
built-ins such as 'echo' and 'exit' are valid commands.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, ordinal: str, label: str, task_info: dict, logger):
|
|
33
|
+
super(RunCommand, self).__init__(ordinal, label, task_info, logger)
|
|
34
|
+
self._command = task_info["command"]
|
|
35
|
+
return
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def command(self) -> str:
|
|
39
|
+
return self._command
|
|
40
|
+
|
|
41
|
+
def perform_task(self, environment: Dict[str, str], parameters: Optional[Dict[str, Any]], flowstate: Dict[str, Any]) -> int:
|
|
42
|
+
|
|
43
|
+
self._logger.info("Running Command: %s" % self._command)
|
|
44
|
+
|
|
45
|
+
# The command is a shell line, so it must be handed to the shell as a single string. Wrapping it
|
|
46
|
+
# in a list makes Windows re-quote the whole line into one token ('"echo hello"' is not recognized).
|
|
47
|
+
proc = subprocess.Popen(self._command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
48
|
+
stdout, stderr = proc.communicate()
|
|
49
|
+
exit_code = proc.wait()
|
|
50
|
+
|
|
51
|
+
stdout = stdout.decode()
|
|
52
|
+
stderr = stderr.decode()
|
|
53
|
+
|
|
54
|
+
log_msg_lines = [
|
|
55
|
+
"RESULT CODE: %d" % exit_code,
|
|
56
|
+
"STDOUT:",
|
|
57
|
+
indent_lines(stdout, level=1),
|
|
58
|
+
"STDERR:",
|
|
59
|
+
indent_lines(stderr, level=1),
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
log_msg = os.linesep.join(log_msg_lines)
|
|
63
|
+
if exit_code == 0:
|
|
64
|
+
self._logger.info(log_msg)
|
|
65
|
+
else:
|
|
66
|
+
self._logger.error(log_msg)
|
|
67
|
+
|
|
68
|
+
return exit_code
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: shellscript
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: A module that provides the ShellScript task class which implements
|
|
5
|
+
the execution of shell based tasks in a workpacket.
|
|
6
|
+
|
|
7
|
+
.. moduleauthor:: Myron Walker <myron.walker@gmail.com>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__author__ = "Myron Walker"
|
|
11
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
12
|
+
__credits__ = []
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from typing import Any, Dict, Optional
|
|
17
|
+
|
|
18
|
+
import os
|
|
19
|
+
import stat
|
|
20
|
+
import subprocess
|
|
21
|
+
|
|
22
|
+
from ccai.thisapp.paths import get_temporary_file
|
|
23
|
+
from ccai.xmodules.xformatting import indent_lines
|
|
24
|
+
|
|
25
|
+
from ccai.taskplus.model.task import Task
|
|
26
|
+
|
|
27
|
+
class ShellScript(Task):
|
|
28
|
+
"""
|
|
29
|
+
A task class that writes the 'script' lines of the task information to a
|
|
30
|
+
temporary script file and runs that file with the platform shell. On POSIX
|
|
31
|
+
systems the script is a '.sh' file run by '/bin/sh', on Windows it is a
|
|
32
|
+
'.cmd' file run by 'cmd.exe'.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, ordinal: str, label: str, task_info: dict, logger):
|
|
36
|
+
super(ShellScript, self).__init__(ordinal, label, task_info, logger)
|
|
37
|
+
self._script = task_info["script"]
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def script(self) -> str:
|
|
42
|
+
return self._script
|
|
43
|
+
|
|
44
|
+
def perform_task(self, environment: Dict[str, str], parameters: Optional[Dict[str, Any]], flowstate: Dict[str, Any]) -> int:
|
|
45
|
+
|
|
46
|
+
script_content = os.linesep.join(self._script)
|
|
47
|
+
|
|
48
|
+
# The platform shell only runs script files it recognizes, so the suffix has to match the shell.
|
|
49
|
+
if os.name == "nt":
|
|
50
|
+
script_suffix = ".cmd"
|
|
51
|
+
else:
|
|
52
|
+
script_suffix = ".sh"
|
|
53
|
+
|
|
54
|
+
tempfile = get_temporary_file(prefix="step-%s" % self._ordinal, suffix=script_suffix)
|
|
55
|
+
|
|
56
|
+
self._logger.info("Running Script: %s" % tempfile)
|
|
57
|
+
|
|
58
|
+
with open(tempfile, 'w') as tf:
|
|
59
|
+
tf.write(script_content)
|
|
60
|
+
|
|
61
|
+
os.chmod(tempfile, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
|
|
62
|
+
|
|
63
|
+
# Hand the script path to the shell as a single string so it is not re-quoted on Windows.
|
|
64
|
+
proc = subprocess.Popen(tempfile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
|
65
|
+
stdout, stderr = proc.communicate()
|
|
66
|
+
exit_code = proc.wait()
|
|
67
|
+
|
|
68
|
+
stdout_text = stdout.decode()
|
|
69
|
+
stderr_text = stderr.decode()
|
|
70
|
+
|
|
71
|
+
log_msg_script = [
|
|
72
|
+
"RESULT CODE: %d" % exit_code,
|
|
73
|
+
"STDOUT:",
|
|
74
|
+
indent_lines(stdout_text, level=1),
|
|
75
|
+
"STDERR:",
|
|
76
|
+
indent_lines(stderr_text, level=1),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
log_msg = os.linesep.join(log_msg_script)
|
|
80
|
+
if exit_code == 0:
|
|
81
|
+
self._logger.info(log_msg)
|
|
82
|
+
else:
|
|
83
|
+
self._logger.error(log_msg)
|
|
84
|
+
|
|
85
|
+
return exit_code
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codecraftai-taskplus
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Code Craft AI Task Plus Library
|
|
5
|
+
License-Expression: LicenseRef-CodeCraftAI-Source-Available
|
|
6
|
+
License-File: LICENSE.md
|
|
7
|
+
Keywords: python
|
|
8
|
+
Author: Myron Walker
|
|
9
|
+
Author-email: myron.walker@gmail.com
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
14
|
+
Requires-Dist: codecraftai-foundations (<2.0.0)
|
|
15
|
+
Requires-Dist: codecraftai-runtime (<2.0.0)
|
|
16
|
+
Requires-Dist: codecraftai-this-app (<2.0.0)
|
|
17
|
+
Requires-Dist: codecraftai-xmodules (<2.0.0)
|
|
18
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
19
|
+
Project-URL: Homepage, https://code-craft.ai
|
|
20
|
+
Project-URL: Repository, https://github.com/code-craft-ai-company/codecraftai-taskplus
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Code Craft AI - TaskPlus Package
|
|
24
|
+
This is a preliminary release of the TaskPlus job engine. This is a very preliminary release and is not intended for public consumption yet.
|
|
25
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ccai/taskplus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
ccai/taskplus/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
ccai/taskplus/cli/cmdtree/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
ccai/taskplus/cli/cmdtree/workflow.py,sha256=xSBpLoHxEJ2ZF2_bFQ5fqbNcOb4dmTQBUgVsX_xC2X4,6569
|
|
5
|
+
ccai/taskplus/cli/taskpluscommand.py,sha256=6CRNVPJfTtQDab_4B7OPWtS_Wyuh_P7R9qCKYZnCggQ,653
|
|
6
|
+
ccai/taskplus/entrypoints.py,sha256=FkWGAN4jkqrW-5BkwEoD2ORAf0no_1KgjjCrB3y11vo,1764
|
|
7
|
+
ccai/taskplus/execution.py,sha256=5_00FPvvrJhtL2zkPZsry8svnZ0X36QDaNZxckbGuUs,4378
|
|
8
|
+
ccai/taskplus/initialize.py,sha256=gJLObG3H7g-kMs1Tnms_1zwOV36IgYxYtjo_DezHKGg,1570
|
|
9
|
+
ccai/taskplus/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
ccai/taskplus/model/flowengine.py,sha256=OT3yU-xWpnEV455mnD-MDbLtBDBx0Bu4aCRiqEQZF4A,3635
|
|
11
|
+
ccai/taskplus/model/flownode.py,sha256=rK2coRW7tyrgHaKGGa7rDU-I8ENZqReGZuLm89geXkw,835
|
|
12
|
+
ccai/taskplus/model/task.py,sha256=_X69azhOVEsm1ySZ0K-f29tnm203P-cleIiNuNumbx8,1559
|
|
13
|
+
ccai/taskplus/model/taskgroup.py,sha256=Jsi1Gvs1UTstehFt5KpMshvE0MvH8OFcMdZGMm8vipU,548
|
|
14
|
+
ccai/taskplus/model/workflow.py,sha256=4YPw_CvvJRJTc1vCMIWfPBLfFTkn7zxv9J0Kjj-Eem8,4404
|
|
15
|
+
ccai/taskplus/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
ccai/taskplus/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
ccai/taskplus/tasks/createenvironment.py,sha256=AnRQwTtc7CQy-vregzYMI_aU44zn3cwjn1Wohj5k-Kk,3989
|
|
18
|
+
ccai/taskplus/tasks/embeddedpython.py,sha256=pTdvAw2tQ-fhN-8rU5Uo-QmBEwuo4yb2fkZMpJpUpas,1434
|
|
19
|
+
ccai/taskplus/tasks/gitcheckout.py,sha256=74zciNIme8Ma9qTJKUkF8lSF_C7iUazGmfKBu0CALCs,835
|
|
20
|
+
ccai/taskplus/tasks/runcommand.py,sha256=84pEOTB2hVHh8ommdyFzi3E5xZ37N-vJzVGiny2C2Bo,2259
|
|
21
|
+
ccai/taskplus/tasks/shellscript.py,sha256=sTWR_YTZsnUpy6ggF5KbeFHZEvKLpfTaXrP285EcTS8,2698
|
|
22
|
+
codecraftai_taskplus-1.3.0.dist-info/METADATA,sha256=Xk4RQL9sqB848jh_5tr-9wM_FclqJCwNBfqLDkXgviY,990
|
|
23
|
+
codecraftai_taskplus-1.3.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
24
|
+
codecraftai_taskplus-1.3.0.dist-info/entry_points.txt,sha256=HoTOUIzh_yMhZ_Z3gL_b-Bzkx-e2ntNZFHQAwbiVMbc,84
|
|
25
|
+
codecraftai_taskplus-1.3.0.dist-info/licenses/LICENSE.md,sha256=5tyUZ2kpPxNXbULzrdiT14-ZV-jCBeBFL0xyO-zt1mg,17907
|
|
26
|
+
codecraftai_taskplus-1.3.0.dist-info/RECORD,,
|