/usr/lib/python2.6/site-packages/sos
Edit: /usr/lib/python2.6/site-packages/sos/utilities.pyc (10095B)
R]c @ sS d d k l Z d d k Z d d k Z d d k Z d d k l Z l Z l Z d d k Z d d k
Z
d d k Z d d k Z d d k
Z
d d k Z d d k Z d d k l Z d d k l Z d Z d d Z d d d d d Z d d d Z d Z d Z d d d Z d d Z d d d Z d e f d YZ d S( i( t with_statementN( t Popent PIPEt STDOUT( t closing( t StringIOc C sh t | d i i } zE | ~ } t i | i | j o | i | d n | i SWd QXd S( s, Returns the last number_of_bytes of filenamet rbi N( t opent __exit__t __enter__t ost statt st_sizet seekt read( t filenamet number_of_bytest _[1]t f( ( s1 /usr/lib/python2.6/site-packages/sos/utilities.pyt tail" s &t rc C sg t | t oI y t | | SWqc t i d } | i d | t t SXn t | Sd S( s@ Returns a file-like object that can be used as a context managert soss fileobj: %s could not be openedN( t
isinstancet
basestringR t loggingt getLoggert debugR R ( t path_or_filet modet log( ( s1 /usr/lib/python2.6/site-packages/sos/utilities.pyt fileobj* s i i
i i i( c C s t | } | | j o
d | | S| | j o
d | | S| | j o
d | | S| | j o
d | | Sd | Sd S( sC Converts a number of bytes to a shorter, more human friendly formats %.1fTs %.1fGs %.1fMs %.1fKs %dN( t float( t bytes_t Kt Mt Gt Tt fn( ( s1 /usr/lib/python2.6/site-packages/sos/utilities.pyt
convert_bytes7 s
c c s | o/ t i i | i t i i } | | 7} n x t i | D] \ } } } | o$ | i t i i | j o | 2n | o t i | | o qF n x. t i | | D] } t i i | | Vq WqF Wd S( s generator function to find files recursively. Usage:
for filename in find("*.properties", "/var/log/foobar"):
print filename
N( R
t patht dirnamet countt sept walkt fnmatcht filtert join( t file_patternt top_dirt max_deptht path_patternt
base_depthR' t dirlistt filelistt name( ( s1 /usr/lib/python2.6/site-packages/sos/utilities.pyt findF s ! # c sa g } xT | D]L } t | i i } z* | ~ } | i f d | D Wd QXq
W| S( s Returns lines matched in fnames, where fnames can either be pathnames to
files to grep through or open file objects to grep through line by linec 3 s0 x) | ]" } t i | o | Vq q Wd S( N( t ret match( t .0t line( t pattern( s1 /usr/lib/python2.6/site-packages/sos/utilities.pys
b s N( R R R t extend( R<