MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/mysqlsh/python-packages/mysqlsh/plugin_manager/__pycache__/general.cpython-39.pyc
a

��kf��@szddlZddlZddlZddlZddlZddlZddlZddlm	Z	dZ
dZdd�Zdd�Z
d	d
�Zddd
�Zdd�ZdS)�N��Pathz0.0.1�
cGs�dtjvrtjd}nHt��}|s*td��t��}|dkrPtj�|dddd�}ntj�|d�}zt|�j	d	d
�Wnt
y�Yn0|D]}tj�||�}q�|S)z�Returns the MySQL Shell's user directory

    The directory will be created if it does not exist yet

    Args:
        *argv: The list of directories to be added to the path

    Returns:
        The plugin directory path as string
    ZMYSQLSH_USER_CONFIG_HOMEzNo home directory setZWindowsZAppDataZRoamingZMySQL�mysqlshz.mysqlshT��parents)�os�environr�home�	Exception�platform�system�path�join�mkdir�FileExistsError)�argvZ	shell_dirZhome_dir�os_name�arg�r�B/usr/lib/mysqlsh/python-packages/mysqlsh/plugin_manager/general.py�get_shell_user_dir(s$

�rcGsLtd�}zt|�jdd�Wnty.Yn0|D]}tj�||�}q4|S)z�Returns the MySQL Shell's temp directory

    The directory will be created if it does not exist yet

    Args:
        *argv: The list of directories to be added to the path

    Returns:
        The temp directory path as string
    ZtempTr)rrrrrrr)rZtemp_dirrrrr�get_shell_temp_dirMsrcGs`ddlm}ddl}td�}z||�jdd�WntyBYn0|D]}|j�||�}qH|S)z�Returns the MySQL Shell's plugin directory

    The directory will be created if it does not exist yet

    Args:
        *argv: The list of directories to be added to the path

    Returns:
        The plugin directory path as string
    rrNZpluginsTr)�pathlibrZos.pathrrrrr)rrrZplugins_dirrrrr�get_plugins_dirfsrFc
Cs�z�t��}|dur4|dkr4t||dtjdd�d�WStjj|t|d��}|�	�}Wd�n1sd0Y|s~|�
d�WSt|d	��}|�|�Wd�n1s�0YWdSWn�tj
j�y}zF|rւ|jd
k�rtd|�dt|����WYd}~dS�WYd}~n�d}~0tj
j�y�}ztt|j�}	d
|	v�rz|du�rzt�}
t|||tj|
d�d�WYd}~Std|�dt|����|�r��WYd}~n
d}~00dS)ajDownloads a file from a given URL

    Args:
        url (str): The URL to the text file to download
        file_path (str): The file to store the downloaded file
        raise_exceptions (bool):  Whether exceptions are raised

    Returns:
        The contents of the file decoded to utf-8 if no file is given or True
        on success or None on failure
    NZDarwinTz/private/etc/ssl/cert.pem)�cafile)�	file_path�raise_exceptions�ctx)Ztimeout�contextzutf-8�wbi�zCould not download file from z
ERROR: ZCERTIFICATE_VERIFY_FAILED)rr
�
download_file�sslZcreate_default_context�urllibZrequestZurlopen�URL_OPEN_TIMEOUT_SECONDS�read�decode�open�write�errorZ	HTTPError�code�print�strZURLError�reason�install_ssl_certificates)ZurlrrrrZresponse�dataZout_file�er-rrrrr!�sF
�&(


�r!cCs�tjtjBtjBtjBtjBtjBtjBtjB}t	j
�t�d�}t
d�t	j
�t���}t
d�zt	�|�Wnty�Yn0t
d�t	�||�t
d�t	�||�t
d�|S)Nzcertifi-ca.pemzInstalling SSL certificate...z& -- removing any existing file or linkz2 -- creating symlink to certifi certificate bundlez -- setting permissionsz -- update complete)�stat�S_IRUSR�S_IWUSR�S_IXUSR�S_IRGRP�S_IWGRP�S_IXGRP�S_IROTH�S_IXOTHrrrrr+�relpath�certifi�where�remove�FileNotFoundError�symlink�chmod)Z
STAT_0o775Zshell_cafileZrelpath_to_certifi_cafilerrrr.�s<��������r.)NFN)r;rrZurllib.errorr#Zurllib.requestr1r"rr�VERSIONr$rrrr!r.rrrr�<module>s%
: