File: //opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/utils.cpython-311.pyc
�
���h�� �
�� � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl
Z
d dl mZmZ d dl
mZ d dlmZmZmZmZmZmZ d dlZd dlZd dlmZ d dlmZmZmZmZ dZdZ d Z!d
Z"dZ#d� Z$dRd
�Z%d� Z&d� Z'd� Z(d� Z) dSd�Z*d� Z+dee, fd�Z-d� Z.de/fd�Z0de,dz fd�Z1de,dz fd�Z2edee, fd�� � Z3de4fd�Z5de,de/fd �Z6de/fd!�Z7de/fd"�Z8de/fd#�Z9d$� Z:d%e,de/fd&�Z;d'� Z<d(� Z=d)� Z>d*� Z?d+� Z@d,e,de/fd-�ZAd.e4de/fd/�ZBd0edee/ fd1�ZCde4fd2�ZDd3e,dee/e/f fd4�ZEd3e,dee/e/f fd5�ZFd3e,dee/e/f fd6�ZGd7e,d8e/de/fd9�ZHd:eej ejI f de,fd;�ZJ dRd<e,d=e,d>e,d?e4dee4e,f f
d@�ZKde,fdA�ZLde/fdB�ZMdCe,dee4 fdD�ZNdCe,fdE�ZOdCe,fdF�ZPdG� ZQdHe,de,fdI�ZRde/fdJ�ZSdKe,de,fdL�ZTdeUe,dz e,dz f fdM�ZVde/fdN�ZWde/fdO�ZXdP� ZYdQ� ZZdS )T� N)�ConfigParser�Error)�cache)�Any�AnyStr�Dict�Optional�Tuple�Union)�etree)�ExternalProgramFailed�
check_command�exec_utility�run_commandz/etc/sysconfig/rhn/systemid)�Mon�Tue�Wed�Thu�Fri�Sat�Sunz /opt/cloudlinux/litespeed_statusz/opt/cloudlinux/nginx_statusz/opt/apache2nginx/statec � � d}t j � |� � r& t j |� � }n# t $ r Y nw xY w| |k r= t j |� � n# t $ r Y nw xY wt j | |� � dS dS )a
Create symlink link_path -> link_value if it does not exist or
points to different location
:param link_value: path that symlink should point to (symlink value)
:type link_value: str
:param link_path: path where to create symlink
:type link_path: str
N)�os�path�islink�readlink�OSError�unlink�symlink)�
link_value� link_path�link_tos ��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.30-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/utils.py�create_symlinkr$ 1 s� � � �G� �w�~�~�i� � � � ��k�)�,�,�G�G��� � � ��D� �����W��� ��I�i� � � � ��� � � ��D� ����
�
�:�y�)�)�)�)�)� �s! �8 �
A�A�A$ �$
A1�0A1c �� � g }t j � | � � r>t | d|�� � 5 }|� � � }ddd� � n# 1 swxY w Y |S )a
Read file and return file's lines
errors param may be passed to define how handle
unicode errors, errors=None is default value of open()
:param path: path to file
:param unicode_errors_handle: how to handle unicode errors
:return: list of file's lines
�utf-8)�encoding�errorsN)r r �isfile�open� readlines)r �unicode_errors_handle�content�fs r# �get_file_linesr/ H s� � � �G� �w�~�~�d��� $�
�$��1F�
G�
G�
G� $�1��k�k�m�m�G� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $��Ns �A�A�Ac � � t | |d�� � 5 }|� |� � ddd� � dS # 1 swxY w Y dS )z�
Write lines to file
:param content: list of lines for writing to file
:param path: path to file
:param mode: open mode
:return: None
r&