HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/rhsmlib/dbus/objects/__pycache__/config.cpython-39.pyc
a

X�Zh{(�@s�ddlmZmZddlZddlZddlmZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlmZddlmZddlmZdd	lmZer�dd
lmZe�e�ZGdd�de
j�ZGd
d�de
j�ZdS)�)�
TYPE_CHECKING�UnionN)�ini)�Locale)�	constants�base_object�util�
dbus_utils)�Config)�CONFIG_WATCHER)�Server)�
DBusException)�RhsmConfigParserc@sjeZdZdd�dd�Zeedd�dd�Zedd	�d
d�Zed�d
d�Zee	eefd�dd�Z
dd�ZdS)�ConfigDBusImplementationr��parsercCst|�|_dS)N)r
�config)�selfr�r�A/usr/lib64/python3.9/site-packages/rhsmlib/dbus/objects/config.py�__init__'sz!ConfigDBusImplementation.__init__N)�section_and_key�value�returnc	
Cs�|�d�\}}}|std��||j||<|dk}t�th�|j��|r�tj��}t	|�|_ztj
�|�Wn4ty�}zt
�d|���WYd}~n
d}~00t�th�dS)z�Set one value.

        :param section_and_key: Specific configuration in 'section.key' format.
        :param value: New value.
        :raises DBusException: Only section has been specified.
        �.�JSetting an entire section is not supported. Use 'section.property' format.�logging�$Re-initialization of logger failed: N)�	partitionr
rr�temporary_disable_dir_watchersr�persist�rhsm�get_config_parserr
�logutil�init_logger�	Exception�log�warning�enable_dir_watchers)	rrr�section�_�key�logging_changedr�excrrr�set*s


&zConfigDBusImplementation.set)�
configurationrc

Cs�t�d|���d}|��D]>\}}|�d�\}}}|s@td��||j||<|dkrd}qt�th�|j�	�|r�t
j��}t|�|_zt
j
�|�Wn4ty�}	zt�d|	���WYd}	~	n
d}	~	00t�th�dS)	zpSet multiple values.

        :param configuration: Mapping of 'section.key' formats to their 'value's.
        z"Setting new configuration values: FrrrTrN)r&�debug�itemsrr
rrrrr r!r"r
r#r$r%r'r()
rr/r,rrr)r*r+rr-rrr�set_allOs*�


&z ConfigDBusImplementation.set_all)rcCs
t|j�S)zGet all values.)�dictr�rrrr�get_allxsz ConfigDBusImplementation.get_all)�section_maybe_keyrcCs4|�d�\}}}|r"|j||St|j|�SdS)z�Get configuration section or specific value.

        :param: Section or specific configuration in 'section.key' format.
        rN)rrr3)rr6r)r*r+rrr�get|szConfigDBusImplementation.getcCs�tj��}tjd|d�|_|��}t|�dkrrt�	dt
|��t|�|_tj�
|�t�	d|jt
|j�f�nt�d|j�dS)z�
        When some change of rhsm.conf is detected (via i-notify or periodical polling),
        it is reloaded so new values can be used.
        N)Zoptionxformsourcerzfiles read: %sz#Configuration file: %s reloaded: %sz%Unable to read configuration file: %s)r!rr"rZ	INIConfig�data�read�lenr&r0�strr
r#r$Zconfig_filer')rrZ
files_readrrr�reload�s

zConfigDBusImplementation.reload)�__name__�
__module__�__qualname__rr;r.r3r2r5rr7r<rrrrr&s%)rcs�eZdZejZejZddd��fdd�
Ze	j
ejdd�e	jdd	���Ze	j
ejd
d�e	je	jddd
����Ze	j
ejdd�e	je	jddd����Ze	j
ejddd�e	je	jddd����Ze	j
ejddd�e	je	jddd����Z�ZS)�ConfigDBusObjectNrrcs t�j|||d�t|�|_dS)N)�conn�object_path�bus_name)�superrr�impl)rrArBrCr��	__class__rrr�szConfigDBusObject.__init__��Z	signaturecCst�dtj�dS)z\
        Signal fired, when config is created/deleted/changed
        :return: None
        zD-Bus signal %s emittedN)r&r0r�CONFIG_INTERFACEr4rrr�
ConfigChanged�s
zConfigDBusObject.ConfigChangedZsvs)�in_signaturecCsFtj|td�}tj|td�}tj|td�}t�|�|j�||�dS)a�
        Method used for setting only one value. When more than one value is going to be set, then it is
        strongly recommended to use method SetAll(), because configuration is saved to the configuration
        file at the end of method Set()
        :param property_name: string with property e.g. server.hostname
        :param new_value: string with new value
        :param locale: string with locale
        :param sender: not used
        :return: None
        �Z
expected_typeN)r	�dbus_to_pythonr;rr.rE)r�
property_nameZ	new_value�locale�senderrrr�Set�s

zConfigDBusObject.Setza{sv}scCs6tj|td�}tj|td�}t�|�|j�|�dS)a�
        Method for setting multiple configuration options. Of course all of them could be set.
        :param configuration: d-bus dictionary with configuration. Keys have to include section. e.g.
                              server.hostname. Configuration file is saved to the file at the end of method.
        :param locale: string with locale
        :param sender: not used
        :return: None
        rMN)r	rNr3r;rr.rEr2)rr/rPrQrrr�SetAll�s
zConfigDBusObject.SetAll�sza{sv})rLZ
out_signaturecCsrtj|td�}t�|�tjidd�}|j���	�D]8\}}tjidd�||<|�	�D]\}}||||<qVq4|S)z�
        Method for getting whole configuration
        :param locale: string with locale
        :param sender: not used
        :return: D-bus dictionary with configuration
        rM�svrI�ss)
r	rNr;rr.�dbus�
DictionaryrEr5r1)rrPrQ�d�k�vZkkZvvrrr�GetAll�s
zConfigDBusObject.GetAllrVr[cCsBtj|td�}t�|�|j�|�}t|�tur>t	j
|dd�}|S)aa
        D-Bus method for getting one configuration property or one section
        :param property_name: string with name of property e.g. server.hostname or section e.g. server
        :param locale: string with locale
        :param sender: not used
        :return: string with value of property or dictionary with dictionary of one section
        rMrUrI)r	rNr;rr.rEr7�typer3rWrX)rrOrPrQ�resultrrr�Get�s
zConfigDBusObject.Get)NNNN)N)N)N)N)r=r>r?rZCONFIG_DBUS_PATHZdefault_dbus_pathrJZinterface_namerrZdbus_service_signalZdbus_handle_exceptionsrKZdbus_service_methodZdbus_handle_senderrRrSr\r_�
__classcell__rrrFrr@�sN�����r@) �typingrrrWrZiniparserr!Zrhsm.logutilZsubscription_manager.i18nrZrhsmlib.dbusrrrr	Zrhsmlib.services.configr
Zrhsmlib.file_monitorrZrhsmlib.dbus.serverrr
Zrhsm.configrZ	getLoggerr=r&ZBaseImplementationrZ
BaseObjectr@rrrr�<module>s 
x