File: shell.py

package info (click to toggle)
intel-gpu-tools 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,360 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (30 lines) | stat: -rw-r--r-- 980 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# SPDX-License-Identifier: MIT
# Copyright © 2024 Intel Corporation

import signal

from bench.executors.executor_interface import ExecutorInterface
from bench.machines.machine_interface import (DEFAULT_TIMEOUT,
                                              MachineInterface, ProcessResult)


class ShellExecutor(ExecutorInterface):
    def __init__(self, target: MachineInterface, command: str, timeout: int = DEFAULT_TIMEOUT) -> None:
        self.target = target
        self.timeout = timeout
        self.pid = self.target.execute(command)

    def status(self) -> ProcessResult:
        return self.target.execute_status(self.pid)

    def wait(self) -> ProcessResult:
        return self.target.execute_wait(self.pid, self.timeout)

    def sendsig(self, sig: signal.Signals) -> None:
        self.target.execute_signal(self.pid, sig)

    def terminate(self) -> None:
        self.sendsig(signal.SIGTERM)

    def kill(self) -> None:
        self.sendsig(signal.SIGKILL)