etho.utils.runner#
- class etho.utils.runner.Runner(host: str, host_is_win: bool = False, host_is_remote: bool = False, python_exe: str = 'python')[source]#
Manages remote processes.
_summary_
- Parameters
host (str) – Host name or IP address of the machine to run the commands on.
host_is_win (bool, optional) – Defaults to False.
host_is_remote (bool, optional) – If False, run commands locallu. If True, run commands via ssh (fabric). Defaults to False.
python_exe (str, optional) – _description_. Defaults to “python”.
- is_running(pids: List[int]) bool [source]#
Return True if at least one of the pids is in list of running processes.
- pid(query: str) List[int] [source]#
Get pids of all processes partially matching
query
.- Parameters
query (str) – Process cmdline by which process can be recognized.
- Returns
PIDs matching query
- Return type
List[int]
- run(cmd: str, timeout: Optional[float] = None, asynchronous: Optional[bool] = False, disown: bool = False, run_local: bool = False, new_console: bool = False) Optional[Union[invoke.runners.Result, invoke.runners.Promise]] [source]#
_summary_
- Parameters
cmd (str) – _description_
timeout (Optional[float], optional) – _description_. Defaults to None.
asynchronous (bool, optional) – _description_. Defaults to False.
disown (bool, optional) – _description_. Defaults to False.
run_local (bool, optional) – Run cmd locally. Overrides host_is_remote attribute. Defaults to False.
new_console (bool, optional) – _description_. Defaults to False.
- Returns
(asynchronous=False) invoke.runners.Result (asynchronous=True) invoke.runners.Promise (disown=True or new_console=True if host_is_win) None
- Raises
UnexpectedExit, if the command exited nonzero and warn was False. –
Failure, if the command didnt even exit cleanly, e.g. if a StreamWatcher raised WatcherError. –