%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/artifactory.pyc

�
���^c@@sDdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
ddlmZmZddlmZyddlmZeZWnek
r�eZnXeje�ZdZd	�Zd
dddded�Z dd
dddded�Z!d
dddded
�Z"d
dddded�Z#dd�Z$ddded�Z%ded�Z&ed�Z'ed�Z(ed�Z)ed�Z*ed�Z+d�Z,ed�Z-ed�Z.d�Z/ed�Z0d�Z1d�Z2d�Z3dd �Z4d!e5fd"��YZ6dS(#u0
Module for fetching artifacts from Artifactory
i(tabsolute_importtprint_functiontunicode_literalsN(turllib(t	HTTPErrortURLError(tCommandExecutionError(tElementTreeuartifactorycC@s!tstdjt�fStSdS(u<
    Only load if elementtree xml library is available.
    u7Cannot load {0} module: ElementTree library unavailableN(tHAS_ELEMENT_TREEtFalsetformatt__virtualname__tTrue(((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt__virtual__ su/tmpcC@s	tjd|||||||�i}|rk|	rkdjtjdj||	��jdd��|d<ntd|d|d	|d
|d|d|
�}|d
}
td|d|d	|d
|d|
d|d|d|d|
�	\}}t|||�}t	|||�S(ug
       Gets latest snapshot of the given artifact

       artifactory_url
           URL of artifactory instance
       repository
           Snapshot repository in artifactory to retrieve artifact from, for example: libs-snapshots
       group_id
           Group Id of the artifact
       artifact_id
           Artifact Id of the artifact
       packaging
           Packaging type (jar,war,ear,etc)
       target_dir
           Target directory to download artifact to (default: /tmp)
       target_file
           Target file to download artifact to (by default it is target_dir/artifact_id-snapshot_version.packaging)
       classifier
           Artifact classifier name (ex: sources,javadoc,etc). Optional parameter.
       username
           Artifactory username. Optional parameter.
       password
           Artifactory password. Optional parameter.
       u�======================== MODULE FUNCTION: artifactory.get_latest_snapshot, artifactory_url=%s, repository=%s, group_id=%s, artifact_id=%s, packaging=%s, target_dir=%s, classifier=%s)u	Basic {0}u{0}:{1}u
uu
Authorizationtartifactory_urlt
repositorytgroup_idtartifact_idtheaderstuse_literal_group_idulatest_versiontversiont	packagingt
classifier(
tlogtdebugR
tbase64tencodestringtreplacet_get_artifact_metadatat_get_snapshot_urlt__resolve_target_filet__save_artifact(RRRRRt
target_dirttarget_fileRtusernametpasswordRRtartifact_metadataRtsnapshot_urlt	file_name((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pytget_latest_snapshot*s	7-
Ec
C@s�tjd||||||||	�	i}
|
rn|rndjtjdj|
|��jdd��|
d<ntd|d|d	|d
|d|d|d
|d|	d|
d|�
\}}t|||�}t|||
�S(u�
       Gets snapshot of the desired version of the artifact

       artifactory_url
           URL of artifactory instance
       repository
           Snapshot repository in artifactory to retrieve artifact from, for example: libs-snapshots
       group_id
           Group Id of the artifact
       artifact_id
           Artifact Id of the artifact
       packaging
           Packaging type (jar,war,ear,etc)
       version
           Version of the artifact
       target_dir
           Target directory to download artifact to (default: /tmp)
       target_file
           Target file to download artifact to (by default it is target_dir/artifact_id-snapshot_version.packaging)
       classifier
           Artifact classifier name (ex: sources,javadoc,etc). Optional parameter.
       username
           Artifactory username. Optional parameter.
       password
           Artifactory password. Optional parameter.
       u�======================== MODULE FUNCTION: artifactory.get_snapshot(artifactory_url=%s, repository=%s, group_id=%s, artifact_id=%s, packaging=%s, version=%s, target_dir=%s, classifier=%s)u	Basic {0}u{0}:{1}u
uu
AuthorizationRRRRRRtsnapshot_versionRRR(	RRR
RRRRRR(RRRRRRR(R R!RR"R#RRR%R&((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pytget_snapshotQs	7KcC@s�tjd|||||||�i}|rk|	rkdjtjdj||	��jdd��|d<ntd|d|d	|d
|d|�}t||||||||
�\}
}t|||�}t	|
||�S(uY
       Gets the latest release of the artifact

       artifactory_url
           URL of artifactory instance
       repository
           Release repository in artifactory to retrieve artifact from, for example: libs-releases
       group_id
           Group Id of the artifact
       artifact_id
           Artifact Id of the artifact
       packaging
           Packaging type (jar,war,ear,etc)
       target_dir
           Target directory to download artifact to (default: /tmp)
       target_file
           Target file to download artifact to (by default it is target_dir/artifact_id-version.packaging)
       classifier
           Artifact classifier name (ex: sources,javadoc,etc). Optional parameter.
       username
           Artifactory username. Optional parameter.
       password
           Artifactory password. Optional parameter.
       u�======================== MODULE FUNCTION: artifactory.get_latest_release(artifactory_url=%s, repository=%s, group_id=%s, artifact_id=%s, packaging=%s, target_dir=%s, classifier=%s)u	Basic {0}u{0}:{1}u
uu
AuthorizationRRRRR(
RRR
RRRt__find_latest_versiont_get_release_urlRR(RRRRRR R!RR"R#RRRtrelease_urlR&((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pytget_latest_releasews	7''c
C@s�tjd||||||||�	i}|	rn|
rndjtjdj|	|
��jdd��|d<nt||||||||�\}
}t|||�}t|
||�S(u�
       Gets the specified release of the artifact

       artifactory_url
           URL of artifactory instance
       repository
           Release repository in artifactory to retrieve artifact from, for example: libs-releases
       group_id
           Group Id of the artifact
       artifact_id
           Artifact Id of the artifact
       packaging
           Packaging type (jar,war,ear,etc)
       version
           Version of the artifact
       target_dir
           Target directory to download artifact to (default: /tmp)
       target_file
           Target file to download artifact to (by default it is target_dir/artifact_id-version.packaging)
       classifier
           Artifact classifier name (ex: sources,javadoc,etc). Optional parameter.
       username
           Artifactory username. Optional parameter.
       password
           Artifactory password. Optional parameter.
       u�======================== MODULE FUNCTION: artifactory.get_release(artifactory_url=%s, repository=%s, group_id=%s, artifact_id=%s, packaging=%s, version=%s, target_dir=%s, classifier=%s)u	Basic {0}u{0}:{1}u
uu
Authorization(	RRR
RRRR+RR(RRRRRRR R!RR"R#RRR,R&((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pytget_release�s	7'cC@s(|dkr$tjj||�}n|S(N(tNonetostpathtjoin(R&R R!((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR�sc
C@s�|dkri}n|dk	o*|dk}
|dkrqy	td|d|d|d|d|d|�}||dkr�d	jd|d|d|d|d
|d|d|�}t|��n|
s�|n|d|}
|
r3|
|dkr3d
jd|d|d|d|d
|d|d|�}t|��n|d|
}Wqqtk
rm}tjd|�|}qqXnt||	�}djd|d|d
|dt|��}djd|d|d|d|d|d|�}tj	d|�||fS(NuRRRRRRusnapshot_versionsu�Cannot find requested packaging '{packaging}' in the snapshot version metadata.
                          artifactory_url: {artifactory_url}
                          repository: {repository}
                          group_id: {group_id}
                          artifact_id: {artifact_id}
                          packaging: {packaging}
                          classifier: {classifier}
                          version: {version}RRu:u�Cannot find requested classifier '{classifier}' in the snapshot version metadata.
                          artifactory_url: {artifactory_url}
                          repository: {repository}
                          group_id: {group_id}
                          artifact_id: {artifact_id}
                          packaging: {packaging}
                          classifier: {classifier}
                          version: {version}uACould not fetch maven-metadata.xml. Assuming snapshot_version=%s.u8{artifact_id}-{snapshot_version}{classifier}.{packaging}R(uN{artifactory_url}/{repository}/{group_url}/{artifact_id}/{version}/{file_name}t	group_urlR&usnapshot_url=%s(
R/t_get_snapshot_version_metadataR
tArtifactoryErrorRRterrort__get_group_id_subpatht__get_classifier_urlR(RRRRRRR(RRRthas_classifiertsnapshot_version_metadatat
error_messagetpackaging_with_classifierterrR3R&R%((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR�s\	-				
			c
C@s�t||�}djd|d|d|dt|��}	djd|d|d	|d|d|d
|	�}
tjd|
�|
|	fS(Nu/{artifact_id}-{version}{classifier}.{packaging}RRRRuN{artifactory_url}/{repository}/{group_url}/{artifact_id}/{version}/{file_name}RRR3R&urelease_url=%s(R7R
R8RR(RRRRRRRRR3R&R,((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR+s			c	C@sGt||�}djd|d|d|d|�}tjd|�|S(NuK{artifactory_url}/{repository}/{group_url}/{artifact_id}/maven-metadata.xmlRRR3Ruartifact_metadata_url=%s(R7R
RR(RRRRRR3tartifact_metadata_url((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt_get_artifact_metadata_url#s		cC@s�td|d|d|d|d|�}y4tjj|d|�}tjj|�j�}Wn7ttfk
r�}	dj	||	�}
t
|
��nXtjd|�|S(NRRRRRu.Could not fetch data from url: {0}. ERROR: {1}uartifact_metadata_xml=%s(
R?RtrequesttRequestR/turlopentreadRRR
RRR(RRRRRRR>R@tartifact_metadata_xmlR=tmessage((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt_get_artifact_metadata_xml/s 		c	
C@s�td|d|d|d|d|d|�}tj|�}||jd�jksZt�||jd�jksxt�|jd	�jd
�j}i|d6S(NRRRRRRugroupIdu
artifactIdu
versioningulatestulatest_version(RFtETt
fromstringtfindttexttAssertionError(	RRRRRRtmetadata_xmltroottlatest_version((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyRGs-cC@sMt||�}djd|d|d|d|d|�}tjd|�|S(NuU{artifactory_url}/{repository}/{group_url}/{artifact_id}/{version}/maven-metadata.xmlRRR3RRu snapshot_version_metadata_url=%s(R7R
RR(RRRRRRR3tsnapshot_version_metadata_url((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt"_get_snapshot_version_metadata_urlTs		c
C@s�td|d|d|d|d|d|�}y4tjj|d|�}tjj|�j�}	Wn7ttfk
r�}
dj	||
�}t
|��nXtjd|	�|	S(	NRRRRRRu.Could not fetch data from url: {0}. ERROR: {1}u snapshot_version_metadata_xml=%s(
RPRR@RAR/RBRCRRR
RRR(RRRRRRRROR@tsnapshot_version_metadata_xmlR=RE((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt"_get_snapshot_version_metadata_xmlas"		c
C@s:td|d|d|d|d|d|�}tj|�}||jd�jksZt�||jd�jksxt�||jd	�jks�t�|jd
�jd�}i}	xx|D]p}
|
jd�j}|
jd
�j}|
jd�dk	r!|
jd�j}
||	|d|
<q�||	|<q�Wi|	d6S(NRRRRRRugroupIdu
artifactIduversionu
versioningusnapshotVersionsu	extensionuvalueu
classifieru:usnapshot_versions(RRRGRHRIRJRKR/(RRRRRRRLtmetadatatsnapshot_versionstextension_version_dictR(t	extensiontvalueR((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR4zs -
c	C@sGt||�}djd|d|d|d|�}tjd|�|S(Nu[{artifactory_url}/api/search/latestVersion?g={group_url}&a={artifact_id}&repos={repository}RRR3Rulatest_version_url=%s(R7R
RR(RRRRRR3tlatest_version_url((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt__get_latest_version_url�s		cC@s�td|d|d|d|d|�}y4tjj|d|�}tjj|�j�}Wn7ttfk
r�}	dj	||	�}
t
|
��nXtjd|�|dks�|dkr�t
d	��n|S(
NRRRRRu.Could not fetch data from url: {0}. ERROR: {1}uResponse of: %suuUnable to find release version(RYRR@RAR/RBRCRRR
RRRR5(RRRRRRRXR@RR=RE((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR*�s$		c
C@s%tjd||�itd6id6dd6}tjj|�r"tjd|�|d}t||�\}}}|rtjd|�td	d
|dd�}tjd
||�||kr�t|d<||d<dj	||�|d<|Sdj	||�|d<q"t|d<||d<|Sntjd||�y�t
jj|d|�}	t
jj|	�}
tjjj|d��)}|jtjjj|
j���WdQXt|d<tdj	|�|d�|d<||dd<||d<Wn6ttfk
r }t|d<t||�|d<nX|S(Nu__save_artifact(%s, %s)ustatusuchangesuucommentu,File %s already exists, checking checksum...u.sha1uDownloaded SHA1 SUM: %su
file.get_hashR1tformusha1uTarget file (%s) SHA1 SUM: %sutarget_fileuMFile {0} already exists, checksum matches with Artifactory.
Checksum URL: {1}uTFile {0} already exists, checksum does not match with Artifactory!
Checksum URL: {1}uDownloading: %s -> %suwbu!Artifact downloaded from URL: {0}udownloaded_file(RRR	R0R1tisfilet
__downloadt__salt__RR
RR@RAR/RBtsalttutilstfilestfopentwritetstringutilstto_bytesRCt__append_commentRRt__get_error_comment(
tartifact_urlR!Rtresulttchecksum_urltchecksum_successtartifact_sumtchecksum_commenttfile_sumR@tft
local_filete((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR�sL





(
 
cC@s |s|jdd�}|S|S(Nu.u/(R(RRR3((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR7�scC@s*|dk	o|dk}|r&d|SdS(Nuu-(R/(RR9((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR8�scC@s�tjd|�t}d}d}y@tjj|d|�}tjj|�}|j�}t	}Wn"t
k
r�}t||�}nX|||fS(NuDownloading content from %s(RRR	R/RR@RARBRCRRRf(trequest_urlRtsuccesstcontenttcommentR@turlRp((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR\�s
cC@sz|jtjjjjjkr+d|}nK|jtjjjjjkr[dj|�}ndjd|jd|�}|S(NuHTTP Error 404. Request URL: u�HTTP Error 409: Conflict. Requested URL: {0}. 
This error may be caused by reading snapshot artifact from non-snapshot repository.u)HTTP Error {err_code}. Request URL: {url}terr_codeRu(	tcodeR^texttsixtmovesthttp_clientt	NOT_FOUNDtCONFLICTR
(t
http_errorRqRt((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyRf
s
ucC@s|d|S(Nu
((tnew_commenttcurrent_comment((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyResR5cB@seZd�Zd�ZRS(cC@s tt|�j�||_dS(N(tsuperR5t__init__RW(tselfRW((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR�scC@s
t|j�S(N(treprRW(R�((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt__str__ s(t__name__t
__module__R�R�(((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyR5s	(7t__doc__t
__future__RRRR0Rtloggingtsalt.utils.filesR^tsalt.utils.stringutilstsalt.ext.six.moves.http_clienttsalt.ext.six.movesRtsalt.ext.six.moves.urllib.errorRRtsalt.exceptionsRtsalt._compatRRGRRtImportErrorR	t	getLoggerR�RRR
R/R'R)R-R.RRR+R?RFRRPRRR4RYR*RR7R8R\RfRet	ExceptionR5(((s</usr/lib/python2.7/site-packages/salt/modules/artifactory.pyt<module>sP


	
'&%&F

		3			

Zerion Mini Shell 1.0