Current File : //usr/lib/python2.7/site-packages/sos/plugins/jars.pyo |
�
u��ec @ s d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z d e e f d � � YZ
d S( i����N( t partial( t Plugint RedHatPlugint Jarsc B sz e Z d Z d Z d Z d Z d d d d
e f g Z d Z d Z d � Z
e d � � Z e d � � Z
e d � � Z RS( s2 Collect information about available Java archives.t jarss 1.0.0t javat append_locationss, colon-separated list of additional JAR pathst fastt t all_known_locationss scan all known pathst slows /usr/share/javas
/usr/lib/javas /opts
/usr/locals /var/libc C s� i g d 6} g } t t j � } | j d � rG | t t j � 7} n | j d � } | rr | | j d � 7} n xv | D]n } xe t j | � D]T \ } } } xB | D]: } t j j | | � }
t j
|
� r� | j |
� q� q� Wq� Wqy Wxg | D]_ } t j | � } t j
| � }
| s"|
r� i | d 6|
d 6| d 6} | d j | � q� q� Wt j | d d d
d �} | j | d
� d S( NR R R t :t patht sha1t maven_idt indenti t
separatorst ,s : s jars.json( R s : ( t listR t
jar_locationst
get_optiont extra_jar_locationst splitt ost walkR t joint is_jart appendt get_maven_idt
get_jar_idt jsont dumpst add_string_as_file( t selft resultst jar_pathst locationst user_locationst locationt dirpatht _t filenamest filenameR t jar_pathR t jar_idt recordt results_str( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyt setup0 s0
c C sw t j j | � rs t j | � rs y2 t j | � � } d | j � k rL t SWd QXWqs t t j f k
ro qs Xn t
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'.
s META-INF/MANIFEST.MFN( R R t isfilet zipfilet
is_zipfilet ZipFilet namelistt Truet IOErrort
BadZipfilet False( R t f( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyR S s !c
C s@ i } y"t j | � �
} t j d � } g | j � D] } | j | � r7 | ^ q7 } t | � d k rn d S| j | d � �� } x� | j � D]� } | j
� } | j d � s� yM | j d � \ } } | j
d � j
� } | j
d � j
� } | | | <Wqt k
rd SXq� q� WWd QXWd QXWn t k
r;n X| 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$i i t #t =t utf8N( R1 R3 t ret compileR4 t matcht lent Nonet opent readlinest stript
startswithR t decodet
ValueErrorR6 (
R+ t propsR9 t rt xt resultt props_ft linet keyt value( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyR c s* .
c C s� d } yj t | d d ��F } t j � } x0 t t | j d � d � D] } | j | � qF WWd QX| j � } Wn t k
r� n X| S( sH Compute JAR id.
Returns sha1 hash of a given JAR file.
R t modet rbi N( RB t hashlibR
t iterR t readt updatet hexdigestR6 ( R+ R, R9 t mt buf( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyR � s "
( s java( s append_locationss, colon-separated list of additional JAR pathsR R ( s /usr/share/javas
/usr/lib/java( s /opts
/usr/locals /var/lib( t __name__t
__module__t __doc__t plugin_namet versiont profilesR8 t option_listR R R/ t staticmethodR R R ( ( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyR s #( RR R R R= R1 t functoolsR t sos.pluginsR R R ( ( ( s4 /usr/lib/python2.7/site-packages/sos/plugins/jars.pyt <module> s