HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clveconfig/__pycache__/ve_config.cpython-37.pyc
B

�~�O���@s�ddlmZddlZddlmZddlmZddlm	Z	ddl
mZmZej
�ed�Zed	Zd
aGdd�de�Zddd�Zdd�Zdd�ZdS)�)�absolute_importN)�minidom)�
ExpatError)�etree�)�
CONFIG_DIR�acquire_lockzve.cfgz.tmp)NNcseZdZd�fdd�	Z�ZS)�BadVeConfigException�Nothingcstt|��d|�dS)Nz8Unable to parse /etc/container/ve.cfg file, message: %s )�superr	�__init__)�self�message)�	__class__��py/clveconfig/ve_config.pyrs
zBadVeConfigException.__init__)r
)�__name__�
__module__�__qualname__r�
__classcell__rr)rrr	sr	TcCs|tdkr|rtSt��\yt�t�}|�d�d}Wn$tttt	fk
rXt
d��YnX|rf||fa||fSWdQRXdS)z�
    Load xml config from ve.cfg
    1. setup lock on file
    2. read info
    3. remove lock
    :type use_cache: bool
    :rtype: tuple[xml.Document, xml.Element]
    :raises: BadVeConfigException, LockFailedException
    )NN�	lveconfigrzbad ve.cfg fileN)�PARSED_XML_CACHEr�xml�parse�VE_CFG_PATH�getElementsByTagName�OSError�IOErrorr�
IndexErrorr	)Z	use_cacheZ_ve_cfg�
_ve_lveconfigrrr�get_xml_configs
r cCsZt��Jyt�t�}|��Stjk
rJ}ztt|���Wdd}~XYnXWdQRXdS)z�
    This method works same as get_xml_config,
    but returns etree object
    :rtype: etree.ElementTree
    :raises: BadVeConfigException, LockFailedException
    N)rrrrZgetrootZ
ParseErrorr	�str)Ztree�errr�get_xml_config_etree;s
r#c	Cs�|�d�d}||fa|jdddd�}|�dd��dd�}t�|�}|jdd	�}|s`td
t��tt	d��&}|�
|�|��t�
|���WdQRXt�t	t�dS)Nrrzutf-8�)�encoding�indentZnewl�
��	)r%z"Rejected attempt to write empty %s�wb)rrZtoprettyxml�replacerZparseString�	Exceptionr�open�VE_CFG_PATH_TMP�write�flush�os�fsync�fileno�rename)Zxml_documentrZ
xml_stringZnew_xmlZbuf�frrr�save_xmlKs

r6)T)Z
__future__rr1Zxml.domrrZxml.parsers.expatrZlxmlrZve_lockrr�path�joinrr.rr,r	r r#r6rrrr�<module>s