관리-도구
편집 파일: process_utils.cpython-39.pyc
a d4h9 � @ sf d dl Z d dlZd dlZddlmZ ddlmZ ej ddd��Zdd d �Zdd� Z d d� Zdd� ZdS )� N� )� log_utils)�utilsTc C sR |pd}|D ]&}t j�|| �}t j�|�r| S q|rJtd�| |���nd S d S )N)z /usr/sbinz/sbinz/usr/binz/binz{0} could not be found at {1})�os�path�join�isfile� Exception�format)�name�pathsZ raise_exc�it�fname� r �3/usr/libexec/kcare/python/kcarectl/process_utils.py�find_cmd s r Fc C s� |r t jnd }|rt jnd }t j| |||d�}|�� \}}|j} |d urRt�|�}|d urdt�|�}t�t � d�j|j||d�| �d�� | ||fS )N)�stdout�stderr�shellz� Call result for `{cmd}`: exit code {exit_code} === STDOUT === {stdout} === STDERR === {stderr} === END === � )Z exit_coder r �cmd) � subprocess�PIPE�Popen�communicate� returncoder �nstrr �logdebug�textwrap�dedentr r ) Zcommand�catch_stdout�catch_stderrr r r �pZstdout_capturedZstderr_captured�coder r r �run_command s"