Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/galaxy/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/galaxy/api.pyo

�
�Udac@`s�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZddlmZddlmZddlmZddlmZmZmZdd	lmZmZm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ydd
l'mZWn!e(k
r_dd
lmZnXe$�Z)d�Z*d�Z+defd��YZ,ddd��YZ-ddd��YZ.dS(i(tabsolute_importtdivisiontprint_functionN(tcontextt	constants(tAnsibleError(t
user_agent(tstring_types(t	HTTPError(tquotet	urlencodeturlparse(tto_bytest	to_nativetto_text(topen_url(tDisplay(t
secure_hash_s(Rc`s�fd�}|S(s�
    Wrapper to lazily initialize connection info to Galaxy and verify the API versions required are available on the
    endpoint.

    :param versions: A list of API versions that the function supports.
    c`s��fd�}|S(Nc
	`sN|js�tjd|j�|j}d|j|f}|jdksW|jdkr`d}ny|j|ddd|�}Wn�tttt	fk
r#}|j
d	�s�|j
d
�r��nt|d
�}y|j|ddd|�}Wq$tk
r}|jdkr|�n�q$XnXd|krLtd
||jf��n||_|j
didd6�}t|j��dgkr�d|d<n||_tjddj|j��|j|jf�nt|jj��}t��j|�}	|	s>td�jdj��dj|�|j|jf��n�|||�S(Ns'Initial connection to galaxy_server: %ss6Error when finding available api versions from %s (%s)shttps://galaxy.ansible.comshttps://galaxy.ansible.com/shttps://galaxy.ansible.com/api/tmethodtGETterror_context_msgs/apis/api/i�tavailable_versionssSTried to find galaxy API root at %s but no 'available_versions' are available on %suv1/uv1uv2/uv2s1Found API version '%s' with Galaxy server %s (%s)s, sPGalaxy action %s requires API versions '%s' but only '%s' are available on %s %s(t_available_api_versionstdisplaytvvvvt
api_servertnamet_call_galaxyRtGalaxyErrort
ValueErrortKeyErrortendswitht_urljoint	http_codetgettlisttkeystjointsettintersectiont__name__(
tselftargstkwargstn_urlRtdataterrtnew_errRtcommon_versions(Rtversions(s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytwrapped+sF					
		)((RR2(R1(Rs6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyt	decorator*s8((R1R3((R1s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyt	g_connect#s:cG`sdjd�|dD��S(Nt/cs`s0|]&}|rt|dd�jd�VqdS(terrorstsurrogate_or_strictR5N(R
tstrip(t.0ta((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pys	<genexpr>hst(R;(R%(R*((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyR gsRcB`seZdZd�ZRS(s( Error for bad Galaxy server responses. cC`s�tt|�j|�|j|_|j�|_y%t|j��}t	j
|�}Wnttfk
rui}nX|jj
d�}d|kr�|jd|j�}|jdd�}d||j||f}n�d|kr�|jdg�}	|	sig}	ng}
xm|	D]e}|jd	�p>|jd
�p>|j}|jd�pSd}
d|j||
f}|
j|�qWd|d
j|
�f}n+|jd|j�}d||j|f}t|�|_dS(NR5tv2tmessagetcodetUnknownu(%s (HTTP Code: %d, Message: %s Code: %s)tv3R6tdetailttitleu%(HTTP Code: %d, Message: %s Code: %s)s%s %ss, tdefaultu%s (HTTP Code: %d, Message: %s)(tsuperRt__init__R>R!tgeturlturlRtreadtjsontloadstAttributeErrorRtsplitR"treasontappendR%R
R=(R)t
http_errorR=thttp_msgterr_infot	url_splitt
galaxy_msgR>tfull_error_msgR6t
message_linesterrort	error_msgt
error_codetmessage_line((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyREns6

'(R(t
__module__t__doc__RE(((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyRkstCollectionVersionMetadatacB`seZd�ZRS(cC`s:||_||_||_||_||_||_dS(s>
        Contains common information about a collection on a Galaxy server to smooth through API differences for
        Collection and define a standard meta info for a collection.

        :param namespace: The namespace name.
        :param name: The collection name.
        :param version: The version that the metadata refers to.
        :param download_url: The URL to download the collection.
        :param artifact_sha256: The SHA256 of the collection artifact for later verification.
        :param dependencies: A dict of dependencies of the collection.
        N(t	namespaceRtversiontdownload_urltartifact_sha256tdependencies(R)R]RR^R_R`Ra((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyRE�s					(R(RZRE(((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyR\�st	GalaxyAPIcB`s�eZdZdddd�Zeedddg�d���Zdddedd�Z	ded�Z
edg�d��Zedg�ddd	��Zedg�dddd
��Z
edg�ed��Zedg�d��Zedg�d
��Zedg�d��Zedg�d��Zedg�d��Zedg�d��Zedg�d��Zeddg�d��Zeddg�dd��Zeddg�d��Zeddg�d��ZRS(sM This class is meant to be used as a API client for an Ansible Galaxy server cC`sq||_||_||_||_||_||_tjd|_i|_	t
jd|j|jf�dS(Ntignore_certss$Validate TLS certificates for %s: %s(tgalaxyRtusernametpasswordttokenRRtCLIARGStvalidate_certsRRtdebug(R)RdRRGReRfRg((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyRE�s							tv1R<R@cC`s|jS(N(R(R)((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytavailable_api_versions�scC`s.|p	i}|j||d|�yWtjd|�tt|�d|d|jd|d|ddd	t�d
d�}WnPtk
r�}t||��n/t	k
r�}t
d|t|�f��nXt|j�d
d�}	yt
j|	�}
Wn0tk
r)t
d|jt|	�f��nX|
S(NtrequiredsCalling Galaxy at %sR-RitheadersRttimeoutit
http_agenttfollow_redirectstsafes8Unknown error when attempting to call Galaxy at '%s': %sR6R7s5Failed to parse Galaxy response from '%s' as JSON:
%s(t_add_auth_tokenRRRR
RiRRRt	ExceptionRRRHRIRJRRG(R)RGR*RnRt
auth_requiredRtresptet	resp_dataR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyR�s"$" 
cC`sgd|krdS|jrA|rAtdjttj����n|jrc|j|jj��ndS(Nt
AuthorizationsMNo access token or username set. A token can be set with --api-key or at {0}.(RgRtformatR
tCtGALAXY_TOKEN_PATHtupdateRn(R)RnRGt
token_typeRm((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyRs�s		c
C`s�t|j|jdd�d}ti|d6�}t|d|d|jddd	t��}tjt	|j
�d
d��}|S(s2
        Retrieve an authentication token
        RkttokensR5tgithub_tokenR-RiRtPOSTRpR6R7(R RRlR
RRiRRIRJRRH(R)R�RGR*RvR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytauthenticate�s
 *!cC`s�t|j|jdd�d}i|d6|d6|r=|ndd6}|rZ||d<n*|jd	�r�|td	�d
|d<n|j|dt|�dd
�}|jdd�r�|dS|S(s(
        Post an import request
        RktimportsR5tgithub_usertgithub_repoR;tgithub_referencetalternate_role_namesansible-roleiR*RR�tresultsN(	R RRlt
startswithtlenRR
R"tNone(R)R�R�t	referencet	role_nameRGR*R-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytcreate_import_task�s 
!cC`s�t|j|jdd�}|dk	r;d||f}n:|dk	ri|dk	rid|||f}ntd��|j|�}|dS(s5
        Check the status of an import task.
        RkR�s%s?id=%ds %s?github_user=%s&github_repo=%ss/Expected task_id or github_user and github_repoR�N(R RRlR�RR(R)ttask_idR�R�RGR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytget_import_task�scC`s�ttt|���}yS|jd�}dj|dd!�}|d}|rjtjd||f�nWn!tk
r�td|��nXt|j	|j
ddd||f�}|j|�}t|d	�dkr�|d	dSd
S(s&
        Find a role by name.
        t.ii����s$- downloading role '%s', owned by %ssAInvalid role name (%s). Specify role as format: username.rolenameRktroless?owner__username=%s&name=%sR�N(RturlquoteRRLR%RRtRR RRlRR�R�(R)R�tnotifytpartst	user_nameRGR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytlookup_role_by_names

c
C`sg}y�t|j|jdd||d�}|j|�}|d}|jdd�dk}t|j�}d|j|jf}xR|s�t||d�}|j|�}||d7}|jdd�dk}q�WWn3t	k
r}	t
jd||t|	�f�nX|S(	s�
        Fetch the list of related items for the given role.
        The url comes from the 'related' field of the role.
        RkR�s
?page_size=50R�t	next_links%s://%s/sSUnable to retrieve role (id=%s) data (%s), but this is not fatal so we continue: %sN(
R RRlRR"R�RtschemetnetlocRtRtwarningR(
R)trelatedtrole_idR�RGR-tdoneturl_infotbase_urlRw((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytfetch_role_related&s$	
	 	cC`sy�t|j|jd|d�}|j|�}d|krJ|d}n|}t}d|kr}|jdd�dk}nxU|s�t|j|d�}|j|�}||d7}|jdd�dk}q�W|SWn/tk
r}td|t	|�f��nXdS(s4
        Fetch the list of items specified.
        Rks
?page_sizeR�tnextR�s"Failed to download the %s list: %sN(
R RRlRtTrueR"R�RtRR
(R)twhatRGR-R�R�RV((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytget_listDs"
	c	K`sPt|j|jdddd�}|rK|dttt|���7}n|jdd�}|jdd�}|jdd�}|jd	d�}|r�t|t	�r�|j
d
�}|ddj|�7}n|rt|t	�r|j
d
�}|d
dj|�7}n|r&|d|7}n|r=|d|7}n|j|�}|S(NRktsearchR�t?s&autocomplete=ttagst	platformst	page_sizetauthort,s&tags_autocomplete=t+s&platforms_autocomplete=s
&page_size=%ss&username_autocomplete=%s(
R RRlRR�RR"R�t
isinstanceRRLR%R(	R)R�R+t
search_urlR�R�R�R�R-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytsearch_roles\s&"#cC`sgt|j|jdd�d}ti|d6|d6|d6|d6�}|j|d|d	d
�}|S(NRktnotification_secretsR5tsourceR�R�tsecretR*RR�(R RRlR
R(R)R�R�R�R�RGR*R-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyt
add_secretzs 
cC`s5t|j|jdd�}|j|dt�}|S(NRkR�Ru(R RRlRR�(R)RGR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytlist_secrets�scC`sBt|j|jdd|�d}|j|dtdd�}|S(NRkR�R5RuRtDELETE(R RRlRR�(R)t	secret_idRGR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyt
remove_secret�s#cC`sHt|j|jddd||f�}|j|dtdd�}|S(NRkt
removeroles?github_user=%s&github_repo=%sRuRR�(R RRlRR�(R)R�R�RGR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytdelete_role�scC`s�tjd||j|jf�t|dd�}tjj|�s]tdt|���n(t	j
|�s�tdt|���nt|d��}|j�}WdQXdt
j�j}tjj|�}d	t|dd�}|d
dtt|dtj�dd�|d
|dd|d|g
}dj|�}id|d6t|�d6}	d|jkr�t|j|jddd�d}
n t|j|jdd�d}
|j|
d|d|	dddtdd|j|jf�}|d S(!s�
        Publishes a collection to a Galaxy server and returns the import task URI.

        :param collection_path: The path to the collection tarball to publish.
        :return: The import task URI that contains the import results.
        s,Publishing collection artifact '%s' to %s %sR6R7s2The collection path specified '%s' does not exist.sThe collection path specified '%s' is not a tarball, use 'ansible-galaxy collection build' to create a proper release artifact.trbNs--------------------------%ss--s-Content-Disposition: form-data; name="sha256"R;t	hash_funcs5Content-Disposition: file; name="file"; filename="%s"s&Content-Type: application/octet-streams%s--s
s multipart/form-data; boundary=%ssContent-typesContent-lengthR@t	artifactstcollectionsR5R<R*RnRR�RuRs+Error when publishing collection to %s (%s)ttask(RRRRtostpathtexistsRR
ttarfilet
is_tarfiletopenRHtuuidtuuid4thextbasenameRthashlibtsha256R%R�RlR RR�(R)tcollection_pathtb_collection_pathtcollection_tarR-tboundarytb_file_namet
part_boundarytformRnR,Rv((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytpublish_collection�sB 
& $ic
C`sFd}d#}d|jkr@t|j|jdd|d�}n"t|j|jdd|d�}tjd|�tj�}d}x�|d	ks�tj�||kr1|j|d
ddtd
d|�}|jdd�}|jdd#�r�Pntj	d||f�tj
|�td|d�}q�W|dkrWtdt
|���nx�|jdg�D]s}|d}	|	dkr�tjd|d�qj|	dkr�tjd|d�qjtj	d|	|df�qjW|dkrBt
|djdd��}
t
|djd d!|��}td"||
f��nd#S($sH
        Waits until the import process on the Galaxy server has completed or the timeout is reached.

        :param task_id: The id of the import task to wait for. This can be parsed out of the return
            value for GalaxyAPI.publish_collection.
        :param timeout: The timeout in seconds, 0 is no timeout.
        twaitingR@simports/collectionsR5R<scollection-importss1Waiting until Galaxy import task %s has completediiRRRuRs,Error when getting import task results at %ststatetfinished_atsMGalaxy import process has a status of %s, wait %d seconds before trying againig�?sUTimeout while waiting for the Galaxy import process to finish, check progress at '%s'tmessagestlevelRVsGalaxy import error message: %sR=R�s!Galaxy import warning message: %ssGalaxy import message: %s - %stfailedR>tUNKNOWNtdescriptions&Unknown error, see %s for more detailss+Galaxy import process failed: %s (Code: %s)N(R�RlR RRttimeRR�R"tvvvtsleeptminRR
RVR�(R)R�RoR�R-tfull_urltstarttwaitR=R�R>R�((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytwait_import_task�sF	%
	

c	C`s�|jjd|jjd��}|j|d||d|dg}t|�}d||||j|jf}|j|d|�}t|dd	|d
d	|d|d|d
d|dd�S(s}
        Gets the collection information from the Galaxy server about a specific Collection version.

        :param namespace: The collection namespace.
        :param name: The collection name.
        :param version: Optional version of the collection to get the information for.
        :return: CollectionVersionMetadata about the collection at the version requested.
        R@R<R�R1R5sHError when getting collection version metadata for %s.%s:%s from %s (%s)RR]Rt
collectionR^R_tartifactR�tmetadataRa(RlR"RR RRR\(	R)R]RR^tapi_patht	url_pathstn_collection_urlRR-((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytget_collection_version_metadata
s
!! cC`s_t}d|jkr=|jd}d}ddg}t}n|jd}d}dg}t|j|d||dd	�}d
|||j|jf}|j|d|�}	g}
x�trZ|
g|	|D]}|d^q�7}
|	}x |D]}
|j|
i�}q�W|sPn$|r6|jt	|�j
|�}n|jt|d
d�d|�}	q�W|
S(s�
        Gets a list of available versions for a collection on a Galaxy server.

        :param namespace: The collection namespace.
        :param name: The collection name.
        :return: A list of versions that are available.
        R@R-tlinksR�R<R�R�R1R5sGError when getting available collection versions for %s.%s from %s (%s)RR^R6R7(tFalseRlR�R RRRR"treplaceRR�R
(R)R]Rt
relative_linkR�tresults_keytpagination_pathR,RR-R1tvR�R�((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pytget_collection_versions s4	
	
	!	%

N(R(RZR[R�REtpropertyR4RlR�RRsR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyRb�s2!	59(((/t
__future__RRRttypet
__metaclass__R�RIR�R�R�R�tansibleRRR{tansible.errorsRtansible.galaxy.user_agentRtansible.module_utils.sixRt+ansible.module_utils.six.moves.urllib.errorRt+ansible.module_utils.six.moves.urllib.parseR	R�R
Rtansible.module_utils._textRR
Rtansible.module_utils.urlsRtansible.utils.displayRtansible.utils.hashingRturllib.parsetImportErrorRR4R RR\Rb(((s6/usr/lib/python2.7/site-packages/ansible/galaxy/api.pyt<module>s6
		D	(

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