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/rhsm/__pycache__/profile.cpython-39.pyc
a

X�Zh:?�@s�UddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddl
mZddlmZmZddlmZzddlZWney�dZYn0zddlZWney�dZYn0zddlZWney�dZYn0ej�d�duZeed<er�d	Znd
Ze�e�Z Gdd�de!�Z"Gd
d�d�Z#Gdd�d�Z$Gdd�d�Z%Gdd�d�Z&Gdd�d�Z'e(e	e'e$e#fd�dd�Z)e'e%e#d�Z*e+ed<dS)�N)�List�Union)�ourjson)�suppress_output)�SafeConfigParser�ConfigParser)�providerZzypp_plugin�
use_zypperz$/etc/rhsm/zypper.repos.d/redhat.repoz/etc/yum.repos.d/redhat.repoc@seZdZdZdS)�InvalidProfileTypezI
    Thrown when attempting to get a profile of an unsupported type.
    N)�__name__�
__module__�__qualname__�__doc__�rr�2/usr/lib64/python3.9/site-packages/rhsm/profile.pyr
2sr
c@s�eZdZdd�dd�Zed�dd�Zded�dd	�Zee	e	d
�dd��Z
ed
dd�dd��Zee
ed�dd��Ze
ed�dd�ZdS)�ModulesProfileN��returncCs|��|_dS�N)�_ModulesProfile__generate�content��selfrrr�__init__;szModulesProfile.__init__cCs
t|j�Sr��strrrrrr�__str__>szModulesProfile.__str__��otherrcCs|j|jkSr�r�rrrrr�__eq__AszModulesProfile.__eq__)�module_listrcCszi}|D]d}|d|d|d|d|df}||vr@|||<q||�dd�dur|�dd�dur|||<qt|���S)	z�
        Try to uniquify list of modules, when there are duplicated repositories
        :param module_list: list of modules
        :return: List of modules without duplicity
        �name�stream�version�context�arch�activeFT)�get�list�values)r"�ret�module�keyrrr�	_uniquifyDs"
$
zModulesProfile._uniquifyzdnf.Base)�basercCst��}|dus|jdkr(t�d�dSt�d�|��}|durPt�d�dSzt�|�}Wn tjy~t�	d�YdS0d|vr�t�d�dS|d}t�d	|���|�
|�D]`}t�d
|j���z|�||�Wq�t
�y}zt�dj|d��WYd}~q�d}~00q�dS)
z�
        Try to fix RHUI repos on AWS systems. When the system is running on AWS, then we have
        to fix repository URL. See: https://bugzilla.redhat.com/show_bug.cgi?id=1924126
        :param base: DNF base
        :return: None
        NZawszAThis system is not running on AWS. Skipping fixing of RHUI repos.z=This system is running on AWS. Trying to collect AWS metadatazCUnable to gather metadata from IMDS. Skipping fixing of RHUI repos.zMAWS provided corrupted json metadata document. Skipping fixing of RHUI repos.�regionzGRegion is not specified in AWS metadata. Skipping fixing of RHUI repos.z/Trying to fix URLs of RHUI repos using region: zTrying to fix repository: zUnable to fix RHUI URL: {error})�error)rZget_cloud_providerZCLOUD_PROVIDER_ID�log�debugZget_metadata�json�loadsZJSONDecodeError�warningZ
rhui_repos�idZfix_rhui_url_template�
ValueError�format)r0Zcloud_providerZmetadata_str�metadatar1Zrepor2rrr�fix_aws_rhui_reposXs2	




z!ModulesProfile.fix_aws_rhui_reposc

Cs�g}tdu�r�tdu�r�t��}|jj�|jj�|��|�|�zt	�
d�|��Wn>tjj
y�}z"t	�dt|��gWYd}~Sd}~00z
|j}Wn ty�t	�d�gYS0|��}|D]�}d}d}|�|��|����r�d}n|�|����rd}|�|����r"d}g}	|dk�rBt|�|����}	|�|��|��|��|��|��d	d
�|� �D�|	||d�	�q�t!�"|�S)Nz!Trying to fill dnf sack object...z Unable to create sack object: %sz+DNF does not provide modulemd functionality�defaultF�enabledZdisabledTcSsg|]}|���qSr)�getName)�.0�profilerrr�
<listcomp>��z-ModulesProfile.__generate.<locals>.<listcomp>)	r#r$r%r&r'Zprofiles�installed_profiles�statusr()#�dnf�libdnf�Base�conf�
substitutionsZupdate_from_etcZinstallrootZread_all_reposr<r3r4Z	fill_sack�
exceptionsZ	RepoErrorr2rZ_moduleContainer�AttributeErrorr7ZgetModulePackagesZ	isEnabledr?Z	getStreamZ
isDisabledZisModuleActiveZgetIdr*ZgetInstalledProfiles�appendZ
getVersionZ
getContextZgetArchZgetProfilesrr/)
rr"r0�err�modulesZall_module_listZ
module_pkgrEr(rDrrr�
__generate�sV





��zModulesProfile.__generatecCs|jS)zf
        Gather list of modules reported to candlepin server
        :return: List of modules
        rrrrr�collect�szModulesProfile.collect)rrr
rrr�boolr!�staticmethodr*r/r<rr�dictrrQrrrrr:s'9rc@s�eZdZeed�dd�Zedd�dd�Zed�dd	�Zeed
�dd�Z	ed�d
d�Z
eed�dd��Zed�dd�Z
ed�dd�ZdS)�EnabledReposrc
s�tj�|j�sgStrt��nt����|j��fdd����D�}g}|D]B}z$|�	||�
��|d��gd��WqNty�Yq�YqN0qN|S)Ncsg|]}��|d�r|�qS)r>)Z
getboolean)r@�section�ZconfigrrrB�rCz+EnabledRepos.__generate.<locals>.<listcomp>�baseurl)ZrepositoryidrX)
�os�path�exists�repofiler	rr�readZsectionsrM�_format_baseurlr)�ImportError)rZenabled_sections�
enabled_reposrVrrWrrP�s$��zEnabledRepos.__generateN��	repo_filercCs<tdurtj��|_ntdur(t��|_||_|��|_dS)zo
        Initialize EnabledRepos
        :param repo_file: A repo file path used to filter the report.
        N)	rFrH�db�yumZYumBase�ybr\�_EnabledRepos__generater�rrbrrrr�s
zEnabledRepos.__init__cCs
t|j�Srrrrrrr�szEnabledRepos.__str__)�repo_urlrcCs6tr|�|�S|��}|�d|d��d|d�SdS)zu
        Returns a well formatted baseurl string
        :param repo_url: a repo URL that you want to format
        z$releasever�
releaseverz	$basearch�basearchN)r	�_cut_question_mark�_obtain_mappings�replace)rrhZmappingsrrrr^�s
�zEnabledRepos._format_baseurlcCs|d|�d��S)z�
        Returns a string where everything after the first occurrence of '?' is truncated
        :param repo_url: a repo URL that you want to modify
        N�?)�find)rrhrrrrk�szEnabledRepos._cut_question_markcCs2tdur|��Stdur |��St�d�t�dS)z�
        returns a hash with "basearch" and "releasever" set. This will try dnf first, and them yum if dnf is
        not installed.
        NzCUnable to load module for any supported package manager (dnf, yum).)rF�_obtain_mappings_dnfrd�_obtain_mappings_yumr3r2r_rrrrrls
zEnabledRepos._obtain_mappingscCs|jjjd|jjjdd�S�Nrirj)rirj)rcrIrJrrrrrps�z!EnabledRepos._obtain_mappings_dnfcCs|jjjd|jjjdd�Srr)rerIZyumvarrrrrrqsz!EnabledRepos._obtain_mappings_yum)rrr
rrTrfrrrr^rkrrlrprqrrrrrU�s


rUc@sFeZdZdZefedd�dd�Zded�dd�Ze	e
d	�d
d�ZdS)�EnabledReposProfilez8
    Collect information about enabled repositories
    NracCst|�|_dSr)rU�_enabled_reposrgrrrrszEnabledReposProfile.__init__rcCs|jj|jjkSr�rtrr rrrr!"szEnabledReposProfile.__eq__rcCs|jjS)zc
        Gather list of enabled repositories
        :return: List of enabled repositories
        rurrrrrQ%szEnabledReposProfile.collect)rrr
r�REPOSITORY_PATHrrrRr!rrTrQrrrrrssrsc	@steZdZdZdeeeeeedd�dd�Zed�dd	�Zde	d
�dd�Z
ed�d
d�Zee
eefed�dd��ZdS)�Packagez7
    Represents a package installed on the system.
    rN)r#r%�releaser'�epoch�vendorrcCs(||_||_||_||_||_||_dSr�r#r%rxr'ryrz)rr#r%rxr'ryrzrrrr2szPackage.__init__rcCsB|�|j�|�|j�|�|j�|�|j�|�|j�|�|j�d�S)z3Returns a dict representation of this package info.r{)�_normalize_stringr#r%rxr'ryrzrrrr�to_dict<s





�zPackage.to_dictrcCsnt|t|��sdS|j|jkrj|j|jkrj|j|jkrj|j|jkrj|j|jkrj|�|j�|�|j�krjdSdS�zV
        Compare one profile to another to determine if anything has changed.
        FT)	�
isinstance�typer#r%rxr'ryr|rzr rrrr!Gs 
�
�
�
�
��zPackage.__eq__cCsd|j|j|jfS)Nz<Package: %s %s %s>)r#r%rxrrrrrZszPackage.__str__)�valuercCst|�tur|�dd�S|S)Nzutf-8rm)r��bytes�decode)r�rrrr|^szPackage._normalize_string)rN)rrr
rr�intrrTr}rRr!rrSrr�r|rrrrrw-s��
rwc@s^eZdZdejdd�dd�Zeeeee	d�dd��Z
eed�d	d
�Zded�dd
�Z
dS)�
RPMProfileN)�	from_filercCs�g|_|rlt�d|j�|��}t�|�}|D]8}|j�t|d|d|d|d|d|dd��q0n0t�d	�t	�
�}|�d
�|��}|�
|�|_dS)z�
        Load the RPM package profile from a given file, or from rpm itself.

        NOTE: from_file is a file descriptor, not a file name.
        z!Loading RPM profile from file: %sr#r%rxr'ryrzr{zLoading current RPM profile.���N)�packagesr3r4r#r]r5r6rMrw�rpmZTransactionSetZ
setVSFlagsZdbMatch�_accumulate_profile)rr�Zjson_buffer�	pkg_dictsZpkg_dict�tsZ	installedrrrrfs*
��

zRPMProfile.__init__)�rpm_header_listrcCsZg}|D]L}|ddkrq|�t|d|d|d|d|dpBd|dpLd	d
��q|S)z�
        Accumulates list of installed rpm info
        @param rpm_header_list: list of rpm headers
        @return: list of package info dicts
        r#z
gpg-pubkeyr%rxr'ryrrzNr{)rMrw)r�Zpkg_list�hrrrr��s

��
zRPMProfile._accumulate_profilercCs"g}|jD]}|�|���q
|S)z�
        Returns a list of dicts containing the package info.

        See 'packages' member on this object for a list of actual objects.

        @return : list of package info dicts
        @rtype: list
        )r�rMr})rr��pkgrrrrQ�s	
zRPMProfile.collectrcCsJt|t|��sdSt|j�t|j�kr*dS|jD]}||jvr0dSq0dSr~)rr��lenr�)rrr�rrrr!�s

zRPMProfile.__eq__)N)rrr
�_io�
TextIOWrapperrrSrrTrwr�rQrRr!rrrrr�es
r�)�profile_typercCs |tvrtd|��t|�}|S)z�
    Returns an instance of a Profile object
    @param profile_type: profile type
    Returns an instance of a Profile object
    z$Could not find profile for type [%s])�PROFILE_MAPr
)r�rArrr�get_profile�s

r�)r�r`Zmodulemdr�),r�Zlogging�importlib.util�	importlibr�Zos.pathrY�typingrrZrhsmrr5Z
rhsm.utilsrZiniparserrZ
cloud_whatrrFr_rGrd�util�	find_specr	rR�__annotations__rvZ	getLoggerrr3�	Exceptionr
rrUrsrwr�rr�r�rTrrrr�<module>sL




	X8Z�