Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ZihengSun committed Jun 5, 2023
1 parent cb507cb commit 5645c89
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pygeoweaver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def get_root_dir():
head, tail = os.path.split(__file__)
return head

def get_java_bin_from_which():
# Check if 'which' command is available
try:
subprocess.check_output(['which', 'java'])
except (subprocess.CalledProcessError, FileNotFoundError):
return None

# Run 'which java' command to get the Java binary path
try:
output = subprocess.check_output(['which', 'java'], encoding='utf-8')
java_bin_path = output.strip()
except subprocess.CalledProcessError:
return None

return java_bin_path

def get_java_bin_path():
# Check if the 'java' command is available in the system path
Expand All @@ -52,6 +67,9 @@ def get_java_bin_path():
java_bin_path = bin_path
break

if java_bin_path is None:
java_bin_path = get_java_bin_from_which()

print("java_bin_path: ", java_bin_path)
return java_bin_path

Expand Down

0 comments on commit 5645c89

Please sign in to comment.