404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.133.108.155: ~ $
3

�fZv�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZm
Z
ddlZddlmZddlmZddlZy$ddlmZmZmZmZdd�ZWnLek
�rd	d
�ZyddlmZWnek
r�dd�ZYnXYnXd
Zeed�ed�g�Zeed�ed�dg�Ze�rdddl m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'n(ddl!m!Z!m"Z"m#Z#ddl(m%Z%m&Z&m'Z'ej)j*Gdd�dej+j,��Z-ej)j*Gdd�de-��Z.dS)�)�print_functionN)�_�logger)�PY3)�ucd)�name�version�codename�os_release_attrcCst�t�t�fS)N)rrr	�rr�/usr/lib/python3.6/copr.py�linux_distribution.sr
cCsdS)N�r)rrrrr
1sr
)r
cCsrtd��`}i}xF|D]>}y$|j�jd�\}}|jd�||<Wqtk
rPYqXqW|d|ddfSQRXdS)Nz/etc/os-release�=�"�NAMEZ
VERSION_ID)�open�rstrip�split�strip�
ValueError)Zos_release_fileZos_release_data�lineZos_release_keyZos_release_valuerrrr
7s


�copr�yes�y�no�nr)�ConfigParser�
NoOptionError�NoSectionError)�urlopen�	HTTPError�URLErrorc@seZdZdZdZdZdZdZdZedeZ	d8Z
ed	�Zd
Z
ed�Zedd
��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zed$d%��Zd&d'�Zd(d)�Zd*d+�Z d,d-�Z!d.d/�Z"d0d1�Z#ed2d3��Z$ed4d5��Z%ed6d7��Z&dS)9�CoprCommandz Copr plugin for DNF Nzcopr.fedorainfracloud.orgZfedoraZhttpsi�z://rz Interact with Copr repositories.Ta�
  enable name/project [chroot]
  disable name/project
  remove name/project
  list --installed/enabled/disabled
  list --available-by-user=NAME
  search project

  Examples:
  copr enable rhscl/perl516 epel-6-x86_64
  copr enable ignatenkobrain/ocltoys
  copr disable rhscl/perl516
  copr remove rhscl/perl516
  copr list --enabled
  copr list --available-by-user=ignatenkobrain
  copr search tests
    c	Cs�|jddddddddgd	�|j�}|jd
dtd�d
�|jddtd�d
�|jddtd�d
�|jddtd�d�|jdtd�d�|jddd�dS)N�
subcommand��help�enable�disable�remove�list�search)�nargs�choicesz--installed�
store_truez.List all installed Copr repositories (default))�actionr&z	--enabledzList enabled Copr repositoriesz
--disabledzList disabled Copr repositoriesz--available-by-userrz-List available Copr repositories by user NAME)�metavarr&z--hubz(Specify an instance of Copr to work with)r&�arg�*)r,)�add_argumentZadd_mutually_exclusive_groupr)�parserZlist_optionrrr�
set_argparserpszCoprCommand.set_argparsercCs�|jjjjdkrdSd}t�}g}|jjjd}tjj	|t
d�}tjj|�r�|j|�|j
|�|jdd�r�|jdd�r�|jdd�}|jdd�}||g|_n
ddg|_xHtjtjj	|t
d��D],}|jd�r�tjj	|t
d|�}	|j|	�q�Wg}
t|jj��r|jjdjd	�}
t|
�d
k�rV|jj�rVtjtd�td��tjjtd
���nL|jj�r�t|
�d
k�r�|j|_|j|_n t|
�d
k�r�|
d}n|jj}|�rH|�rHd|_|j
t |dd��|j!||dd�}|�rH|j!||d|j"�}|j!||d|j#�}
||_|d||_t$|
�|j#k�rH|jd|
7_|jd|
7_|j�s�d|k�rr||_|j"d||_n|jdd�d|_||_dS)Nrrz.conf�main�distribution�
releaseverFz.d�/�zError: z^specify Copr hub either with `--hub` or using `copr_hub/copr_username/copr_projectname` formatzmultiple hubs specifiedT)�reverse�hostname�protocol�portz://�:r%)%�cliZcommand�optsr�base�confZpluginconfpath�os�path�join�PLUGIN_CONF�isfile�append�readZ
has_option�get�
chroot_config�listdir�endswith�lenr1r�hubr�criticalr�dnf�CliError�default_hostname�
copr_hostname�default_url�copr_url�sorted�_read_config_item�default_protocol�default_port�int)�selfZcopr_hubZcopr_plugin_configZconfig_filesZconfig_pathZdefault_config_filer7r8�filenameZconfig_file�projectr<r=r>rrr�	configure�sl








zCoprCommand.configurecCs*y|j||�Sttfk
r$|SXdS)N)rKrr)r]�configrPZsection�defaultrrrrY�szCoprCommand._read_config_itemcCstjjdj|j���dS)Nz{0}
)�sys�stderr�write�formatr)r]�textrrr�_user_warning_before_prompt�sz'CoprCommand._user_warning_before_promptc
Cs�|jjd}|dkr&|jjj|�dS|dkrl|jjrH|j|jj�dS|j|jj	j
d|jj|jj�dSy|jj
d}WnLttfk
r�tjtd�td��|jjj|�tjjtd���YnXy\|jj
d}t|jj
�dkr�tjjtd���|jd	�|_t|j�d
k�r$tjjtd���Wn*tk
�rP|j�}|jd	�|_YnX|dk�rj|j|�dS|jd
�}t|�dk�r�tjtd�td��tjjtd���n<t|�dk�r�|d}|d}n|d}|d}|d
|}dj|jj	j|j|j|�|�}|dk�rn|j �td�}d
j!|j||g�}dj|�}	|j"||	�|j#||�tj$td��|j%||�nr|dk�r�|j �|j&||�tj$td��nD|dk�r�|j �|j'||�tj$td��ntjjtd�j|���dS)Nrr&r*zError: z>exactly two additional parameters to copr command are requiredr%�zToo many arguments.�-r:zOBad format of optional chroot. The format is distribution-version-architecture.r+r9zEuse format `copr_username/copr_projectname` to reference copr projectzbad copr project formatz{0}/_copr:{1}:{2}:{3}.repor'a
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>,
and packages are not held to any quality or security level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
z!Do you really want to enable {0}?z Repository successfully enabled.r(z!Repository successfully disabled.r)z Repository successfully removed.zUnknown subcommand {}.)rir:)(rAr$r@Z	optparserZ
print_helpZavailable_by_user�_list_user_projects�_list_installed_repositoriesrBrCZreposdir�enabledZdisabledr1r�
IndexErrorrrQrrRrSrO�
exceptions�Errorr�chroot_parts�
_guess_chroot�_searchrf�get_reposdirrU�_sanitize_username�
_need_rootrF�	_ask_user�_download_repo�info�_runtime_deps_warning�
_disable_repo�_remove_repo)
r]r$�project_name�chrootr_�
copr_username�copr_projectname�
repo_filenamery�msgrrr�run�s�








zCoprCommand.runcCs�|jjd�d}tjd|j|�}|j|jko8tjd|�}tjd|�}|jjr`|rh|rhdSn|shdStjd|�rxdStjd|�r�dS|j	}	|	r�|s�|	r�|r�dSd}
tjd	|�r�|jd
d�\}}}
}|d|
d|}n�tjd|��r2|jdd�}|j
d
d
�djd
d�d}|d|dd|d}n.|jdd�}|jd|dd|d}d}
|	�sn|d7}|
�r||d7}t|�|
S)Nr9r%z_copr:Z_copr_z_copr:|^_copr_zcopr:.*:.*:.*:mlz
coprdep:.*Fzcopr:r?r:rjrirTz (disabled)z *���)
�repofiler�re�matchrUrWrVrArPrm�rsplitrT�print)r]�repo_id�repo�enabled_only�
disabled_only�	file_nameZ	match_newZ	match_oldZ	match_anyrm�old_reporrUZ
copr_ownerZcopr_dirr�Z	copr_namerrr�_list_repo_file8sBzCoprCommand._list_repo_filecCsFd}x,|jjj�D]\}}|j||||�rd}qW|rBttd��dS)NFTz�* These coprs have repo file with an old format that contains no information about Copr hub - the default one was assumed. Re-enable the project to fix this.)rB�repos�itemsr�r�r)r]Z	directoryr�r�r�r�r�rrrrlisz(CoprCommand._list_installed_repositoriesc

Cs�dj|�}|j|}|jj|dd�}ytj|j��}Wn*tk
r`tj	j
td�j|���YnX|j|�td�j|�}|j
|�xL|dD]@}dj||d�}|d	p�td
�}	|jjjt|�|	�}t|�q�WdS)Nz!/api_3/project/list?ownername={0}zw+)�modez+Can't parse repositories for username '{}'.zList of {} coprsr�z
{0}/{1} : r�descriptionzNo description given)rfrWrBr �json�loadsrJrrRrorpr�_check_json_output�_print_match_section�output�
fmtKeyValFillrr�)
r]Z	user_name�api_path�url�res�
json_parse�section_text�itemr��descrrrrkss"



zCoprCommand._list_user_projectsc
Cs�dj|�}|j|}|jj|dd�}ytj|j��}Wn*tk
r`tj	j
td�j|���YnX|j|�td�j|�}|j
|�xJ|dD]>}dj|d�}|d	p�td
�}	|jjjt|�|	�}t|�q�WdS)Nz/api_3/project/search?query={}zw+)r�zCan't parse search for '{}'.zMatched: {}r�z{0} : Z	full_namer�zNo description given.)rfrWrBr r�r�rJrrRrorprr�r�r�r�rr�)
r]Zqueryr�r�r�r�r�r�r�r�rrrrs�s 



zCoprCommand._searchcCs|jjj|�}t|�dS)N)rBr�Z
fmtSectionr�)r]rgZ	formattedrrrr��sz CoprCommand._print_match_sectioncCsj|jstjjd�d|_tjjdj|j���|jj�rf|jjj	sb|jj
jdj|�dj|�d�rfdSdS)N�
Fz{0}
z
{} [y/N]: z
{} [Y/n]: )r�Zdefaultyes_msgT)�
first_warningrcrdrerfrrBZ
_promptWantedrCZassumenor�Zuserconfirm)r]ryr�rrr�_ask_user_no_raise�s
zCoprCommand._ask_user_no_raisecCs |j||�stjjtd���dS)NzSafe and good answer. Exiting.)r�rRrorpr)r]ryr�rrrrw�szCoprCommand._ask_usercCs tj�dkrtjjtd���dS)Nrz/This command has to be run under the root user.)rD�geteuidrRrorpr)�clsrrrrv�szCoprCommand._need_rootcs|j��dks&�ddks&�ddkr,t��|jjjd}t�fdd�dD��r�d
�krbd|}n&dtd
�krxd|}ndj�d|�}n�d�kr�tj	d�}d�kr�dj|�}ndj�d|�}nPd�kr�tj	d�}d�kr�dj|�}ndj�d|�}nd�dj
dd�d}|S)z2 Guess which chroot is equivalent to this machine NrFr%Zbasearchcsg|]}|�k�qSrr)�.0r)�distrr�
<listcomp>�sz-CoprCommand._guess_chroot.<locals>.<listcomp>�Fedora�Fedora LinuxZRawhidezfedora-rawhide-ZrawhideZredhat_support_product_versionzfedora-{0}-{1}ZMageiaz%{distro_arch}ZCauldronzmageia-cauldron-{}zmageia-{0}-{1}ZopenSUSEz%{_target_cpu}Z
Tumbleweedzopensuse-tumbleweed-{}zopensuse-leap-{0}-{1}zepel-%s-x86_64�.)r�r�)rLr
rBrC�
substitutions�anyr
rf�rpmZexpandMacror)r]Zdistarchr~r)r�rrr�s, 



zCoprCommand._guess_chrootcCs�dj|jdd��}|jd}dj|||�}y*t|j|�}tjj|�rRtj|�W�n^t	k
�rl}z�|j
dkr�td�j|j||j
t|��}t
jj|��td�}|jjd�}	|	�r>tj|	�jd�}
tj|
�}
|td	�jdj|j�|�7}|
jd
��r0|td�djd
d�|
d
D��7}|td�j|�7}t
jj|��n|td�j|�7}t
jj|��WYdd}~XnJtk
�r�}z,td�j|j||jj�}t
jj|��WYdd}~XnX|j�}|jd�}tjd|��r�tjj|jjjd|dd�d�}|j|j k�rR|j!ddd�j!|j"d�j!ddd�j!dd�j!dd�}
tjj|
��rRtj|
�t#|d��.}|j$|�x|j%�D]}|j$|��qrWWdQRXtj&|t'j(t'j)Bt'j*Bt'j+B�dS) Nrjr%z%/coprs/{0}/repo/{1}/dnf.repo?arch={2}i�z Request to {0} failed: {1} - {2}z+It wasn't possible to enable this project.
zCopr-Error-Datazutf-8z1Repository '{0}' does not exist in project '{1}'.zavailable chrootsz
Available repositories: z, css|]}dj|�VqdS)z'{}'N)rf)r��xrrr�	<genexpr>�sz-CoprCommand._download_repo.<locals>.<genexpr>z�

If you want to enable a non-default repository, use the following command:
  'dnf copr enable {0} <repository>'
But note that the installed repo file will likely need a manual modification.zProject {0} does not exist.zFailed to connect to {0}: {1}z\[copr:rriz.repoz_copr:�_coprrr?Zgroup_�@�wbr�r����),rFrqrfr rWrDrE�existsr)r!�coder�strrRrorpZheadersrK�base64Z	b64decode�decoder�r�r"�reason�strerror�readliner�r�rBrCrtrV�replacerUrre�	readlines�chmod�stat�S_IRUSR�S_IWUSR�S_IRGRP�S_IROTH)r]r}r�Zshort_chrootZarchr�Zresponse�eZ	error_msgZ
error_dataZerror_data_decodedZ
first_linerZold_repo_filename�frrrrx�sX





$

zCoprCommand._download_repocs�|jjdd�|jj�|j|j|�|��g}x(�jj�D]}|jd�rJq:|j|�q:W|s`dSt	d�}t
jd��|jdj
��fdd	�|D���}|j|t	d
��s�x,|D]$}|jjj�j||jjjddi�q�WdS)
a,
        In addition to the main copr repo (that has repo ID prefixed with
        `copr:`), the repofile might contain additional repositories that
        serve as runtime dependencies. This method informs the user about
        the additional repos and provides an option to disable them.
        T)r�zcopr:Na�Maintainer of the enabled Copr repository decided to make
it dependent on other repositories. Such repositories are
usually necessary for successful installation of RPMs from
the main Copr repository (they provide runtime dependencies).

Be aware that the note about quality and bug-reporting
above applies here too, Fedora Project doesn't control the
content. Please review the list:

{0}

These repositories have been enabled automatically.r%z

cs*g|]"}djt��|�jj|d�d��qS)z){num:2}. [{repoid}]
    baseurl={baseurl}�baseurl)Znum�repoidr�)rf�next�cfgZgetValue)r�r�)�counterr�rrr�9sz5CoprCommand._runtime_deps_warning.<locals>.<listcomp>z!Do you want to keep them enabled?rm�0)rB�resetZread_all_repos�_get_copr_reporur��sections�
startswithrIr�	itertools�countrfrFr�rC�write_raw_configfiler�r�)r]rr�Zruntime_depsr�ryZdepr)r�r�rrzs*



z!CoprCommand._runtime_deps_warningcCs�dj|jjdd�d|j|�|�}||jjkr�dj|j|�|�}}||jjkr�d|jj|jkr�|jj|jjd�d	}y.|jdd�djdd�d}||jkr�dSWq�tk
r�Yq�XndS|jj|S)
Nzcopr:{0}:{1}:{2}r?r%rz{0}-{1}r�r9rir�)	rfrUr�rurBr�r�rrn)r]rr�r�r�rUrrrr�Fs 

zCoprCommand._get_copr_repocCst|j||�}|s,tjjtdj|j||����ytj|j	�Wn2t
k
rn}ztjjt|���WYdd}~XnXdS)Nz&Failed to remove copr repo {0}/{1}/{2})r�rRrorprrfrUrDr)r��OSErrorr�)r]rr�r�r�rrrr|\szCoprCommand._remove_repocCsd|j||�}|dkr,tjjtdj||����x2|jj�D]$}|jj	j
|j||jj	jddi�q8WdS)Nz!Failed to disable copr repo {}/{}rmr�)
r�rRrorprrfr�r�rBrCr�r�r�)r]rr�r�r�rrrr{hszCoprCommand._disable_repocCs<ytj|j��}Wn$tk
r6tjjtd��dSX|S)z� Wrapper around response from server

        check data and print nice error in case of some error (and return None)
        otherwise return json object.
        zUnknown response from server.N)r�r�rJrrRr@rSr)r�r�r�rrr�	_get_datatszCoprCommand._get_datacCs"d|krtjjdj|d���dS)N�errorz{})rRrorprf)r�Zjson_objrrrr��szCoprCommand._check_json_outputcCs&|ddkrdj|dd��S|SdS)Nrr�zgroup_{}r%)rf)r�rrrrru�szCoprCommand._sanitize_username)r)'�__name__�
__module__�__qualname__�__doc__rLrTZdefault_hubrZr[rV�aliasesr�summaryr��usage�staticmethodr5r`rYrhr�r�rlrkrsr�r�rw�classmethodrvrrrxrzr�r|r{r�r�rurrrrr#PsDL_1
%82r#c@sDeZdZdZdZed�ZdZdd�Zdd�Z	e
d	d
��Zdd�Zd
S)�PlaygroundCommandz Playground plugin for DNF �
playgroundz$Interact with Playground repository.z [enable|disable|upgrade]c	Cs0|j�|jtd�td��dj|j�}|jj|dd�}|j|�}|j�|ddkrft	j
jtd���x�|d	D]�}d
j|d|d�}d
j|jjj
|jdd��}yj||dkr�wpdj|j||�}|jj|dd�}|j|�}|j�|o�d|ko�|ddk�r
|j||�Wqpt	jjk
�r&YqpXqpWdS)Nz!Enabling a Playground repository.zDo you want to continue?z{0}/api/playground/list/zw+)r�r��okzUnknown response from server.r�z{0}/{1}ZusernameZcoprnamez{}/_playground_{}.repor9rjZchrootsz{0}/api/coprs/{1}/detail/{2}/)rvrwrrfrWrBr r��closerRr@rSrCrtr�rxrorp)	r]r~Zapi_urlr�r�r�r}r�Zoutput2rrr�_cmd_enable�s8




zPlaygroundCommand._cmd_enablecCs6|j�x(tjdj|jjj��D]}|j|�q WdS)Nz{}/_playground_*.repo)rv�globrfrBrCrtr|)r]r�rrr�_cmd_disable�szPlaygroundCommand._cmd_disablecCs|jdddddgd�dS)Nr$r%r'r(�upgrade)r,r-)r3)r4rrrr5�szPlaygroundCommand.set_argparsercCs�tjjd��|jjd}|j�}|dkrB|j|�tjt	d��n`|dkrb|j
�tjt	d��n@|dkr�|j
�|j|�tjt	d��ntjjt	d	�j|���dS)
Nz%Playground is temporarily unsupportedrr'z-Playground repositories successfully enabled.r(z.Playground repositories successfully disabled.r�z-Playground repositories successfully updated.zUnknown subcommand {}.)rRrorprAr$rrr�rryrr�rf)r]r$r~rrrr��s

zPlaygroundCommand.runN)r�)
r�r�r�r�r�rr�r�r�r�r�r5r�rrrrr��s r�)/Z
__future__rr�r�r�rDr�Zshutilr�rcr�ZdnfpluginscorerrrRZ
dnf.pycomprZdnf.i18nrr�Zdistrorrr	r
r
�ImportError�platformrG�setZYESZNOZconfigparserrrrZurllib.requestr r!r"Zurllib2ZpluginZregister_commandr@ZCommandr#r�rrrr�<module>sP
B

Filemanager

Name Type Size Permission Actions
builddep.cpython-36.opt-1.pyc File 7.27 KB 0644
builddep.cpython-36.pyc File 7.27 KB 0644
changelog.cpython-36.opt-1.pyc File 4.08 KB 0644
changelog.cpython-36.pyc File 4.08 KB 0644
config_manager.cpython-36.opt-1.pyc File 7.09 KB 0644
config_manager.cpython-36.pyc File 7.09 KB 0644
copr.cpython-36.opt-1.pyc File 20.2 KB 0644
copr.cpython-36.pyc File 20.2 KB 0644
debug.cpython-36.opt-1.pyc File 10.56 KB 0644
debug.cpython-36.pyc File 10.56 KB 0644
debuginfo-install.cpython-36.opt-1.pyc File 5.93 KB 0644
debuginfo-install.cpython-36.pyc File 5.93 KB 0644
download.cpython-36.opt-1.pyc File 9.29 KB 0644
download.cpython-36.pyc File 9.29 KB 0644
generate_completion_cache.cpython-36.opt-1.pyc File 3 KB 0644
generate_completion_cache.cpython-36.pyc File 3 KB 0644
groups_manager.cpython-36.opt-1.pyc File 8.45 KB 0644
groups_manager.cpython-36.pyc File 8.45 KB 0644
needs_restarting.cpython-36.opt-1.pyc File 9.88 KB 0644
needs_restarting.cpython-36.pyc File 9.88 KB 0644
repoclosure.cpython-36.opt-1.pyc File 4.31 KB 0644
repoclosure.cpython-36.pyc File 4.31 KB 0644
repodiff.cpython-36.opt-1.pyc File 7.55 KB 0644
repodiff.cpython-36.pyc File 7.55 KB 0644
repograph.cpython-36.opt-1.pyc File 2.72 KB 0644
repograph.cpython-36.pyc File 2.72 KB 0644
repomanage.cpython-36.opt-1.pyc File 6.37 KB 0644
repomanage.cpython-36.pyc File 6.37 KB 0644
reposync.cpython-36.opt-1.pyc File 10.19 KB 0644
reposync.cpython-36.pyc File 10.19 KB 0644
spacewalk.cpython-36.opt-1.pyc File 9.79 KB 0644
spacewalk.cpython-36.pyc File 9.79 KB 0644
system_upgrade.cpython-36.opt-1.pyc File 22.48 KB 0644
system_upgrade.cpython-36.pyc File 22.48 KB 0644
universal_hooks.cpython-36.opt-1.pyc File 5.86 KB 0644
universal_hooks.cpython-36.pyc File 5.86 KB 0644