
    )                         S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSK	Jr   " S	 S
\R                  5      r " S S\5      rSS jrg)z;Utility functions for interacting with a java installation.    )absolute_import)division)unicode_literalsN)
exceptionsencoding)filesc                       \ rS rSrSrg)	JavaError    N__name__
__module____qualname____firstlineno____static_attributes__r       +lib/googlecloudsdk/command_lib/util/java.pyr   r          r   r   c                       \ rS rSrSrg)JavaVersionError!   r   Nr   r   r   r   r   r   !   r   r   r   c                    [         R                  " S5      nU(       d  [        SR                  U US95      e [        R
                  " [        R                  " USS/[        R                  S9SS9n[        S
R                  XS95      n[        R                  " SU5      nU(       a;  [        R                  " SU5      nU(       d  Ue[        UR                  S5      5      nO:[        R                  " SU5      nU(       d  Ue[        UR                  S5      5      nXa:  a  UeU$ ! [        R                   a    [        S	R                  XS95      ef = f)a9  Require that a certain version of Java is installed.

Args:
  for_text: str, the text explaining what Java is necessary for.
  min_version: int, the minimum major version to check for.

Raises:
  JavaError: if a Java executable is not found or has the wrong version.

Returns:
  str, Path to the Java executable.
javazPTo use the {for_text}, a Java {v}+ JRE must be installed and on your system PATH)for_textvz-Dfile.encoding=UTF-8z-version)stderrzutf-8r   zUnable to execute the java that was found on your PATH. The {for_text} requires a Java {v}+ JRE installed and on your system PATHzThe java executable on your PATH is not a Java {v}+ JRE. The {for_text} requires a Java {v}+ JRE installed and on your system PATH)r   r   zversion "1\.zversion "(\d+)\.(\d+)\.   zversion "([1-9][0-9]*)   )r	   FindExecutableOnPathr   formatr   Decode
subprocesscheck_outputSTDOUTCalledProcessErrorr   researchintgroup)r   min_version	java_pathoutputjava_exec_version_errormatchmajor_versions          r   RequireJavaInstalledr2   %   sV    ((0)	
 ..4fh7B /5 /DE E	Q__/<$$	& 	F -+AC ))OV
,%
 II0&9E##A'M II/8E##A'M 
!!	; 
	&	& Q
 ''-vxv'OQ QQs   9D% %-E)   )__doc__
__future__r   r   r   r(   r$   googlecloudsdk.corer   googlecloudsdk.core.utilr   r	   Errorr   r   r2   r   r   r   <module>r9      sF    B &  ' 	  * - *
   y 5r   