Current File : //usr/lib/python2.7/site-packages/sos/plugins/jars.pyo
�
u��ec@sddlZddlZddlZddlZddlZddlmZddlmZm	Z	dee	fd��YZ
dS(i����N(tpartial(tPlugintRedHatPlugintJarscBszeZdZdZdZdZddd	d
efgZdZdZ	d�Z
ed��Zed��Z
ed��ZRS(s2Collect information about available Java archives.tjarss1.0.0tjavatappend_locationss,colon-separated list of additional JAR pathstfastttall_known_locationssscan all known pathstslows/usr/share/javas
/usr/lib/javas/opts
/usr/locals/var/libcCs�igd6}g}ttj�}|jd�rG|ttj�7}n|jd�}|rr||jd�7}nxv|D]n}xetj|�D]T\}}}xB|D]:}	tjj	||	�}
tj
|
�r�|j|
�q�q�Wq�WqyWxg|D]_}tj|�}tj
|�}
|s"|
r�i|d6|
d6|d6}|dj|�q�q�Wtj|dd	d
d�}|j|d
�dS(NRR	Rt:tpathtsha1tmaven_idtindentit
separatorst,s: s	jars.json(Rs: (tlistRt
jar_locationst
get_optiontextra_jar_locationstsplittostwalkRtjointis_jartappendtget_maven_idt
get_jar_idtjsontdumpstadd_string_as_file(tselftresultst	jar_pathst	locationstuser_locationstlocationtdirpatht_t	filenamestfilenameRtjar_pathRtjar_idtrecordtresults_str((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pytsetup0s0





cCswtjj|�rstj|�rsy2tj|��}d|j�krLtSWdQXWqsttj	fk
roqsXnt
S(s�Check whether given file is a JAR file.

        JARs are ZIP files which usually include a manifest
        at the canonical location 'META-INF/MANIFEST.MF'.
        sMETA-INF/MANIFEST.MFN(RRtisfiletzipfilet
is_zipfiletZipFiletnamelisttTruetIOErrort
BadZipfiletFalse(Rtf((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pyRSs!c
Cs@i}y"tj|��
}tjd�}g|j�D]}|j|�r7|^q7}t|�dkrndS|j|d���}x�|j	�D]�}|j
�}|jd�s�yM|jd�\}}	|j
d�j
�}|	j
d�j
�}	|	||<Wqtk
rdSXq�q�WWdQXWdQXWntk
r;nX|S(s�Extract Maven coordinates from a given JAR file, if possible.

        JARs build by Maven (most popular Java build system) contain
        'pom.properties' file. We can extract Maven coordinates
         from there.
        s*META-INF/maven/[^/]+/[^/]+/pom.properties$iit#t=tutf8N(R1R3tretcompileR4tmatchtlentNonetopent	readlineststript
startswithRtdecodet
ValueErrorR6(
R+tpropsR9trtxtresulttprops_ftlinetkeytvalue((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pyRcs*.

cCs�d}yjt|dd��F}tj�}x0tt|jd�d�D]}|j|�qFWWdQX|j�}Wntk
r�nX|S(sHCompute JAR id.

        Returns sha1 hash of a given JAR file.
        RtmodetrbiN(	RBthashlibR
titerRtreadtupdatet	hexdigestR6(R+R,R9tmtbuf((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pyR�s"
(sjava(sappend_locationss,colon-separated list of additional JAR pathsRR(s/usr/share/javas
/usr/lib/java(s/opts
/usr/locals/var/lib(t__name__t
__module__t__doc__tplugin_nametversiontprofilesR8toption_listRRR/tstaticmethodRRR(((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pyRs 	#(RRRRR=R1t	functoolsRtsos.pluginsRRR(((s4/usr/lib/python2.7/site-packages/sos/plugins/jars.pyt<module>s