403Webshell
Server IP : 172.24.0.40  /  Your IP : 216.73.216.10
Web Server : Apache
System : Linux dbweb26.ust.edu.ph 4.18.0-513.5.1.el8_9.x86_64 #1 SMP Fri Sep 29 05:21:10 EDT 2023 x86_64
User : apache ( 48)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib64/python3.6/site-packages/rhsm/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib64/python3.6/site-packages/rhsm/__pycache__/profile.cpython-36.pyc
3

a�e <�$@s�ddlmZmZmZddlZddlZddlZddlZddlZ	ddl
mZddl
mZddlmZmZddlmZyddlZWnek
r�dZYnXyddlZWnek
r�dZYnXyddlZWnek
r�dZYnXyejd�dZWnek
�rd	ZYnXe�rd
ZndZeje�ZGdd
�d
e�ZGdd�de �Z!Gdd�de �Z"Gdd�de �Z#Gdd�de �Z$Gdd�de �Z%dd�Z&e%e#e!d�Z'dS)�)�print_function�division�absolute_importN)�ourjson)�suppress_output)�SafeConfigParser�ConfigParser)�providerZzypp_pluginTFz$/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�/usr/lib64/python3.6/profile.pyr
7sr
c@sVeZdZdd�Zdd�Zdd�Zedd��Zed	d
�dd��Ze	d
d��Z
dd�Zd	S)�ModulesProfilecCs|j�|_dS)N)�_ModulesProfile__generate�content)�selfrrr�__init__@szModulesProfile.__init__cCs
t|j�S)N)�strr)rrrr�__str__CszModulesProfile.__str__cCs|j|jkS)N)r)r�otherrrr�__eq__FszModulesProfile.__eq__cCs~i}xl|D]d}|d|d|d|d|df}||krB|||<q
||jdd�dkr
|jdd�dkr
|||<q
Wt|j��S)	N�name�stream�version�context�arch�activeFT)�get�list�values)�module_list�ret�module�keyrrr�	_uniquifyIs
"
$zModulesProfile._uniquifyN)�returncCs tj�}|dks|jdkr(tjd�dStjd�|j�}|dkrPtjd�dSytj|�}Wn tjk
r~tj	d�dSXd|kr�tjd�dS|d}tjd	|���xl|j
|�D]^}tjd
|j���y|j||�Wq�t
k
�r}ztjdj|d��WYdd}~Xq�Xq�WdS)
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)r	Zget_cloud_providerZCLOUD_PROVIDER_ID�log�debugZget_metadata�json�loadsZJSONDecodeError�warningZ
rhui_repos�idZfix_rhui_url_template�
ValueError�format)�baseZcloud_providerZmetadata_strZmetadatar)Zrepor*rrr�fix_aws_rhui_reposXs2	




z!ModulesProfile.fix_aws_rhui_reposc
"Cs�g}tdk	otdk	�rztj�}|jjj|jj�|j�|j|�yt	j
d�|j�Wn6tjj
k
r�}zt	jdt|��gSd}~XnXy
|j}Wntk
r�t	jd�gSX|j�}x�|D]�}d}d}|j|j�|j��r�d}n|j|j���rd}|j|j���rd}g}	|dk�r6t|j|j���}	|j|j�|j�|j�|j�|j�d	d
�|j �D�|	||d�	�q�Wt!j"|�S)Nz!Trying to fill dnf sack object...z Unable to create sack object: %sz+DNF does not provide modulemd functionality�defaultF�enabledZdisabledTcSsg|]}|j��qSr)�getName)�.0�profilerrr�
<listcomp>�sz-ModulesProfile.__generate.<locals>.<listcomp>)	rrrrrZprofiles�installed_profiles�statusr)#�dnf�libdnf�Base�conf�
substitutionsZupdate_from_etcZinstallrootZread_all_reposr4r+r,Z	fill_sack�
exceptionsZ	RepoErrorr*rZ_moduleContainer�AttributeErrorr/ZgetModulePackagesZ	isEnabledr7Z	getStreamZ
isDisabledZisModuleActiveZgetIdr!ZgetInstalledProfiles�appendZ
getVersionZ
getContextZgetArchZgetProfilesrr')
rr#r3�err�modulesZall_module_listZ
module_pkgr<rr;rrr�
__generate�sR





zModulesProfile.__generatecCs|jS)zf
        Gather list of modules reported to candlepin server
        :return: List of modules
        )r)rrrr�collect�szModulesProfile.collect)rrr
rrr�staticmethodr'r4rrrHrrrrr>s'8rc@sPeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	d
d�Z
dd�ZdS)�EnabledReposc
s�tjj|j�sgStrt��nt���j|j��fdd��j�D�}g}xH|D]@}y$|j	||j
�j|d��gd��WqPtk
r�PYqPXqPW|S)Ncsg|]}�j|d�r|�qS)r6)Z
getboolean)r8�section)�configrrr:�sz+EnabledRepos.__generate.<locals>.<listcomp>�baseurl)ZrepositoryidrM)
�os�path�exists�repofile�
use_zypperrr�readZsectionsrD�_format_baseurlr �ImportError)rZenabled_sections�
enabled_reposrKr)rLrrG�s 
zEnabledRepos.__generatecCs<tdk	rtjj�|_ntdk	r(tj�|_||_|j�|_dS)zc
        :param path: A .repo file path used to filter the report.
        :type path: str
        N)	r=r?�db�yumZYumBase�ybrQ�_EnabledRepos__generater)r�	repo_filerrrr�s
zEnabledRepos.__init__cCs
t|j�S)N)rr)rrrrr�szEnabledRepos.__str__cCs6tr|j|�S|j�}|jd|d�jd|d�SdS)z�
        returns a well formatted baseurl string

        :param repo_url: a repo URL that you want to format
        :type path: str
        z$releasever�
releaseverz	$basearch�basearchN)rR�_cut_question_mark�_obtain_mappings�replace)r�repo_urlZmappingsrrrrT�s
zEnabledRepos._format_baseurlcCs|d|jd��S)z�
        returns a string where everything after the first occurence of ? is truncated

        :param repo_url: a repo URL that you want to modify
        :type path: str
        N�?)�find)rrarrrr^�szEnabledRepos._cut_question_markcCs2tdk	r|j�Stdk	r |j�Stjd�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).)r=�_obtain_mappings_dnfrX�_obtain_mappings_yumr+r*rU)rrrrr_s
zEnabledRepos._obtain_mappingscCs|jjjd|jjjdd�S)Nr\r])r\r])rWr@rA)rrrrrdsz!EnabledRepos._obtain_mappings_dnfcCs|jjjd|jjjdd�S)Nr\r])r\r])rYr@Zyumvar)rrrrresz!EnabledRepos._obtain_mappings_yumN)rrr
rZrrrTr^rr_rdrerrrrrJ�s

	rJc@s,eZdZdZefdd�Zdd�Zdd�ZdS)	�EnabledReposProfilez8
    Collect information about enabled repositories
    cCst|�|_dS)N)rJ�_enabled_repos)rr[rrrrszEnabledReposProfile.__init__cCs|jj|jjkS)N)rgr)rrrrrrszEnabledReposProfile.__eq__cCs|jjS)zc
        Gather list of enabled repositories
        :return: List of enabled repositories
        )rgr)rrrrrH"szEnabledReposProfile.collectN)rrr
r�REPOSITORY_PATHrrrHrrrrrfsrfc@s>eZdZdZddd�Zdd�Zdd	�Zd
d�Zedd
��Z	dS)�Packagez7
    Represents a package installed on the system.
    rNcCs(||_||_||_||_||_||_dS)N)rr�releaser�epoch�vendor)rrrrjrrkrlrrrr.szPackage.__init__cCsB|j|j�|j|j�|j|j�|j|j�|j|j�|j|j�d�S)z6 Returns a dict representation of this packages info. )rrrjrrkrl)�_normalize_stringrrrjrrkrl)rrrr�to_dict6s




zPackage.to_dictcCsnt|t|��sdS|j|jkrj|j|jkrj|j|jkrj|j|jkrj|j|jkrj|j|j�|j|j�krjdSdS)zV
        Compare one profile to another to determine if anything has changed.
        FT)	�
isinstance�typerrrjrrkrmrl)rrrrrrAszPackage.__eq__cCsd|j|j|jfS)Nz<Package: %s %s %s>)rrrj)rrrrrRszPackage.__str__cCst|�tjkr|jdd�S|S)Nzutf-8r`)rp�sixZbinary_type�decode)�valuerrrrmVszPackage._normalize_string)rN)
rrr
rrrnrrrIrmrrrrri*s
ric@s2eZdZd
dd�Zedd��Zdd�Zdd	�ZdS)�
RPMProfileNc
Cs�g|_|rptjd|j�|j�}tj|�}xr|D]8}|jjt|d|d|d|d|d|dd��q2Wn0tjd	�t	j
�}|jd�|j�}|j
|�|_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: %srrrjrrkrl)rrrjrrkrlzLoading current RPM profile.�N���)�packagesr+r,rrSr-r.rDri�rpmZTransactionSetZ
setVSFlagsZdbMatch�_accumulate_profile)rZ	from_fileZjson_buffer�	pkg_dictsZpkg_dictZtsZ	installedrrrr_s$



zRPMProfile.__init__c
Cs^g}xT|D]L}|ddkrq
|jt|d|d|d|d|dpDd|dpNd	d
��q
W|S)z�
        Accumulates list of installed rpm info
        @param rpm_header_list: list of rpm headers
        @type rpm_header_list: list
        @return: list of package info dicts
        @rtype: list
        rz
gpg-pubkeyrrjrrkrrlN)rrrjrrkrl)rDri)Zrpm_header_listZpkg_list�hrrrryzs


zRPMProfile._accumulate_profilecCs&g}x|jD]}|j|j��qW|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
        )rwrDrn)rrz�pkgrrrrH�s	zRPMProfile.collectcCsLt|t|��sdSt|j�t|j�kr*dSx|jD]}||jkr2dSq2WdS)zV
        Compare one profile to another to determine if anything has changed.
        FT)rorp�lenrw)rrr|rrrr�s
zRPMProfile.__eq__)N)rrr
rrIryrHrrrrrrt]s
rtcCs |tkrtd|��t|�}|S)z�
    Returns an instance of a Profile object
    @param profile_type: profile type
    @type profile_type: string
    Returns an instance of a Profile object
    z$Could not find profile for type [%s])�PROFILE_MAPr
)Zprofile_typer9rrr�get_profile�s

r)rxrVZmodulemd)(Z
__future__rrrZloggingZimprxrqZos.pathrNZrhsmrr-Z
rhsm.utilsrZiniparserrZ
cloud_whatr	r=rUr>rX�find_modulerRrhZ	getLoggerrr+�	Exceptionr
�objectrrJrfrirtrr~rrrr�<module>sR





W3Y

Youez - 2016 - github.com/yon3zu
LinuXploit