handle no java installed case based on exit code

This commit is contained in:
Craig Macdonald 2020-04-09 01:39:49 +01:00
parent e6ee4fdba3
commit ad42b7ebf6
1 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,7 @@
include "config.pxi" include "config.pxi"
import os import os
from shlex import split from shlex import split
from subprocess import check_output from subprocess import check_output, CalledProcessError
from os.path import dirname, join, exists from os.path import dirname, join, exists
from os import readlink from os import readlink
from sys import platform from sys import platform
@ -60,9 +60,14 @@ cdef find_java_home():
if platform in ('darwin'): if platform in ('darwin'):
# its a mac # its a mac
if not exists('/usr/libexec/java_home'): if not exists('/usr/libexec/java_home'):
# I believe this always exists, but just in case
return return
try:
java = check_output('/usr/libexec/java_home').strip().decode('utf8') java = check_output('/usr/libexec/java_home').strip().decode('utf8')
return java return java
except CalledProcessError as exc:
# java_home return non-zero exit code if no Javas are installed
return