mirror of https://github.com/explosion/spaCy.git
add custom warning when run_command fails
This commit is contained in:
parent
39953c7c60
commit
60f97bc519
|
@ -539,6 +539,7 @@ class Errors(object):
|
|||
E199 = ("Unable to merge 0-length span at doc[{start}:{end}].")
|
||||
|
||||
# TODO: fix numbering after merging develop into master
|
||||
E970 = ("Can not execute command '{str_command}'. Do you have '{tool}' installed?")
|
||||
E971 = ("Found incompatible lengths in Doc.from_array: {array_length} for the "
|
||||
"array and {doc_length} for the Doc itself.")
|
||||
E972 = ("Example.__init__ got None for '{arg}'. Requires Doc.")
|
||||
|
|
|
@ -452,7 +452,12 @@ def run_command(command: Union[str, List[str]]) -> None:
|
|||
"""
|
||||
if isinstance(command, str):
|
||||
command = split_command(command)
|
||||
status = subprocess.call(command, env=os.environ.copy())
|
||||
try:
|
||||
status = subprocess.call(command, env=os.environ.copy())
|
||||
except FileNotFoundError:
|
||||
raise FileNotFoundError(
|
||||
Errors.E970.format(str_command=" ".join(command), tool=command[0])
|
||||
)
|
||||
if status != 0:
|
||||
sys.exit(status)
|
||||
|
||||
|
|
Loading…
Reference in New Issue