twister: Remove import exception handler for psutil

`handlers.py` treats the `psutil` package as optional and quietly prints
a message to stdout if it is not present, but it is actually a hard
requirement for the base `Handler` class. This try/except block is bad
as it hides the requirement until a timeout occurs and the handler
attempts to use `psutil` in the terminate method, which will crash if
the module happens to be missing.

This PR removes the try/except guard so missing `psutil` will cause
twister to immediately fail. `psutil` is already specified in the
`requirements.txt` file, so this should only affect users who
unwittingly have an outdated/incorrect environment.

Also update the Github Action for twister tests to install from
requirements files.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
This commit is contained in:
Tristan Honscheid 2022-08-24 12:50:22 -06:00 committed by Anas Nashif
parent 6986185c81
commit 52db2d8279
2 changed files with 2 additions and 6 deletions

View file

@ -42,7 +42,7 @@ jobs:
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: install-packages
run: |
pip3 install pytest colorama pyyaml ply mock pykwalify
pip3 install -r scripts/requirements-base.txt -r scripts/requirements-build-test.txt
- name: Run pytest
env:
ZEPHYR_BASE: ./

View file

@ -16,6 +16,7 @@ import subprocess
import threading
import select
import re
import psutil
from twisterlib.environment import ZEPHYR_BASE
try:
@ -23,11 +24,6 @@ try:
except ImportError:
print("Install pyserial python module with pip to use --device-testing option.")
try:
import psutil
except ImportError:
print("Install psutil python module with pip to run in Qemu.")
try:
import pty
except ImportError as capture_error: