%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
ddlmZmZddlmZyddlmZeZWnek
r�eZnXeje�ZdZd	�Zd
ddddd�Z dd
ddddd�Z!dddd
�Z"d
ddddd�Z#d
ddddd�Z$dd�Z%ddddd�Z&dd�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d�Z1d�Z2dd�Z3d e4fd!��YZ5dS("uJ
Module for fetching artifacts from Nexus 3.x

.. versionadded:: 2018.3.0
i(tabsolute_importtprint_functiontunicode_literalsN(turllib(t	HTTPErrortURLError(tCommandExecutionError(tElementTreeunexuscC@s!tstdjt�fStSdS(u<
    Only load if elementtree xml library is available.
    u7Cannot load {0} module: ElementTree library unavailableN(tHAS_ELEMENT_TREEtFalsetformatt__virtualname__tTrue(((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt__virtual__"su/tmpc
C@s�tjd|||||||�i}
|rk|	rkdjtjdj||	��jdd��|
d<ntd|d|d	|d
|d|
�}|d}td|d|d	|d
|d
|d|d|d|
�\}
}t|||�}t	|
||
�S(uI
       Gets latest snapshot of the given artifact

       nexus_url
           URL of nexus instance
       repository
           Snapshot repository in nexus 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
           nexus username. Optional parameter.
       password
           nexus password. Optional parameter.
       u�======================== MODULE FUNCTION: nexus.get_latest_snapshot, nexus_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
Authorizationt	nexus_urlt
repositorytgroup_idtartifact_idtheadersulatest_versiontversiont	packagingt
classifier(
tlogtdebugR
tbase64tencodestringtreplacet_get_artifact_metadatat_get_snapshot_urlt__resolve_target_filet__save_artifact(RRRRRt
target_dirttarget_fileRtusernametpasswordRtartifact_metadataRtsnapshot_urlt	file_name((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pytget_latest_snapshot,s	7'
?cC@s�tjd||||||||	�	i}|
rn|rndjtjdj|
|��jdd��|d<ntd|d|d	|d
|d|d|d
|d|	d|�	\}
}t|||�}t|
||�S(u�
       Gets snapshot of the desired version of the artifact

       nexus_url
           URL of nexus instance
       repository
           Snapshot repository in nexus 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
           nexus username. Optional parameter.
       password
           nexus password. Optional parameter.
       u�======================== MODULE FUNCTION: nexus.get_snapshot(nexus_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_versionRR(	RRR
RRRRRR(RRRRRRR'RR RR!R"RR$R%((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pytget_snapshotSs	7Ec	
C@s�tjd|||||||�i}	|rk|rkdjtjdj||��jdd��|	d<ntd|d|d	|d
|d|d|d
|dt�S(u�
       Gets the specific version string of a snapshot of the desired version of the artifact

       nexus_url
           URL of nexus instance
       repository
           Snapshot repository in nexus 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
       classifier
           Artifact classifier name (ex: sources,javadoc,etc). Optional parameter.
       username
           nexus username. Optional parameter.
       password
           nexus password. Optional parameter.
       u�======================== MODULE FUNCTION: nexus.get_snapshot_version_string(nexus_url=%s, repository=%s, group_id=%s, artifact_id=%s, packaging=%s, version=%s, classifier=%s)u	Basic {0}u{0}:{1}u
uu
AuthorizationRRRRRRRtjust_get_version_string(RRR
RRRRR(
RRRRRRRR!R"R((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pytget_snapshot_version_stringys	7c
C@s�tjd|||||||�i}
|rk|	rkdjtjdj||	��jdd��|
d<ntd|d|d	|d
|d|
�}|d}t|||||||�\}
}t|||�}t	|
||
�S(
u;
       Gets the latest release of the artifact

       nexus_url
           URL of nexus instance
       repository
           Release repository in nexus 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
           nexus username. Optional parameter.
       password
           nexus password. Optional parameter.
       u�======================== MODULE FUNCTION: nexus.get_latest_release(nexus_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
AuthorizationRRRRRulatest_version(
RRR
RRRRt_get_release_urlRR(RRRRRRR RR!R"RR#Rtrelease_urlR%((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pytget_latest_release�s	7'
$c
C@s�tjd||||||||�	i}|	rn|
rndjtjdj|	|
��jdd��|d<nt|||||||�\}}
t|
||�}t|||�S(up
       Gets the specified release of the artifact

       nexus_url
           URL of nexus instance
       repository
           Release repository in nexus 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
           nexus username. Optional parameter.
       password
           nexus password. Optional parameter.
       u�======================== MODULE FUNCTION: nexus.get_release(nexus_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(RRRRRRRR RR!R"RR,R%((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pytget_release�s	7$cC@s(|dkr$tjj||�}n|S(N(tNonetostpathtjoin(R%RR ((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR�sc
C@s�|dkri}n|dk	o*|dk}
|dkr'td|d|d|d|d|d|�}||dkr�d	jd|d|d|d|d
|d|d|�}t|��n|
r||dkrdjd|d|d|d|d
|d|d|�}t|��n|d|}nt|�}
d
jd|d|d
|dt|��}djd|d|d|
d|d|d|�}tjd|�|	r�|S||fSdS(NuRRRRRRusnapshot_versionsu�Cannot find requested packaging '{packaging}' in the snapshot version metadata.
                      nexus_url: {nexus_url}
                      repository: {repository}
                      group_id: {group_id}
                      artifact_id: {artifact_id}
                      packaging: {packaging}
                      classifier: {classifier}
                      version: {version}RRu�Cannot find requested classifier '{classifier}' in the snapshot version metadata.
                      nexus_url: {nexus_url}
                      repository: {repository}
                      group_id: {group_id}
                      artifact_id: {artifact_id}
                      packaging: {packaging}
                      classifier: {classifier}
                      version: {version}u8{artifact_id}-{snapshot_version}{classifier}.{packaging}R'uH{nexus_url}/{repository}/{group_url}/{artifact_id}/{version}/{file_name}t	group_urlR%usnapshot_url=%s(R/t_get_snapshot_version_metadataR
t
nexusErrort__get_group_id_subpatht__get_classifier_urlRR(RRRRRRR'RRR)thas_classifiertsnapshot_version_metadatat
error_messageR3R%R$((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR�sV	-							c

C@s�t|�}djd|d|d|dt|��}djd|d|d	|d|d|d
|�}	tjd|	�|	|fS(Nu/{artifact_id}-{version}{classifier}.{packaging}RRRRuH{nexus_url}/{repository}/{group_url}/{artifact_id}/{version}/{file_name}RRR3R%urelease_url=%s(R6R
R7RR(
RRRRRRRR3R%R,((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR+/s			c	C@sDt|�}djd|d|d|d|�}tjd|�|S(NuE{nexus_url}/{repository}/{group_url}/{artifact_id}/maven-metadata.xmlRRR3Ruartifact_metadata_url=%s(R6R
RR(RRRRR3tartifact_metadata_url((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt_get_artifact_metadata_urlDs		c
	C@s�td|d|d|d|�}y4tjj|d|�}tjj|�j�}Wn7ttfk
r�}dj	||�}	t
|	��nXtjd|�|S(NRRRRu.Could not fetch data from url: {0}. ERROR: {1}uartifact_metadata_xml=%s(
R<RtrequesttRequestR/turlopentreadRRR
RRR(
RRRRRR;R=tartifact_metadata_xmlterrtmessage((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt_get_artifact_metadata_xmlPs		cC@s�td|d|d|d|d|�}tj|�}||jd�jksTt�||jd�jksrt�|jd�jd	�}g}x'|jd
�D]}	|j|	j�q�Wt|�}
t	j
d|
�i|
d6S(
NRRRRRugroupIdu
artifactIdu
versioninguversionsuversionulatest version=%sulatest_version(RDtETt
fromstringtfindttexttAssertionErrortitertappendtmaxRR(RRRRRtmetadata_xmltroottversionstversionListRtlatest_version((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyRgs'cC@sJt|�}djd|d|d|d|d|�}tjd|�|S(NuO{nexus_url}/{repository}/{group_url}/{artifact_id}/{version}/maven-metadata.xmlRRR3RRu snapshot_version_metadata_url=%s(R6R
RR(RRRRRR3tsnapshot_version_metadata_url((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt"_get_snapshot_version_metadata_urlys		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}u snapshot_version_metadata_xml=%s(
RSRR=R>R/R?R@RRR
RRR(RRRRRRRRR=tsnapshot_version_metadata_xmlRBRC((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt"_get_snapshot_version_metadata_xml�s 		c
C@s2td|d|d|d|d|d|�}tj|�}||jd�jksZt�||jd�jksxt�||jd	�jks�t�|jd
�jd�}i}	xp|D]h}
|
jd�j}|
jd
�j}||	|<|
jd�dk	r�|
jd�j}
||	|
<q�q�Wi|	d6S(NRRRRRRugroupIdu
artifactIduversionu
versioningusnapshotVersionsu	extensionuvalueu
classifierusnapshot_versions(RURERFRGRHRIR/(RRRRRRRMtmetadatatsnapshot_versionstextension_version_dictR't	extensiontvalueR((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR4�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_fileuGFile {0} already exists, checksum matches with nexus.
Checksum URL: {1}uNFile {0} already exists, checksum does not match with nexus!
Checksum URL: {1}uDownloading: %s -> %suwbu!Artifact downloaded from URL: {0}udownloaded_file(RRR	R0R1tisfilet
__downloadt__salt__RR
RR=R>R/R?tsalttutilstfilestfopentwritetstringutilstto_bytesR@t__append_commentRRt__get_error_comment(
tartifact_urlR Rtresulttchecksum_urltchecksum_successtartifact_sumtchecksum_commenttfile_sumR=tft
local_filete((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR�sN





"
 
cC@s|jdd�}|S(Nu.u/(R(RR3((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR6�scC@s*|dk	o|dk}|r&d|SdS(Nuu-(R/(RR8((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR7�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=R>R?R@RRRg(trequest_urlRtsuccesstcontenttcommentR=turlRq((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.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_codeRv(	tcodeR_texttsixtmovesthttp_clientt	NOT_FOUNDtCONFLICTR
(t
http_errorRrRu((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyRgs
ucC@s|d|S(Nu
((tnew_commenttcurrent_comment((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyRfsR5cB@seZd�Zd�ZRS(cC@s tt|�j�||_dS(N(tsuperR5t__init__RZ(tselfRZ((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR�scC@s
t|j�S(N(treprRZ(R�((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt__str__s(t__name__t
__module__R�R�(((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyR5s	(6t__doc__t
__future__RRRR0Rtloggingtsalt.utils.filesR_tsalt.utils.stringutilstsalt.ext.six.moves.http_clienttsalt.ext.six.movesRtsalt.ext.six.moves.urllib.errorRRtsalt.exceptionsRtsalt._compatRRERRtImportErrorR	t	getLoggerR�RRR
R/R&R(R*R-R.RRR+R<RDRRSRUR4RR6R7R]RgRft	ExceptionR5(((s6/usr/lib/python2.7/site-packages/salt/modules/nexus.pyt<module>sN


	
'&&&E				
			5				

Zerion Mini Shell 1.0