ó
ÑKjc @ 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