%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/clwizard/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clwizard/__pycache__/utils.cpython-37.pyc

B

�2Lb7�@s�ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddl
Z
edd	d
��Zdd�Zd
d�Zdd�Zdd�Zdd�ZdS)�)�absolute_importN)�contextmanager)�Iterable�)�CRASH_LOG_PATH)�PackageMissingErrorTccs~|d}zFt|d��&}|V|r6|��t�|���WdQRXt�||�Wdyt�|�Wnttfk
rvYnXXdS)z� Writeable file object that atomically updates a file (using a temporary file).

    :param filepath: the file path to be opened
    :param fsync: whether to force write the file to disk
    z.tmp�wN)	�open�flush�os�fsync�fileno�rename�remove�IOError�OSError)�filepathrZtmppath�f�r�?/opt/alt/python37/lib/python3.7/site-packages/clwizard/utils.py�atomic_writesrc	CsTdd�}xFt��D]:}yt|���}Wntjk
r>wYnX||�rdSqWdS)zQ
    Detects if the process installing modules is running in the background.
    cSs$dddht|�kp"dddht|�kS)Nz/usr/sbin/cloudlinux-wizardZinstallz
--no-asyncz/sbin/cloudlinux-wizard)�set)�cmdlinerrr�_is_wizard_cmdline2sz9is_background_process_running.<locals>._is_wizard_cmdlineTF)�psutilZprocess_iter�listrZ
NoSuchProcess)r�procrrrr�is_background_process_running-srcCs(ttjd�}ttd�}tj||||d�S)Nr)�stdin�stdout�stderr)r	r�devnullr�
subprocess�Popen)�cmdZfnullZ	log_crashrrr�run_backgroundGs
r%cCs6yddlm}Wntk
r,td��YnX||�S)Nr)�"interpreter_versions_short_summaryZ
lvemanager)Zclselect.clselectctlr&�ImportErrorr)Zinterpreterr&rrr�installed_interpreters_listRs
r(cCsd�|�d�d|��S)z�
    Format version string
    e.g:
    3.6.0 -> 3.6 if version size = 2
    9.11.3 -> 9 if version size = 1
    :param version given version to convert
    :param version_size expected size of result version string
    �.N)�join�split)�versionZversion_sizerrr�convert_package_versionZs	r-cCsTt�|�}|�tj�yt�|�}Wntk
r8YnXt�d�|_|�|�|S)z3
    Logger setup for all modules
    :return:
    z*[%(levelname)s | %(asctime)s]: %(message)s)	�loggingZ	getLoggerZsetLevel�INFOZFileHandlerrZ	FormatterZ	formatterZ
addHandler)Zlogger_nameZlog_fileZ
app_loggerZfhrrr�setup_loggerfs

r0)T)Z
__future__rrr"r.�
contextlibr�typingrZ	constantsr�
exceptionsrrrrr%r(r-r0rrrr�<module>s

Zerion Mini Shell 1.0