DImuthuUpe commented on code in PR #105:
URL: https://github.com/apache/airavata-mft/pull/105#discussion_r1240593238


##########
python-cli/mft_cli/airavata_mft_cli/bootstrap.py:
##########
@@ -62,15 +64,51 @@ def stop_service(bin_path, daemon_script_name):
   finally:
     os.chdir(current_dir)
 
+
+def check_java_version_method(required_version):

Review Comment:
   Change the signature to validate_java_vailability



##########
python-cli/mft_cli/airavata_mft_cli/bootstrap.py:
##########
@@ -62,15 +64,51 @@ def stop_service(bin_path, daemon_script_name):
   finally:
     os.chdir(current_dir)
 
+
+def check_java_version_method(required_version):
+  """
+      Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+      References:
+      ---------
+      
https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+      
https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+  """
+  if shutil.which("java"):
+    res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
+    system_version = ''
+    count = 0
+    for c in res:
+      if c == '"' or count == 1:
+        if (c == '.' or c == '"') and count == 1:
+          break
+        if count == 0:
+          count += 1
+          continue
+        system_version += c
+
+    system_version = int(system_version)
+    if system_version < required_version:
+      print("Airavata MFT requires Java version 11 or higher")

Review Comment:
   "Airavata MFT requires Java version " + required_version + " or higher"



##########
python-cli/mft_cli/airavata_mft_cli/bootstrap.py:
##########
@@ -62,15 +64,51 @@ def stop_service(bin_path, daemon_script_name):
   finally:
     os.chdir(current_dir)
 
+
+def check_java_version_method(required_version):
+  """
+      Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+      References:
+      ---------
+      
https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+      
https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+  """
+  if shutil.which("java"):
+    res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')

Review Comment:
   It is initially unclear what the following for loop does to fetch the java 
version. I think it is better to add an example output for "res" in a comment. 
Something like "#openjdk version "18.0.2" 2022-07-19"



##########
python-cli/mft_cli/airavata_mft_cli/bootstrap.py:
##########
@@ -62,15 +64,51 @@ def stop_service(bin_path, daemon_script_name):
   finally:
     os.chdir(current_dir)
 
+
+def check_java_version_method(required_version):
+  """
+      Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+      References:
+      ---------
+      
https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+      
https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+  """
+  if shutil.which("java"):
+    res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
+    system_version = ''
+    count = 0
+    for c in res:
+      if c == '"' or count == 1:
+        if (c == '.' or c == '"') and count == 1:
+          break
+        if count == 0:
+          count += 1
+          continue
+        system_version += c
+
+    system_version = int(system_version)
+    if system_version < required_version:
+      print("Airavata MFT requires Java version 11 or higher")
+      print("If you have more than one version of java please set java version 
11 or higher to the path")

Review Comment:
   Same as above



##########
python-cli/mft_cli/airavata_mft_cli/bootstrap.py:
##########
@@ -62,15 +64,51 @@ def stop_service(bin_path, daemon_script_name):
   finally:
     os.chdir(current_dir)
 
+
+def check_java_version_method(required_version):
+  """
+      Issue 96: https://github.com/apache/airavata-mft/issues/96
+
+      References:
+      ---------
+      
https://stackoverflow.com/questions/31807882/get-java-version-number-from-python
+      
https://stackoverflow.com/questions/1332598/how-to-determine-whether-java-is-installed-on-a-system-through-python
+  """
+  if shutil.which("java"):
+    res = check_output(['java', '-version'], stderr=STDOUT).decode('utf-8')
+    system_version = ''

Review Comment:
   rename to java_version



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to