Skip to content

Commit

Permalink
Merge branch 'federico' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
martianbug committed Nov 7, 2023
2 parents 21a25a3 + a281c17 commit 47a7670
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions musif/extract/features/jsymbolic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ class JavaNotFoundError(RuntimeError):


def get_java_path():
java = __get_java_path_env()
if java is not None:
return java
java = __get_java_path_subprocess()
if java is not None:
return java
java = __get_java_path_env()
if java is not None:
return java
try:
java = __get_java_path_env()
if java is not None:
return java
java = __get_java_path_shutil()
if java is not None:
return java
except Exception as e:
exc = "Raised exception: " + str(e)
else:
exc = ""
raise JavaNotFoundError(
"Could not find Java Runtime Environment (JRE)! Please, set JAVA_HOME environment variable or make it available in the PATH."
"Could not find Java Runtime Environment (JRE)! Please, set JAVA_HOME environment variable or make it available in the PATH. " + exc
)


def __get_java_path_env():
if "JAVA_HOME" not in os.environ:
return None
if sys.platform == "win32":
java = os.path.join(os.environ["JAVA_HOME"], "bin", "java.exe")
else:
Expand All @@ -49,13 +53,6 @@ def __get_java_path_shutil():
return path


def __get_java_path_subprocess():
try:
return subprocess.check_output(["which", "java"]).decode("utf-8").strip()
except subprocess.CalledProcessError:
return None


def _jsymbolic_path():
if platform.system() == "Windows":
cache_dir = Path(os.getenv("APPDATA"), "jSymbolic")
Expand Down

0 comments on commit 47a7670

Please sign in to comment.