%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/utils.cpython-310.pyc

o

K��^��@sFddlZddlZddlZddlZddlZddlZddlmZe�d�Z	dd�Z
dd�Zdejejdd	dd
�dee
dejfd
d�Zejejddd	ddd�dee
dejfdd�Zejejejdd�dee
dejjfdd�Zdee
de
dee
fdd�Zejejejdd	dd�dee
dejfdd�Zd#dd�Zdd �Zd!d"�ZdS)$�N)�Listzsubiquitycore.utilscCs(|dur
tj��}n|��}d|d<|S)N�C�LC_ALL)�os�environ�copy)�env�r	�+/usr/share/subiquity/subiquitycore/utils.py�
_clean_envs
rcCsb|durtj}|��}|��D]\}}|�d�r.|dtd��}|r(|||<n||=||=q|S)N�_ORIG)rrr�items�endswith�len)r�ret�key�val�key_to_restorer	r	r
�orig_environ%s

�rzutf-8�replace)�input�stdout�stderr�encoding�errorsr�cmd�returnc

Ks�|dur
tj|d<n|�|�}t�d|�z.tj|f|||t|�d�|��}|rBt|jt	�r5|j�
|�|_t|jt	�rB|j�
|�|_WntjyY}	z	t�dt
|	���d}	~	wwt�d|j|j�|S)z�A wrapper around subprocess.run with logging and different defaults.

    We never ever want a subprocess to inherit our file descriptors!
    N�stdinzrun_command called: %s)rrrrzrun_command %sz"run_command %s exited with code %s)�
subprocess�DEVNULL�encode�log�debug�runr�
isinstancer�bytes�decoder�CalledProcessError�str�args�
returncode)
rrrrrrr�kw�cp�er	r	r
�run_command4s.
�����r.F)rrrrrr�checkc
�s��|durd|vrtj|d<n
tj|d<|�|�}t�d|�tj|||t|�d�|��IdH}	|	j	|d�IdH\}}|rO|durF|�
|�}|durO|�
|�}t�d||	j�|re|	jdkret�|	j|��t�
||	j||�S)Nrzarun_command called: %s�rrr)rz#arun_command %s exited with code %sr)rr�PIPEr r!r"�asyncio�create_subprocess_execr�communicater&r*r'�CompletedProcess)
rrrrrrrr/r+�procr	r	r
�arun_commandPs2�
�

��


�r7)rrrrc�s0�t�d|�tj|||t|�d�|��IdHS)Nzastart_command called: %sr0)r!r"r2r3r)rrrrrr+r	r	r
�astart_commandls���r8�split_onc�s �t|dd�IdH}|j�|�S)NT)r/)r7r�split)rr9r,r	r	r
�split_cmd_outputus�r;)rrrrrrcKs,t�d|�tj|f|||t|�d�|��S)z�A wrapper around subprocess.Popen with logging and different defaults.

    We never ever want a subprocess to inherit our file descriptors!
    zstart_command called: %s)rrrr)r!r"r�Popenr)rrrrrrrr+r	r	r
�
start_commandzs��r=�SHA-512csdddddd�}||vrtd�|d�|������d�d	}d��fd
d�|D��}t�||||�S)Nz$6$z$5$z$1$�)r>zSHA-256�MD5�DESz&Invalid algo({}), must be one of: {}. �,z@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./z                csg|]}t����qSr	)�random�choice)�.0�c��salt_setr	r
�
<listcomp>�sz"crypt_password.<locals>.<listcomp>)�	Exception�format�join�keys�crypt)�passwd�algo�algos�saltr	rGr
�crypt_password�s�rScCst�d�tgd��dS)z> Stop console-conf service; which also restores getty service zdisabling console-conf service)�	systemctl�stop�
--no-blockzconsole-conf@*.servicezserial-console-conf@*.serviceN�r!�infor.r	r	r	r
�disable_console_conf�s
rYcCs>t�d�tgd��tddg�tgd��tgd��dS)z; Stop subiquity service; which also restores getty service zdisabling subiquity service)�mkdirz-pz/run/subiquity�touchz/run/subiquity/complete)rT�startrVzgetty@tty1.service)rTrUrVz(snap.subiquity.subiquity-service.servicezserial-subiquity@*.serviceNrWr	r	r	r
�disable_subiquity�s
r])r>)r2rN�loggingrrCr�typingr�	getLoggerr!rrr1r(r5r.r7r�Processr8r;r<r=rSrYr]r	r	r	r
�<module>sL
�
��
��
�	�
�


Zerion Mini Shell 1.0