Skip to content
Open
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
28 changes: 14 additions & 14 deletions src/madengine/core/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

class Console:
"""Class to run console commands.

Attributes:
shellVerbose (bool): The shell verbose flag.
live_output (bool): The live output flag.
"""
def __init__(
self,
shellVerbose: bool=True,
self,
shellVerbose: bool=True,
live_output: bool=False
) -> None:
"""Constructor of the Console class.

Args:
shellVerbose (bool): The shell verbose flag.
live_output (bool): The live output flag.
Expand All @@ -34,24 +34,24 @@ def __init__(
self.live_output = live_output

def sh(
self,
command: str,
canFail: bool=False,
timeout: int=60,
secret: bool=False,
prefix: str="",
self,
command: str,
canFail: bool=False,
timeout: int=60,
secret: bool=False,
prefix: str="",
env: typing.Optional[typing.Dict[str, str]]=None
) -> str:
"""Run shell command.

Args:
command (str): The shell command.
canFail (bool): The flag to allow failure.
timeout (int): The timeout in seconds.
secret (bool): The flag to hide the command.
prefix (str): The prefix of the output.
env (typing_extensions.TypedDict): The environment variables.

Returns:
str: The output of the shell command.

Expand Down Expand Up @@ -89,7 +89,7 @@ def sh(
except subprocess.TimeoutExpired as exc:
proc.kill()
raise RuntimeError("Console script timeout") from exc

# Check for failure
if proc.returncode != 0:
if not canFail:
Expand All @@ -107,6 +107,6 @@ def sh(
+ "' failed with exit code "
+ str(proc.returncode)
)

# Return the output
return outs.strip()
Loading