Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/dnf-plugins/
Upload File :
Current File : //lib/python2.7/site-packages/dnf-plugins/copr.pyo

�
	i/\c@s�ddlmZddlmZddlmZmZddlmZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlmZmZWnKek
r
d�ZyddlmZWnek
r	d	�ZnXnXd
Zeed�ed�g�Zeed
�ed�dg�ZerxddlmZmZmZnddlmZmZmZe	jjde	j j!fd��Y�Z"e	jjde"fd��Y�Z#dS(i����(tprint_function(tPY3(t_tlogger(tucdN(tlinux_distributiontos_release_attrcCsdS(Nt((R((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR(s(RcCsptd��^}i}x9|D]1}|jjd�\}}|jd�||<qW|d|ddfSWdQXdS(Ns/etc/os-releaset=t"tNAMEt
VERSION_ID(topentrstriptsplittstriptNone(tos_release_filetos_release_datatlinetos_release_keytos_release_value((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR.s
tcoprtyestytnotnR(tConfigParsert
NoOptionErrortNoSectionErrortCoprCommandcBs*eZdZdZdZdZdZdZedeZ	dZ
ed�Zed�Z
ed	��Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zed��Zed��Zdd�Zd�Zd�Zd�Zed��Z ed��Z!ed��Z"RS(s Copr plugin for DNF scopr.fedorainfracloud.orgtfedorathttpsi�s://Rs Interact with Copr repositories.s�
  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
    cCs�|jddddddddd	d
g�|j�}|jddd
dtd��|jddd
dtd��|jddd
dtd��|jddddtd��|jddtd��|jddd�dS(Nt
subcommandtnargsitchoicesthelptenabletdisabletremovetlisttsearchs--installedtactiont
store_trues.List all installed Copr repositories (default)s	--enabledsList enabled Copr repositoriess
--disabledsList disabled Copr repositoriess--available-by-usertmetavarR
s-List available Copr repositories by user NAMEs--hubs(Specify an instance of Copr to work withtargt*(tadd_argumenttadd_mutually_exclusive_groupR(tparsertlist_option((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt
set_argparser_s	



c	Cs=d}t�}g}|jjjd}tjj|td�}tjj	|�r�|j
|�|j|�|jdd�r�|jdd�r�|j
dd�}|j
dd�}||g|_q�ttg|_nxetjtjj|td��D]A}|jd�r�tjj|td|�}	|j
|	�q�q�Wg}
t|jj�ru|jjdjd�}
nt|
�dkr�|jjr�tjtd	�td
��tjjtd���ne|jjrt|
�dkr|j|_|j|_ n+t|
�dkr$|
d}n|jj}|r|rd|_ |jt!|dt"��|j#||d
d�}|r|j#||d|j$�}|j#||d|j%�}
||_|d||_ t&|
�|j%kr
|j d|
7_ |jd|
7_q
qn|j s9||_|j$d||_ ndS(Nis.conftmaintdistributiont
releasevers.dt/isError: s^specify Copr hub either with `--hub` or using `copr_hub/copr_username/copr_projectname` formatsmultiple hubs specifiedtreversethostnametprotocoltports://t:('RRtbasetconftpluginconfpathtostpathtjointPLUGIN_CONFtisfiletappendtreadt
has_optiontgett
chroot_configtFalsetlistdirtendswithtlentoptsR-RthubRtcriticalRtdnftclitCliErrortdefault_hostnamet
copr_hostnametdefault_urltcopr_urltsortedtTruet_read_config_itemtdefault_protocoltdefault_porttint(tselftcopr_hubtcopr_plugin_configtconfig_filestconfig_pathtdefault_config_fileR5R6tfilenametconfig_filetprojectR9R:R;((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt	configuressb	

)	
				cCs3y|j||�SWnttfk
r.|SXdS(N(RHRR(R^tconfigROtsectiontdefault((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRZ�sc	CsF|jjd}|dkr3|jjj|�dS|dkr�|jjrb|j|jj�dS|j|jj	j
d|jj|jj�dSny|jj
d}Wn_ttfk
r
tjtd�td��|jjj|�tjjtd���nXy|jj
d}Wn#tk
rD|j|j�}nX|dkrb|j|�dS|jd�}t|�dkr�tjtd�td��tjjtd���nKt|�d	kr�|d}|d}n"|d}|d	}|d|}d
j|jj	j|j|j|�|�}|dkr�|j�tdjdj|j||g���}|j |�|j!|||�tj"td��n�|dkr�|j�|j#||�tj"td��n]|dkr!|j�|j$||�tj"td��n!tj%j&td�j|���dS(NiR$R(sError: s>exactly two additional parameters to copr command are requirediR)R7iisEuse format `copr_username/copr_projectname` to reference copr projectsbad copr project formats{0}/_copr:{1}:{2}:{3}.repoR%sC
You are about to enable 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.

Do you really want to enable {0}?s Repository successfully enabled.R&s!Repository successfully disabled.R's Repository successfully removed.sUnknown subcommand {}.(ii('RNR!RRt	optparsert
print_helptavailable_by_usert_list_user_projectst_list_installed_repositoriesR=R>treposdirtenabledtdisabledR-t
ValueErrort
IndexErrorRRPRRQRSt
_guess_chrootRIt_searchRRMtformattget_reposdirRUt_sanitize_usernamet
_need_rootRBt	_ask_usert_download_repotinfot
_disable_repot_remove_repot
exceptionstError(	R^R!tproject_nametchrootRft
copr_usernametcopr_projectnamet
repo_filenametmsg((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pytrun�sx		

	







	cCs�|jjd�d}tjd|j|�}|j|jkoPtjd|�}tjd|�}|jjr�|r�|r�dSn
|s�dS|j	}	|	r�|s�|	r�|r�dSt
}
tjd|�r|jdd�}|d	jdd
�d
}|d|d
d|d}
n�tjd|�r�|jdd
�}|jdd�d	jdd
�d
}|d|d	d|d
}
n9|jdd
�}|jd|d	d|d
}
t
}
|	s�|
d7}
n|
r�|
d
7}
nt|
�|
S(NR7i����s_copr:t_copr_s_copr:|^_copr_scopr:R<iiit-s (disabled)s *(trepofileRtretmatchRURWRVRNRORqRJtrsplitRTRYtprint(R^trepo_idtrepotenabled_onlyt
disabled_onlyt	file_namet	match_newt	match_oldt	match_anyRqtold_repot	copr_nameRUR�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt_list_repo_files<$	!&!!


cCsgt}xA|jjj�D]-\}}|j||||�rt}qqW|rcttd��ndS(Ns�* 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.(RJR=trepostitemsR�RYR�R(R^t	directoryR�R�R�R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRo>s
c	CsIdj|�}|jj|j|dd�}ytj|j��}Wn2tk
r{tj	j
td�j|���nX|j|�td�j|�}|j
|�d}x�|t|d�krDdj||d|d	�}|d|d
}|std�}n|jjjt|�|�}t|�|d7}q�WdS(
Ns/api/coprs/{}/tmodesw+s+Can't parse repositories for username '{}'.sList of {} coprsiR�s
{0}/{1} : tnametdescriptionsNo description giveni(RwR=turlopenRWtjsontloadsRFRsRQR�R�Rt_check_json_outputt_print_match_sectionRMtoutputt
fmtKeyValFillRR�(	R^t	user_nametapi_pathtrest
json_parsetsection_texttiR�tdesc((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRnHs*
	

	
c	CsUdj|�}|jj|j|dd�}ytj|j��}Wn2tk
r{tj	j
td�j|���nX|j|�td�j|�}|j
|�d}x�|t|d�krPdj|d|d	|d|d
�}|d|d}|std�}n|jjjt|�|�}t|�|d
7}q�WdS(Ns/api/coprs/search/{}/R�sw+sCan't parse search for '{}'.sMatched: {}iR�s
{0}/{1} : tusernametcoprnameR�sNo description given.i(RwR=R�RWR�R�RFRsRQR�R�RR�R�RMR�R�RR�(	R^tqueryR�R�R�R�R�R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRv`s(



cCs#|jjj|�}t|�dS(N(R=R�t
fmtSectionR�(R^ttextt	formatted((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR�wscCsq|jj�rm|jjjsO|jjjddj|�ddj|��rmtjj	t
d���qmndS(NR�s
{} [y/N]: tdefaultyes_msgs
{} [Y/n]: sSafe and good answer. Exiting.(R=t
_promptWantedR>tassumenoR�tuserconfirmRwRQR�R�R(R^R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR{{s"cCs1tj�dkr-tjjtd���ndS(Nis/This command has to be run under the root user.(R@tgeteuidRQR�R�R(tcls((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRz�s	cCsV|}|dks2|dtks2|dtkr>t�}nd|kr�d|kr_d}qRdtd�krzd}qRdj|d�}n�d	|kr�tjd
�}d|kr�dj|�}qRd
j|d|�}npd|kr4tjd�}d|krdj|�}qRdj|d|�}nd|djdd�d}|S(s2 Guess which chroot is equivalent to this machine iitFedoratRawhidesfedora-rawhide-x86_64trawhidetredhat_support_product_versionsfedora-{}-x86_64tMageias%{distro_arch}tCauldronsmageia-cauldron-{}smageia-{0}-{1}topenSUSEs%{_target_cpu}t
Tumbleweedsopensuse-tumbleweed-{}sopensuse-leap-{0}-{1}sepel-%s-x86_64t.N(RRJRRRwtrpmtexpandMacroR(RItdistR�tdistarch((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRu�s*,		c
Cs�|dkr!|j|j�}ndj|jd�d �}dj||�}y#|jj|j|dd�}Wn.t	k
r�}t
jj|�r�t
j
|�ndt|�kr�tr"ddl}y-|jj|jd|�}	|	j�}
WqT|jjk
r}|j�}
qTXn2ddl}|j|jd|�}	|	j�}
t|
�dkr�tjjtd	���q�tjjtd
���n�nXxQ|D]I}tjd|�r�t
jj|jjjd|d
d!d�}nPq�W|j|jkry|jddd
�j|j d�jddd
�jdd�jdd�}t
jj|�ryt
j
|�qynt!j"|j#|�t
j$|t%j&t%j'Bt%j(Bt%j)B�dS(NR�is/coprs/{0}/repo/{1}/R�sw+t404i����s/coprs/sIThis repository does not have any builds yet so you cannot enable it now.sSuch repository does not exist.s\[copr:Rii����s.repos_copr:t_coprRR<tgroup_t@(*RRuRIRBRRwR=R�RWtIOErrorR@RAtexistsR'tstrRturllib.requesttrequesttgetcodeterrort	HTTPErrorturllibRQR�R�RR�R�R>RxRVtreplaceRUtshutiltcopy2R�tchmodtstattS_IRUSRtS_IWUSRtS_IRGRPtS_IROTH(
R^R�R�R�tshort_chrootR�tfteR�R�tstatus_codeRtold_repo_filename((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR|�sJ#
*cCsdj|j|j|�|�}||jjkr�dj|j|�|�}}||jjkr�d|jj|jkr�|jj|jjd�d}y=|jdd�djdd	�d	}||jkr�dSWq�t	k
r�q�Xq�dSn|jj|S(
Nscopr:{0}:{1}:{2}s{0}-{1}R�R7i����R<iii(
RwRURyR=R�R�RR�RRt(R^R�R�R�R�RU((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt_get_copr_repo�s 	
+ &
cCs�|j||�}|sEtjjtdj|j||����nytj|j	�Wn+t
k
r�}tjjt|���nXdS(Ns&Failed to remove copr repo {0}/{1}/{2}(R�RQR�R�RRwRUR@R'R�tOSErrorR�(R^R�R�R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR�s		cCs{|j||�}|dkrEtjjtdj||����n|jjj	|j
|j|jjjidd6�dS(Ns!Failed to disable copr repo {}/{}iRq(
R�RRQR�R�RRwR=R>twrite_raw_configfileR�tidt
substitutions(R^R�R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR~s		cCsHytj|j��}Wn(tk
rCtjjtd��dSX|S(s� Wrapper around response from server

        check data and print nice error in case of some error (and return None)
        otherwise return json object.
        sUnknown response from server.N(R�R�RFRsRQRRRSR(R�R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt	_get_datas
cCs6|ddkr2tjjdj|d���ndS(NR�toks{}R�(RQR�R�Rw(R�tjson_obj((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR�scCs)|ddkr!dj|d�S|SdS(NiR�sgroup_{}i(Rw(R�R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyRysN(R(#t__name__t
__module__t__doc__RRIRTtdefault_hubR[R\RVtaliasesRtsummarytusagetstaticmethodR3RgRZR�R�RoRnRvR�R{tclassmethodRzRuR|R�RR~R�R�Ry(((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR@s<		F		V	)	
				&1			
tPlaygroundCommandcBsPeZdZdZed�ZdZd�Zd�Ze	d��Z
d�ZRS(	s Playground plugin for DNF t
playgrounds$Interact with Playground repository.s [enable|disable|upgrade]c
Cs�|j�td�}|j|�dj|j�}|jj|dd�}|j|�}|j�|ddkr�t	j
jtd���nx|dD]�}d	j|d
|d�}dj|jjj
|jd
d��}y�||dkr�w�ndj|j||�}|jj|dd�}|j|�}	|j�|	r}d|	kr}|	ddkr}|j|||�nWq�t	jjk
r�q�Xq�WdS(NsK
You are about to enable a Playground repository.

Do you want to continue?s{0}/api/playground/list/R�sw+R�R�sUnknown response from server.R�s{0}/{1}R�R�s{}/_playground_{}.repoR7R�tchrootss{0}/api/coprs/{1}/detail/{2}/(RzRR{RwRWR=R�R�tcloseRQRRRSR>RxR�R|R�R�(
R^R�R�tapi_urlR�R�R�R�R�toutput2((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt_cmd_enable.s8
	



'
cCsG|j�x6tjdj|jjj��D]}|j|�q,WdS(Ns{}/_playground_*.repo(RztglobRwR=R>RxR(R^R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt_cmd_disableOs
(cCs&|jdddddddg�dS(NR!R"iR#R%R&tupgrade(R/(R1((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR3TscCs�|jjd}|j|j�}|dkrQ|j|�tjtd��n�|dkr}|j�tjtd��nZ|dkr�|j�|j|�tjtd��n!t	j
jtd�j|���dS(	NiR%s-Playground repositories successfully enabled.R&s.Playground repositories successfully disabled.R�s-Playground repositories successfully updated.sUnknown subcommand {}.(
RNR!RuRIR�RR}RR�RQR�R�Rw(R^R!R�((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR�Ys



	(R�(R�R�R�R�RR�R�R�R�R�R3R�(((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyR�&s	!	($t
__future__Rt
dnf.pycompRtdnfpluginscoreRRtdnf.i18nRRQR�R�R@R�R�R�R�tdistroRRtImportErrortplatformRCtsettYEStNOtconfigparserRRRtplugintregister_commandRRtCommandRR�(((s4/usr/lib/python2.7/site-packages/dnf-plugins/copr.pyt<module>s<
	
!��

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]