Merge branch 'dev' into 'master'

Fix winreg import pass on non-NT systems

See merge request crafty-controller/crafty-4!344
This commit is contained in:
Iain Powrie 2022-06-15 04:48:38 +00:00
commit 025db1de77

View File

@ -1,7 +1,6 @@
import contextlib
import os
import re
import winreg
import sys
import json
import tempfile
@ -30,6 +29,12 @@ from app.classes.web.websocket_helper import WebSocketHelper
with redirect_stderr(NullWriter()):
import psutil
# winreg is only a package on windows-python. We will only import
# this on windows systems to avoid a module not found error
# this is only needed for windows java path shenanigans
if os.name == "nt":
import winreg
logger = logging.getLogger(__name__)
try:
@ -134,7 +139,7 @@ class Helpers:
)
)
return kjdk_current_values["JavaHome"]
except WindowsError as e: # pylint: disable=E0602
except OSError as e:
if e.errno == 2:
continue
raise