fmartingr
/
jeeves
Archived
1
0
Fork 0
This repository has been archived on 2021-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
jeeves/jeeves/core/tasks/shell.py

27 lines
596 B
Python

import subprocess
from typing import Text
import pydantic
from jeeves.core.objects import Result
from .base import Task
class ShellTask(Task):
id = "library/shell"
verbose_name = "Execute Shell script"
class Parameters(pydantic.BaseModel):
script: Text
def execute(self):
process = subprocess.run(
self.parameters.script,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
return Result(
success=process.returncode == 0, output=process.stdout.decode("utf-8")
)