Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceWSL.cpython-310.pyc
o

}��f%/�	@s�dZddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
mZddlZddl
mZmZmZddlmZddlmZe�e�ZdZd	Zd
ZdZdefd
d�Zdeefdd�Zdefdd�Zdefdd�Z dedeefdd�Z!deefdd�Z"dedee
e#e$ffdd�Z%deedede#fdd�Z&dede	e
e#e$dfe
e#e$dfffd d!�Z'Gd"d#�d#ej(�Z)e)ej*ffgZ+d$d%�Z,dS)&z?Datasource to support the Windows Subsystem for Linux platform.�N)�PurePath)�Any�List�Optional�Tuple�Union�cast)�sources�subp�util)�Distro)�Pathsz/usr/bin/wslpathziid-datasource-wsl�%s.user-dataz
agent.yaml�returncCs"t�tddg�\}}t|���jS)zL
    Returns the name of the current WSL instance as seen from outside.
    z-am�/)r
�WSLPATH_CMDr�rstrip�name)�
root_net_path�_�r�A/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceWSL.py�
instance_names	rcCsHd}d}g}t����D]}|d|kr!||dvr!|�|d�q|S)z�
    Return a list of mount points of the Windows drives inside the current
    WSL instance, if drives are mounted, or an empty list otherwise
    �9pzaname=drvfs�fstype�opts�
mountpoint)r�mounts�values�append)�FS_TYPE�OPTIONS_CONTAIN�mounted�mntrrr�mounted_win_drives*s�r$cCs`t�}|s	td��d}|D]}||}t�|tj�sq
t�d|�t|�Stdd�|���)z?
    Returns the Linux path to the Windows host's cmd.exe.
    zWindows drives are not mounted.z%s/Windows/System32/cmd.exezFound cmd.exe at <%s>z,Couldn't find cmd.exe in any mount point: %sz, )	r$�IOError�os�access�X_OK�LOG�debugr�join)r�	candidater#�cmdrrr�cmd_executable:s�r.cCsVt�}t�d|��ddg�\}}|��}|st�d��t�td|g�\}}t|���S)z�
    Finds the user's home directory path as a WSL path.

    raises: IOError when no mountpoint with cmd.exe is found
               ProcessExecutionError when either cmd.exe is unable to retrieve
               the user's home directory
    z/initz/Czecho %USERPROFILE%z4No output from cmd.exe to show the user profile dir.z-au)r.r
�as_posixr�ProcessExecutionErrorrr)r-�homer�outrrr�	find_homeRs�	r3�	user_homecCs2tj�|d�}tj�|�st�d|�dSt|�S)z�
    Returns the Windows user profile .cloud-init directory translated as a
    Linux path accessible inside the current WSL instance, or None if not
    found.
    z.cloud-initz*cloud-init user data dir %s doesn't exist.N)r&�pathr+�isdirr)r*r)r4�seed_dirrrr�cloud_init_data_dirps
r8cCs6t��\}}}|r|n|}d|d||fd|dgS)z
    Return a list of candidate file names that may contain user-data
    in some supported format, ordered by precedence.
    rz%s-%s.user-dataz%s-all.user-datazdefault.user-data)r�get_linux_distro)r�distribution_id�
version_id�version_codename�versionrrr�candidate_user_data_file_names~s
�r>�	data_pathcCsJzt�|�}t�|�}|dur|WS|WSty$t�d|�YdSw)z�
    Tries to load a YAML file as a dict, otherwise returns the file's raw
    binary contents as `bytes`. Returns `None` if no file is found.
    NzNo data found at %s, ignoring.)r�load_binary_file�	load_yaml�FileNotFoundErrorr)r*)r?�bin_data�	dict_datarrr�load_yaml_or_bin�s

�rE�cloudinitdircCs�dti}|dur
|Stj�|��d|�}z
t�t�|��}Wnty.t	�
d|�Ynw|r5d|vrFd|�d|��}t	�|�t|��|S)z`
    Returns the relevant metadata loaded from cloudinit dir based on the
    instance name
    �instance-idNz%s.meta-dataz<No instance metadata found at %s. Using default instance-id.z
 Metadata at z5 does not contain instance-id key. Instead received: )
�DEFAULT_INSTANCE_IDr&r5r+r/rrAr@rBr)r*�error�
ValueError)rFr�metadata�
metadata_path�msgrrr�load_instance_metadata�s,�����
rNcCsPtj�|d�}tj�|�sdSttj�|tt���}ttj�|t��}||fS)zg
    Read .ubuntupro user-data if present and return a tuple of agent and
    landscape user-data.
    z.ubuntupro/.cloud-init)NN)r&r5r+r6rE�LANDSCAPE_DATA_FILEr�AGENT_DATA_FILE)r4�pro_dir�landscape_data�
agent_datarrr�load_ubuntu_pro_data�s�rTcsZeZdZdZddedef�fdd�
Zdedefd	d
�Zde	fdd�Z
de	fd
d�Z�ZS)�
DataSourceWSL�WSLN�distro�pathscst��||||�d|_dS)N�)�super�__init__r)�self�sys_cfgrWrX�ud_proc��	__class__rrr[�s
zDataSourceWSL.__init__r7rcCsjdd�t�|�D�}|std|��dd�t|j�D�}|D]}||��vr.t||�Sqtd|��)z�
        Finds the most precendent of the candidate files that may contain
        user-data, if any, or None otherwise.
        cSsi|]	}|j��|j�qSr)r�casefoldr5)�.0�efrrr�
<dictcomp>�s�z5DataSourceWSL.find_user_data_file.<locals>.<dictcomp>z%s directory is emptycSsg|]}|���qSr)ra)rb�frrr�
<listcomp>�s��z5DataSourceWSL.find_user_data_file.<locals>.<listcomp>z6%s doesn't contain any of the expected user-data files)r&�scandirr%r>r�keysr)r\r7�existing_files�folded_names�filenamerrr�find_user_data_file�s����z!DataSourceWSL.find_user_data_filec
Csr|��}|sdSztt��}t|t��}||�d�kWSttfy8}zt�	dt
|��WYd}~dSd}~ww)NFrGz2Unable to check_instance_id from metadata file: %s)�get_instance_idr8r3rNr�getr%rJr)�warning�str)r\r]�current�data_dirrK�errrrr�check_instance_id�s
���zDataSourceWSL.check_instance_idc
Cs�t�t�s
t�dt�dSt�|_zt�}Wnty/}z
t�d|�WYd}~dSd}~wwt|�}d}d}z	t	||j�|_
Wnttfy^}zt�dt
|��WYd}~dSd}~ww|jjdkrkt|�\}}z|dur|dur|�|�}t|���}Wnttfy�}zt�d|t
|��WYd}~nd}~wwt||g�s�dSt|t�s�t|t�r�tt||g�|_dSi}g}	|r�|}|r�|r�t�d�|D]}
|
|vr�|	�|
�||
||
<q�|	r�t�d	�|	��d
t�|�|_dS)Nz5No WSL command %s found. Cannot detect WSL datasourceFz#Unable to detect WSL datasource: %szUnable to load metadata: %s�ubuntuz+Unable to load any user-data file in %s: %sTz.Merging both user_data and agent.yaml configs.z% agent.yaml overrides config keys: , z#cloud-config
%s)r
�whichrr)r*rr3r%r8rNrKrJrIrprWrrTrlrEr/�any�
isinstance�bytesrr�userdata_rawrr+�yaml�dump)r\r4�er7rS�	user_datars�file�merged�overridden_keys�keyrrr�	_get_datas�
�
��
���
����

�zDataSourceWSL._get_data�N)
�__name__�
__module__�__qualname__�dsnamerr
r[rrl�boolrtr��
__classcell__rrr_rrU�srUcCst�|t�Sr�)r	�list_from_depends�datasources)�dependsrrr�get_datasource_listhsr�)-�__doc__�loggingr&�typing�pathlibrrrrrrrr{�	cloudinitr	r
r�cloudinit.distrosr�cloudinit.helpersr
�	getLoggerr�r)rrHrOrPrprr$r.r3r8r>�dictryrErNrT�
DataSourcerU�DEP_FILESYSTEMr�r�rrrr�<module>sN 

��
�!�
�

�

Spamworldpro Mini