wazuh / qa-system-framework

GNU General Public License v2.0
1 stars 3 forks source link

Add generic module to manage process execution #5

Closed jmv74211 closed 1 year ago

jmv74211 commented 1 year ago

It is requested to create a module that allows us to manage process execution locally.

jmv74211 commented 1 year ago

First approach

We want to build a class to be able to execute processes locally, so that both the result, output, stderr... is managed in a simple and parameterized way. The objective is to provide a high-level layer to the psutil library in relation to run processes.

Process():
    - Attributes:
        - command (str or list(str)): Command (string or splitted in list) to run.
        - capture_stdout (boolean): True for capturing the process stdout, False otherwise.
        - capture_stderr (boolean): True for capturing the process stderr, False otherwise.
        - stdout (str): Process stdout if captured with capture_stdout=True.
        - stderr (str): Process stderr if captured with capture_stderr=True.
        - wait (boolean): True for waiting until the process is finished, False otherwise.
        - timeout (int): Num seconds to wait until the process is finished. If it's exceeded, exception will be generated.
        - process (psutil.Process): Process object.
    - Methods:
        - run
        - get_stdout
        - get_stderr
        - get_status
        - get_pid
        - kill
        - get_return_code
jmv74211 commented 1 year ago

2023-03-03

jmv74211 commented 1 year ago

2023-03-06