OwlCyberSecurity - MANAGER
Edit File: debug.cpython-36.pyc
3 �gt`1������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZ�d�dlmZmZ�d�dlZd�dl Zd�dl Z d�dlZd�dlZd�dl Z d�dlZd�dlZdZG�dd��dej�ZG�d d ��d ejj�ZG�dd��dejj�Zd d��Zdd��Zdd��ZdS�)�����)�absolute_import)�unicode_literals)�ucd)�_�loggerNzdnf-debug-dump version 1 c�������������������s ���e�Zd�ZdZ��fdd�Z���ZS�)�Debug�debugc����������������sD���t�t|��j||��||�_||�_|�jd�k r@|�jjt��|�jjt��d�S�)N)�superr����__init__�base�cliZregister_command�DebugDumpCommand�DebugRestoreCommand)�selfr���r���)� __class__���/usr/lib/python3.6/debug.pyr ���)���s���� zDebug.__init__)�__name__� __module__�__qualname__�namer ���� __classcell__r���r���)r���r���r���%���s���r���c�������������������st���e�Zd�ZdZed�Z��fdd�Zdd��Zedd���Z d d ��Z dd��Zd d��Zdd��Z dd��Zdd��Zdd��Z���ZS�)r ���� debug-dumpz5dump information about installed rpm packages to filec����������������s���t�t|��j|��d�|�_d�S�)N)r ���r ���r ���� dump_file)r���r���)r���r���r���r ���7���s����zDebugDumpCommand.__init__c�������������C���s���d|�j�j_d|�j�j_d�S�)NT)r����demands�sack_activation�available_repos)r���r���r���r���� configure;���s���� zDebugDumpCommand.configurec�������������C���s.���|�j�dddtd�d��|�j�ddtd�d ��d�S�) Nz --norepos� store_trueFz/do not attempt to dump the repository contents.)�action�default�help�filename�?zoptional name of dump file)�nargsr!���)�add_argumentr���)�parserr���r���r���� set_argparser?���s����zDebugDumpCommand.set_argparserc�������������C���s����|�j�j}|s6tjdtjtj����}dtj��d�|f�}tjj|�}|j d�r\t j|d�|�_nt |d�|�_|�jt��|�j���|�j���|�j���|�j|�j�j���|�j���|�jj���ttd�|���dS�)z{create debug txt file and compress it, if no filename specified use dnf_debug_dump-<timestamp>.txt.gz by defaultz%Y-%m-%d_%Tzdnf_debug_dump-%s-%s.txt.gz����z.gz�wzOutput written to: %sN)�optsr"����timeZstrftimeZ localtime�os�uname�path�abspath�endswith�gzip�GzipFiler����open�write� DEBUG_VERSION�dump_system_info�dump_dnf_config_info�dump_rpm_problems� dump_packagesZnorepos�dump_rpmdb_versions�close�printr���)r���r"���Znowr���r���r����runH���s ���� zDebugDumpCommand.runc�������������C���s4���t�jjr t|�jtj�r t|d�}t�jj|�j|��d�S�)N�utf8) �dnfZpycompZPY3� isinstancer���r1���r2����bytesZ write_to_file)r����msgr���r���r���r4���a���s���� zDebugDumpCommand.writec�������������C���sX���|�j�d��tj��}|�j�d|d�|d�f���|�j�dtj���|�j�dtjjdd����d�S�) Nz%%%%SYSTEM INFO z uname: %s, %s ��������z rpm ver: %s z python ver: %s � ��)r4���r,���r-����rpm�__version__�sys�version�replace)r���r-���r���r���r���r6���f���s���� z!DebugDumpCommand.dump_system_infoc�������������C���s����|�j�jj}djdd��|�j�jjD���}|�jd��|�jd|d����|�jd|d����|�jd |d ����|�jdtjj ���|�jd|���|�jd dj|�j�jj ����d�S�)N�,c�������������S���s���g�|�] }|j��qS�r���)r���)�.0�pr���r���r���� <listcomp>p���s����z9DebugDumpCommand.dump_dnf_config_info.<locals>.<listcomp>z %%%%DNF INFO z arch: %s �archz basearch: %s Zbasearchz releasever: %s Z releaseverz dnf ver: %s z enabled plugins: %s z global excludes: %s )r����confZ substitutions�joinZ_plugins�pluginsr4���r?����const�VERSION�excludepkgs)r����varrS���r���r���r���r7���n���s���� z%DebugDumpCommand.dump_dnf_config_infoc�������������C���sP���|�j�d��t|�j�\}}|�j�djdd��|D�����|�j�djdd��|D�����d�S�)Nz%%%%RPMDB PROBLEMS rF���c�������������S���s$���g�|�]\}}d�t�|�t�|�f��qS�)zPackage %s requires %s )r���)rM����req�pkgr���r���r���rO���}���s���z6DebugDumpCommand.dump_rpm_problems.<locals>.<listcomp>c�������������S���s$���g�|�]\}}d�t�|�t�|�f��qS�)zPackage %s conflicts with %s )r���)rM���rQ���rY���r���r���r���rO������s���)r4����rpm_problemsr���rR���)r���Zmissing� conflictsr���r���r���r8���z���s���� z"DebugDumpCommand.dump_rpm_problemsc������� ������C���s\��|�j�jj��}|�jd��x&t|j���D�]}|�jdt|����q$W�|sFd�S�|�jd��|j��}x�t|�j�jj ��dd��d�D�]�}y�d�}|j d�k r�|j }n*|jd�k r�|j}nt|j �dkr�|j d�}|�jd|j|f���|�jd d j|j����x,t|j|jd��D�]}|�jdt|����q�W�W�qr�tjjk �rR�}�z|�jd|t|�f���wrW�Y�d�d�}~X�qrX�qrW�d�S�) Nz %%%%RPMDB z %s z %%%%REPOS c�������������S���s���|�j�S�)N)�id)�xr���r���r����<lambda>����s����z0DebugDumpCommand.dump_packages.<locals>.<lambda>)�keyr���z %%%s - %s z excludes: %s rL���)ZreponamezError accessing repo %s: %s )r����sack�queryr4����sorted� installed�pkgspec� availableZreposZiter_enabledZmetalinkZ mirrorlist�lenZbaseurlr\���rR���rV����filterr?���� exceptions�Error�str) r���Z load_repos�qrN���re���ZrepoZurlZpo�er���r���r���r9�������s2���� zDebugDumpCommand.dump_packagesc�������������C���s(���|�j�d��|�jjj��}|�j�d|���d�S�)Nz%%%%RPMDB VERSIONS z all: %s )r4���r���r`���Z_rpmdb_version)r���rJ���r���r���r���r:�������s���� z$DebugDumpCommand.dump_rpmdb_versions)r���)r���r���r����aliasesr����summaryr ���r����staticmethodr'���r=���r4���r6���r7���r8���r9���r:���r���r���r���)r���r���r ���2���s��� r ���c���������������@���sP���e�Zd�ZdZed�Zdd��Zedd���Zdd��Z d d ��Z dd��Zed d���ZdS�)r���� debug-restorez,restore packages recorded in debug-dump filec�������������C���s4���d|�j�j_d|�j�j_d|�j�j_|�jjs0d|�j�j_d�S�)NT)r���r���r���r���Z root_userr*����outputZ resolving)r���r���r���r���r�������s ���� zDebugRestoreCommand.configurec�������������C���s~���|�j�ddtd�d��|�j�ddtd�d��|�j�ddtd�d��|�j�d d dtd�d ��|�j�ddtd�d��|�j�ddtd�d��d�S�)Nz--outputr���z,output commands that would be run to stdout.)r���r!���z--install-latestz0Install the latest version of recorded packages.z --ignore-archz_Ignore architecture and install missing packages matching the name, epoch, version and release.z--filter-typesz[install, remove, replace]zinstall, remove, replacezlimit to specified type)�metavarr ���r!���z--remove-installonlyzqAllow removing of install-only packages. Using this option may result in an attempt to remove the running kernel.r"���r(���zname of dump file)r$���r!���)r%���r���)r&���r���r���r���r'�������s$����z!DebugRestoreCommand.set_argparserc�������������C���sV���|�j�jr$t|�j�jjdd�j���|�j�_|�j|�j�jd��}|�j||�j���|�j||�j���dS�)z Execute the command action here.rL���� r���N) r*����filter_types�setrK����split�read_dump_filer"����process_installed�process_dump)r���� dump_pkgsr���r���r���r=�������s����zDebugRestoreCommand.runc�������������C���s����|�j�jj��j��}|�j�j|�}x�|D�]�}d}t|�}|j|j|jfd��}|d�k r�|j |j |jf} | |krpd|| <�q�||kr~d}q�d|jkr�d} nd} x|j ��D�]}| ||<�q�W�nd}|r"d|jkr"||ks�|jr"|jr�td|���q"|�j�j|��q"W�d�S�)NF�skipTrK����removezremove %s)r���r`���ra���rc���Z_get_installonly_queryrd����getr���rP����epochrJ����releasert����keysZremove_installonlyrq���r<���Zpackage_remove)r���rz���r*���rc���Zinstallonly_pkgsrY���Z pkg_remove�spec�dumped_versionsZevrr���Zd_evrr���r���r���rx�������s.���� z%DebugRestoreCommand.process_installedc���������� ���C���s����x�t�|j���D�]�\}}|||f�}x�t�|j���D�]�\}}}||||f�} | dkrRq0|jr^d} nd|�} |jr�| dkr�d|| f�}nt|| |||�}| |jkr0|jr�td| |f���q0y|�jj |��W�q0�t jjk r����t jtd�|��Y�q0X�q0W�qW�d�S�)Nr{���rF����.�installz%s%sz%s %szPackage %s is not available)rb���r����Zignore_archZinstall_latest�pkgtup2specrt���rq���r<���r���r����r?���rh���ZMarkingErrorr����errorr���)r���rz���r*����n�ar����rl����v�rr���rP����pkg_specr���r���r���ry�������s&���� z DebugRestoreCommand.process_dumpc�������������C���s����|�j�d�rtj|��}nt|��}t|j���tkrFtjt d�|���t jj�d}i�}xp|D�]h}t|�}|rr|dkrTd}qT|�s�|d�dkr�P�|j ��}tj|�}d|j|j|jfi��|j|j|jf<�qTW�|S�) Nz.gzzBad dnf debug file: %sTz %%%%RPMDB Fr���rs���r����)r0���r1���r2���r3���r����readliner5���r���r����r���r?���rh���ri����strip�hawkeyZsplit_nevra� setdefaultr���rP���r~���rJ���r���)r"���Zfobjr{���Zpkgs�liner����Znevrar���r���r���rw�����s(���� (z"DebugRestoreCommand.read_dump_fileN)rp���) r���r���r���rm���r���rn���r���ro���r'���r=���rx���ry���rw���r���r���r���r���r�������s���#r���c����������������s����t�jj|��}|j��j����t��}t��}x@��D�]8�|j�fdd��jD����|j�fdd��jD����q*W���fdd�|D��}��fdd�|D��}||fS�)Nc����������������s2���g�|�]*}t�|�d�k�rt�|�jd��r|��f�qS�)zsolvable:prereqmarkerzrpmlib()rj���� startswith)rM���rX���)rY���r���r���rO���:��s����z rpm_problems.<locals>.<listcomp>c����������������s���g�|�]}|��f�qS�r���r���)rM���rQ���)rY���r���r���rO���=��s����c����������������s$���g�|�]\}}��j�|d��s||f�qS�))�provides)rg���)rM���rX���rY���)�allpkgsr���r���rO���?��s����c����������������s$���g�|�]\}}��j�|d��r||f�qS�))r����)rg���)rM���rQ���rY���)r����r���r���rO���A��s����) r?���r`���Z_rpmdb_sackra���rc���ru����update�requiresr[���)r���Zrpmdbr����r[���Zmissing_requiresZexisting_conflictsr���)r����rY���r���rZ���3��s���� rZ���c�������������C���s���t�|�j|�j|�j|�j|�j�S�)N)r����r���rP���r~���rJ���r���)rY���r���r���r���rd���F��s����rd���c�������������C���s<���|sdnd|j�d��}|dkr"dnd|�}d|�||||f�S�)NrF���z.%sr����z%s:z%s-%s%s-%s%s)NrF���)�lstrip)r���rP���r~���rJ���r���r����rl���r���r���r���r����J��s����r����)Z __future__r���r���Zdnf.i18nr���Zdnfpluginscorer���r���r?���Zdnf.clir1���r����r,���rG���rI���r+���r5���ZPluginr���r���ZCommandr ���r���rZ���rd���r����r���r���r���r����<module>���s&��� w�