🐛 Handle case when java is not installed on system [skip ci]

This commit is contained in:
Nikhil Badyal
2022-11-26 13:41:05 +05:30
parent 6ec295144e
commit 8bf278a0e8
+14 -10
View File
@@ -15,18 +15,22 @@ class Patches(object):
@staticmethod @staticmethod
def check_java() -> None: def check_java() -> None:
"""Check if Java17 is installed.""" """Check if Java17 is installed."""
logger.debug("Checking if java is available") try:
jd = subprocess.check_output( logger.debug("Checking if java is available")
["java", "-version"], stderr=subprocess.STDOUT jd = subprocess.check_output(
).decode("utf-8") ["java", "-version"], stderr=subprocess.STDOUT
jd = jd[1:-1] ).decode("utf-8")
if "Runtime Environment" not in jd: jd = jd[1:-1]
logger.debug("Java Must be installed") if "Runtime Environment" not in jd:
exit(-1) logger.debug("Java Must be installed")
if "17" not in jd: exit(-1)
if "17" not in jd:
logger.debug("Java 17 Must be installed")
exit(-1)
logger.debug("Cool!! Java is available")
except subprocess.CalledProcessError:
logger.debug("Java 17 Must be installed") logger.debug("Java 17 Must be installed")
exit(-1) exit(-1)
logger.debug("Cool!! Java is available")
# noinspection DuplicatedCode # noinspection DuplicatedCode
def fetch_patches(self) -> None: def fetch_patches(self) -> None: