Commit 6cf79f49 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Add informative python/vpython error message

When running blink web tests it is important to invoke the wrapper
script (run_isolated_script_test.py) with vpython or else psutil and six
will fail to import.

This change wraps the import of psutil and six in an exception handler
so that a useful error message can be printed. This should make it
easier for users to find the correct solution.

Change-Id: Ia2712e97790d8b54bb9cc640ace37a0fe01ce1c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495868
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820453}
parent 433b7179
...@@ -18,7 +18,10 @@ SIX_DIR = os.path.join( ...@@ -18,7 +18,10 @@ SIX_DIR = os.path.join(
'six') 'six')
sys.path.insert(0, SIX_DIR) sys.path.insert(0, SIX_DIR)
import six try:
import six
except ImportError:
raise Exception('Failed to import six. Run under vpython or install six.')
# This is hardcoded to be src/ relative to this script. # This is hardcoded to be src/ relative to this script.
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
import os import os
import os.path import os.path
import psutil
import random import random
import re import re
import signal import signal
...@@ -18,6 +17,11 @@ import threading ...@@ -18,6 +17,11 @@ import threading
import time import time
import test_env import test_env
try:
import psutil
except ImportError:
raise Exception(
'Failed to import psutil. Run under vpython or install psutil.')
class _XvfbProcessError(Exception): class _XvfbProcessError(Exception):
"""Exception raised when Xvfb cannot start.""" """Exception raised when Xvfb cannot start."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment