HOME


Mini Shell 1.0
DIR: /snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Current File : //snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/utils.cpython-38.pyc
U

K��^��@s�ddlZddlZddlZddlZddlZddlZe�d�Zdd�Zdej	ej	dddd�dd	�Z
ej	ej	ddddd
d�dd
�Zej	ej	ejdd�dd�Z
ejej	ej	dddd�dd�Zddd�Zdd�Zdd�ZdS)�Nzsubiquitycore.utilscCs(|dkrtj��}n|��}d|d<|S)N�C�LC_ALL)�os�environ�copy)�env�r�+/usr/share/subiquity/subiquitycore/utils.py�
_clean_envs
r
zutf-8�replace)�input�stdout�stderr�encoding�errorsrc

Ks�|dkrtj|d<n
|�|�}t�d|�z\tj|f|||t|�d�|��}|r�t|jt	�rj|j�
|�|_t|jt	�r�|j�
|�|_Wn6tjk
r�}	zt�dt
|	���W5d}	~	XYnXt�d|j|j�|SdS)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)rr
rrzrun_command %sz"run_command %s exited with code %s)�
subprocess�DEVNULL�encode�log�debug�runr
�
isinstancer
�bytes�decoder�CalledProcessError�str�args�
returncode)
�cmdrr
rrrr�kwZcp�errr	�run_command$s(
��r"F)r
rrrrr�checkc
�s�|dkrd|kr0tj|d<ntj|d<|�|�}t�d|�tj|||t|�d�|��IdH}	|	j	|d�IdH\}}|r�|dk	r�|�
|�}|dk	r�|�
|�}t�d||	j�|r�|	jdkr�t�|	j|��nt�
||	j||�SdS)Nrzarun_command called: %s�r
rr)rz#arun_command %s exited with code %sr)rr�PIPErrr�asyncio�create_subprocess_execr
ZcommunicaterrrZCompletedProcess)
rr
rrrrrr#r �procrrr	�arun_command@s:

��

�r))r
rrrc�s.t�d|�tj|||t|�d�|��IdHS)Nzastart_command called: %sr$)rrr&r'r
)rr
rrrr rrr	�astart_commandZs��r*)rr
rrrrcKs,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)rr
rr)rrr�Popenr
)rrr
rrrrr rrr	�
start_commandcs��r,�SHA-512csdddddd�}||kr0td�|d�|������d�d	}d��fd
d�|D��}t�||||�S)Nz$6$z$5$z$1$�)r-zSHA-256ZMD5ZDESz&Invalid algo({}), must be one of: {}. �,z@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./z                csg|]}t����qSr)�randomZchoice)�.0�c�Zsalt_setrr	�
<listcomp>{sz"crypt_password.<locals>.<listcomp>)�	Exception�format�join�keys�crypt)ZpasswdZalgoZalgosZsaltrr3r	�crypt_passwordps�r:cCs t�d�tdddddg�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"rrrr	�disable_console_confs


�r@cCsJt�d�tdddg�tddg�tddd	d
g�tddd	dd
g�dS)z; Stop subiquity service; which also restores getty service zdisabling subiquity service�mkdirz-pz/run/subiquityZtouchz/run/subiquity/completer;�startr=zgetty@tty1.servicer<z(snap.subiquity.subiquity-service.servicezserial-subiquity@*.serviceNr>rrrr	�disable_subiquity�s
�rC)r-)r&r9Zloggingrr0rZ	getLoggerrr
r%r"r)rr*r,r:r@rCrrrr	�<module>sD
���	�