|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /opt/alt/python37/lib/python3.7/site-packages/clwpos/user/__pycache__/ |
Upload File : |
B
A�co% � @ s� d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl m
Z
d dlmZ d dl
mZmZmZ d dlmZ d dlmZ d d lmZ d d
lmZ G dd� de�ZG d
d� de�ZdS )� )�absolute_importN)�Iterable�Optional)�ALL_OPTIMIZATION_MODULES)�
setup_logging)�get_relative_docroot�create_clwpos_dir_if_not_exists�is_run_under_user)�
is_wp_path)� constants)� WposError)�gettextc @ s e Zd ZdZdS )�ConfigErrorz^
Used for all exceptions during handling clwpos user config
in UserConfig methods
N)�__name__�
__module__�__qualname__�__doc__� r r �C/opt/alt/python37/lib/python3.7/site-packages/clwpos/user/config.pyr s r c @ s� e Zd ZdZej�dejej �Z
ej� d�Zi ed�Zdd� Z
dd� Zed �d
d�Zdd
� Zdd� Zed�dd�Zd#eeeee ed�dd�Zeeedd�dd�Zeeedd�dd�Zdd� Zeee d�dd �Zd!d"� ZdS )$�
UserConfigzQ
Class to manage clwpos user config - read, write, set params in config.
z {homedir}Zmb)�docrootsZmax_cache_memoryc C sN t � sttd���|| _t�|�j| _| jj | jd�| _
tt�| _
t|� d S )Nz&Trying to use UserConfig class as root)�homedir)r r �_�username�pwd�getpwnam�pw_dirr �CONFIG_PATH�format�config_pathr r �_loggerr )�selfr r r r �__init__- s
zUserConfig.__init__c C s` y&t | jd��}t�|�� �S Q R X W n4 tk
rZ t�� }tt d�| j|d�d��Y nX dS )z4
Reads config from self.config_path
�rNz@Error while reading config %(config_path)s: %(exception_string)s)r Zexception_string)�message�context)
�openr �json�loads�read� Exception� traceback�
format_excr r )r! �fZ
exc_stringr r r �read_config7 s zUserConfig.read_config)�configc
C sr y6t j|ddd�}t| jd��}|�|� W dQ R X W n6 tk
rl } zttd�d|id��W dd}~X Y nX dS ) z=
Writes config (as json) to self.config_path
� T)�indentZ sort_keys�wNzDAttempt of writing to config file failed due to error:
%(exception)s� exception)r$ r% )r'