HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/fm-agent/dependencies/linux/python3.9/jpype/__pycache__/_jvmfinder.cpython-39.pyc
a

��iX2�@s�ddlZddlZgd�ZzddlZWney:dZYn0Gdd�de�ZGdd�de�Zdd�ZGd	d
�d
e	�Z
Gdd�de
�ZGd
d�de�Zej
fdd�ZddgZGdd�de
�ZdS)�N)�getDefaultJVMPath�JVMNotFoundException�JVMNotSupportedExceptionc@seZdZdZdS)raI Exception raised when no JVM was found in the search path.

    This exception is raised when the all of the places searched did not
    contain a JVM. The locations searched depend on the machine architecture.
    To avoid this exception specify the JAVA_HOME environment variable as a
    valid jre or jdk root directory.
    N��__name__�
__module__�__qualname__�__doc__�r
r
�B/usr/lib/fm-agent/dependencies/linux/python3.9/jpype/_jvmfinder.pyr src@seZdZdZdS)raj Exception raised when the JVM is not supported.

    This exception is raised after a search found a valid Java home directory
    was found, but the JVM shared library found is not supported. Typically
    this occures when the JVM does not match the architecture of Python
    32 vs 64 bit, or the JVM is older than the version used to compile
    JPype.
    Nrr
r
r
rr+srcCs2tjdkrt�}ntjdkr$t�}nt�}|��S)aO
    Retrieves the path to the default or first found JVM library

    Returns:
      The path to the JVM shared library file

    Raises:
      JVMNotFoundException: If there was no JVM found in the search path.
      JVMNotSupportedException: If the JVM was found was not compatible with
        Python due to cpu architecture.

    �win32�darwin)�sys�platform�WindowsJVMFinder�DarwinJVMFinder�LinuxJVMFinder�get_jvm_path)�finderr
r
rr7s

rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�	JVMFinderz'
    JVM library finder base class
    cCsd|_d|_|j|jf|_dS)�!
        Sets up members
        �	libjvm.so)�/usr/lib/jvm�	/usr/javaN)�_libfile�
_locations�_get_from_java_home�_get_from_known_locations�_methods��selfr
r
r�__init__Rs
�zJVMFinder.__init__cCsxd}d}t�|�D]F\}}}|j|vrtj�|�d}||vrDd}qtj�||j�Sq|rltd�|���td��dS)z�
        Recursively looks for the given file

        Parameters:
            java_home(str): A Java home folder
            filename(str): filename: Name of the file to find

        Returns:
            The first found file path, or None
        )ZcacaoZjamvmF�TzySorry '{0}' is known to be broken. Please ensure your JAVA_HOME contains at least another JVM implementation (eg. server)zsSorry no JVM could be found. Please ensure your JAVA_HOME environment variable is pointing to correct installation.N)	�os�walkr�path�split�joinr�formatr)r �	java_homeZnon_supported_jvmZfound_non_supported_jvm�root�_�names�	candidater
r
r�find_libjvm`s
�zJVMFinder.find_libjvmc	cs�g}d}|D]�}tj�|�sqtt�|��D]f}tj�tj�||��}||vs,tj�|�s\q,tj�|��	�}|D] }||vrp|�
|�|Vq,qpq,qdS)a*
        Generator that looks for the first-level children folders that could be
        Java installations, according to their name

        Parameters:
            parents (str[]): A list of parent directories

        Returns:
            A list of the possible JVM installation folders
        )ZjreZjdk�javaN)r#r%�exists�sorted�listdir�realpathr'�isdir�basename�lower�append)	r �parentsZhomesZ
java_names�parentZ	childnamer%Z	real_nameZ	java_namer
r
r�find_possible_homes�s
zJVMFinder.find_possible_homescCsdS)z�
        Check if the jvm is valid for this architecture.

        This method should be overriden for each architecture.

        Raises:
            JVMNotSupportedException: If the jvm is not supported.
        Nr
�r �jvmr
r
r�check�s	zJVMFinder.checkcCs�d}|jD]v}z|�}|r$|�|�WnHty8Yq
tyHYq
tyn}z|}WYd}~q
d}~00|dur
|Sq
|dur�|�td�|j���dS)z�
        Retrieves the path to the default or first found JVM library

        Returns:
            The path to the JVM shared library file

        Raises:
            ValueError: No JVM library found or No Support JVM found
        NzcNo JVM shared library file ({0}) found. Try setting up the JAVA_HOME environment variable properly.)rr=�NotImplementedErrorrrr(r)r Zjvm_notsupport_ext�methodr<�er
r
rr�s&


�zJVMFinder.get_jvm_pathcCsJt�d�}|rFtj�|�rFtj�|�}tj�|�s<t�d�}|�|�SdS)z�
        Retrieves the Java library path according to the JAVA_HOME environment
        variable

        Returns:
            The path to the JVM library, or None
        Z	JAVA_HOMEN)r#�getenvr%r0r3r.)r r)r
r
rr�s	

zJVMFinder._get_from_java_homecCs0|�|j�D]}|�|�}|dur|SqdS)z�
        Retrieves the first existing Java library path in the predefined known
        locations

        Returns:
            The path to the JVM library, or None
        N)r:rr.)r �homer<r
r
rr�s
z#JVMFinder._get_from_known_locationsN)rrrr	r!r.r:r=rrrr
r
r
rrMs%#&rc@s eZdZdZdd�Zdd�ZdS)rz(
    Linux JVM library finder class
    cCs2t�|�d|_d|_d|_|j|j|jf|_dS)rz
/usr/bin/javar)rrz/opt/sunN)	rr!�_javarrr�
_get_from_binrrrr
r
rr!s
�zLinuxJVMFinder.__init__cCsFtj�|j�}tj�|�rBtj�tj�tj�|�d��}|�|�SdS)z�
        Retrieves the Java library path according to the real installation of
        the java executable

        :return: The path to the JVM library, or None
        z..N)	r#r%r3rCr0�abspathr'�dirnamer.)r Zjava_binr)r
r
rrDs�zLinuxJVMFinder._get_from_binN)rrrr	r!rDr
r
r
rr�src@s eZdZdZdd�Zdd�ZdS)rz+
    Mac OS X JVM library finder class
    cCs4t�|�d|_t|j�|_|j�|j�d|_dS)rzlibjli.dylib)z!/Library/Java/JavaVirtualMachinesN)rr!r�listrr7�_javahome_binaryrrr
r
rr!,s

zDarwinJVMFinder.__init__cCs`ddl}ddl}ddlm}||��ddd��}||d�kr\||d�kr\|�dg���SdS)z�
        for osx > 10.5 we have the nice util /usr/libexec/java_home available. Invoke it and
        return its output. It seems this tool has been removed in osx 10.9.
        rN)�
StrictVersion�z10.6z10.9z/usr/libexec/java_home)r�
subprocess�distutils.versionrI�mac_ver�check_output�strip)r rrKrI�currentr
r
rrH<s�z DarwinJVMFinder._javahome_binaryN)rrrr	r!rHr
r
r
rr'srcCs�ddl}d}d}d}|dk}t|d��v}|�d�}|dkrBtd	��|�d
�|�d�}|�d|�d}	|�|	d�|�d�}|�d
|�d}
Wd�n1s�0Y|
|kr�|r�td��n&|
|ks�|
|kr�|s�td��ntd��dS)NriLiid�l�rb�sMZz
JVM not valid�<rJz<Lz<Hz1JVM mismatch, python is 64 bit and JVM is 32 bit.z1JVM mismatch, python is 32 bit and JVM is 64 bit.zUnable to determine JVM Type)�struct�open�readr�seek�unpack)ZjvmPath�maxsizerTZIMAGE_FILE_MACHINE_I386ZIMAGE_FILE_MACHINE_IA64ZIMAGE_FILE_MACHINE_AMD64Zis64�f�s�
header_offset�machiner
r
r�
_checkJVMArchKs4



.��r^z*SOFTWARE\JavaSoft\Java Runtime EnvironmentzSOFTWARE\JavaSoft\JREc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz*
    Windows JVM library finder class
    cCs"t�|�d|_|j|jf|_dS)rzjvm.dllN)rr!rr�_get_from_registryrrr
r
rr!ss
zWindowsJVMFinder.__init__cCst|�dS)N)r^r;r
r
rr=�szWindowsJVMFinder.checkc	Cs�tsdStD]p}zXt�tj|�}t�|d�}t�||d�}t�|�t�|d�}t�|�|dWStyzYq0qdS)z�
        Retrieves the path to the default Java installation stored in the
        Windows registry

        :return: The path found in the registry, or None
        NZCurrentVersionrZ
RuntimeLib)�winreg�reg_keys�OpenKey�HKEY_LOCAL_MACHINE�QueryValueExZCloseKey�OSError)r �locationZjreKeyZcvZ
versionKeyr
r
rr_�s

z#WindowsJVMFinder._get_from_registryN)rrrr	r!r=r_r
r
r
rrns
r)r#r�__all__r`�ImportError�
ValueErrorrrr�objectrrrrYr^rarr
r
r
r�<module>s$
/,$�