Skip to content
Snippets Groups Projects

4.0.1 Patches,

Merged Iain Powrie requested to merge dev into master
2 files
+ 49
0
Compare changes
  • Side-by-side
  • Inline
Files
2
import contextlib
import os
import re
import winreg
import sys
import json
import tempfile
@@ -101,6 +102,39 @@ class Helpers:
def get_servers_root_dir(self):
return self.servers_dir
@staticmethod
def which_java():
# Adapted from LeeKamentsky's https://github.com/LeeKamentsky/python-javabridge/blob/master/javabridge/locate.py
jdk_key_paths = (
"SOFTWARE\\JavaSoft\\JDK",
"SOFTWARE\\JavaSoft\\Java Development Kit",
)
for jdk_key_path in jdk_key_paths:
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, jdk_key_path) as kjdk:
kjdk_values = dict(
[
winreg.EnumValue(kjdk, i)[:2]
for i in range(winreg.QueryInfoKey(kjdk)[1])
]
)
current_version = kjdk_values["CurrentVersion"]
kjdk_current = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, jdk_key_path + "\\" + current_version
)
kjdk_current_values = dict(
[
winreg.EnumValue(kjdk_current, i)[:2]
for i in range(winreg.QueryInfoKey(kjdk_current)[1])
]
)
return kjdk_current_values["JavaHome"]
except WindowsError as e:
if e.errno == 2:
continue
else:
raise
@staticmethod
def check_internet():
try:
Loading