;ò
µAc           @   sj  d  k  Z d  k Z d  k Z d  k Z d a y d k l Z Wn e j
 o Z	 d „  Z n Xy d k
 l Z Wn e j
 o Z	 e Z n Xg  Z y d  k Z Wn? e j
 o3 Z	 d  k Z e i ƒ  e _ e Z d Z e Z n* Xd Z e i e i ƒ  ƒ Z e i e ƒ y d k l Z Wn e j
 o Z	 e Z n Xe ƒ  Z e i e ƒ e o# e e i e ƒ Z e i e ƒ n d „  Z d „  Z d	 e  f d
 „  ƒ  YZ! d „  Z" d a# d a$ d „  Z% d „  Z& e d d e e e d d d d d d d g e d „	 Z' e d d e e e d „ Z( d „  a) d „  Z* d „  Z+ d „  Z, d „  Z- e. d j o e d ƒ e+ ƒ  n d  S(   Ni    (   s   _c         C   s   |  Sd  S(   N(   s   st(   s   st(    (    s   /usr/share/yum/urlgrabber.pys   _   s    (   s   HTTPExceptioni   (   s   HTTPHandlerc          C   sU   y9 |  t j o t i |  ƒ n |  t j	 o
 t }  n Wn t j
 o	 } n Xd  S(   N(   s   keepalive_handlers   special_handlerss   removes   Nones	   NameErrors   e(   s   keepalive_handlers   e(    (    s   /usr/share/yum/urlgrabber.pys   disable_keepalive0   s    c         C   s~   t  o t i } n t i i } d |  f } xK t t | ƒ ƒ D]* } | | d d j o | | | <Pq? q? W| i
 | ƒ d  S(   Ns
   User-agenti    (   s   have_urllib2s   openers
   addheaderss   urllibs
   _urlopeners   new_user_agents	   new_tuples   ranges   lens   is   append(   s   new_user_agents   is
   addheaderss	   new_tuple(    (    s   /usr/share/yum/urlgrabber.pys   set_user_agent9   s      
	s   URLGrabErrorc           B   s   t  Z d  Z RS(   só  
    URLGrabError error codes:
      -1 - default retry code for retrygrab check functions
      0  - everything looks good (you should never see this)
      1  - malformed url
      2  - local file doesn't exist
      3  - request for non-file local file (dir, etc)
      4  - IOError on fetch
      5  - OSError on fetch
      6  - no content length header when we expected one
      7  - HTTPException

    Negative codes are reserved for use by functions passed in to
    retrygrab with checkfunc.

    You can use it like this:
      try: urlgrab(url)
      except URLGrabError, e:
         if e.errno == 3: ...
           # or
         print e.strerror
           # or simply
         print e  #### print '[Errno %i] %s' % (e.errno, e.strerror)
    (   s   __name__s
   __module__s   __doc__(    (    (    s   /usr/share/yum/urlgrabber.pys   URLGrabErrorF   s    c           C   s   t  o t  i ƒ  n d S(   s$   close any open keepalive connectionsN(   s   keepalive_handlers	   close_all(    (    (    s   /usr/share/yum/urlgrabber.pys	   close_alla   s      f1.0c         C   s
   |  a d S(   s  urlgrab supports throttling via two values: throttle and bandwidth
    Between the two, you can either specify and absolute throttle threshold
    or specify a theshold as a fraction of maximum available bandwidth.
    
    throttle is a number - if it's an int, it's the bytes/second throttle
       limit.  If it's a float, it is first multiplied by bandwidth.  If
       throttle == 0, throttling is disabled.  If None, the module-level
       default (which can be set with set_throttle) is used.

    bandwidth is the nominal max bandwidth in bytes/second.  If throttle
       is a float and bandwidth == 0, throttling is disabled.  If None,
       the module-level default (which can be set with set_bandwidth) is
       used.

    EXAMPLES:

      Lets say you have a 100 Mbps connection.  This is (about) 10^8 bits
      per second, or 12,500,000 Bytes per second.  You have a number of
      throttling options:

      *) set_bandwidth(12500000); set_throttle(0.5) # throttle is a float

         This will limit urlgrab to use half of your available bandwidth.

      *) set_throttle(6250000) # throttle is an int

         This will also limit urlgrab to use half of your available
         bandwidth, regardless of what bandwidth is set to.

      *) set_throttle(6250000); set_throttle(1.0) # float

         Use half your bandwidth

      *) set_throttle(6250000); set_throttle(2.0) # float

         Use up to 12,500,000 Bytes per second (your nominal max bandwidth)

      *) set_throttle(6250000); set_throttle(0) # throttle = 0

         Disable throttling - this is more efficient than a very large
         throttle setting.

      *) set_throttle(0); set_throttle(1.0) # throttle is float, bandwidth = 0

         Disable throttling - this is the default when the module is loaded.


    SUGGESTED AUTHOR IMPLEMENTATION

      While this is flexible, it's not extremely obvious to the user.  I
      suggest you implement a float throttle as a percent to make the
      distinction between absolute and relative throttling very explicit.

      Also, you may want to convert the units to something more convenient
      than bytes/second, such as kbps or kB/s, etc.
    N(   s   new_throttles	   _throttle(   s   new_throttle(    (    s   /usr/share/yum/urlgrabber.pys   set_throttleg   s    8  c         C   s
   |  a d  S(   N(   s   new_bandwidths
   _bandwidth(   s   new_bandwidth(    (    s   /usr/share/yum/urlgrabber.pys   set_bandwidth£   s     i   iÿÿÿÿi   i   i   i   i   c
         C   s@  d } |	 t j o< t |	 ƒ o |	 f  h  f \ } } } qV |	 \ } } } n t } xã n oÛ | d } t o d | |  f GHn yc t	 |  | | | | | | ƒ }
 | t j o t | |
 f | | ƒ n t o d |
 GHn |
 SWqY t j
 oA } t o d | GHn | | j p | i | j o ‚  q7qY Xq` Wd S(   s  a wrapper function for urlgrab that retries downloads

    The args for retrygrab are the same as urlgrab except for numtries,
    retrycodes, and checkfunc.  You should use keyword arguments for
    both in case new args are added to urlgrab later.  If you use keyword
    args (especially for the retrygrab-specific options) then retrygrab
    will continue to be a drop-in replacement for urlgrab.  Otherwise,
    things may break.

    retrygrab exits just like urlgrab in either case.  Either it
    returns the local filename or it raises an exception.  The
    exception raised will be the one raised MOST RECENTLY by urlgrab.

    retrygrab ONLY retries if URLGrabError is raised.  If urlgrab (or
    checkfunc) raise some other exception, it will be passed up
    immediately.

    numtries
       number of times to retry the grab before bailing.  If this is
       zero, it will retry forever.  This was intentional... really,
       it was :)

    retrycodes
       the errorcodes (values of e.errno) for which it should retry.
       See the doc on URLGrabError for more details on this.

    checkfunc
       a function to do additional checks.  This defaults to None,
       which means no additional checking.  The function should simply
       return on a successful check.  It should raise URLGrabError on
       and unsuccessful check.  Raising of any other exception will
       be considered immediate failure and no retries will occur.

       Negative error numbers are reserved for use by these passed in
       functions.  By default, -1 results in a retry, but this can be
       customized with retrycodes.

       If you simply pass in a function, it will be given exactly one
       argument: the local file name as returned by urlgrab.  If you
       need to pass in other arguments,  you can do so like this:

         checkfunc=(function, ('arg1', 2), {'kwarg': 3})

       if the downloaded file as filename /tmp/stuff, then this will
       result in this call:

         function('/tmp/stuff', 'arg1', 2, kwarg=3)

       NOTE: both the "args" tuple and "kwargs" dict must be present
       if you use this syntax, but either (or both) can be empty.
    i    i   s   TRY #%i: %ss   RESULT = success (%s)s   EXCEPTION: %sN(   s   triess	   checkfuncs   Nones   callables   funcs   argss   kwargss   DEBUGs   urls   urlgrabs   filenames
   copy_locals   close_connections   progress_objs   throttles	   bandwidths   fnames   applys   URLGrabErrors   es   numtriess   errnos
   retrycodes(   s   urls   filenames
   copy_locals   close_connections   progress_objs   throttles	   bandwidths   numtriess
   retrycodess	   checkfuncs   fnames   kwargss   argss   triess   funcs   e(    (    s   /usr/share/yum/urlgrabber.pys	   retrygrab¨   s2    5  
     c         C   sÓ  t  i  |  ƒ \ }
 } } } }	 } t i i	 | ƒ } d | j o t
 o |
 d d g j o“ y. t i | ƒ \ } } t i | ƒ \ } } Wn. t j
 o" } t d t d ƒ |  ƒ ‚ n Xt o d | | f GHn t
 i t | | | ƒ n t  i |
 | | | |	 | f ƒ }  | t j o t i i | ƒ } n |
 d j o | op t i i | ƒ o  t d t d	 ƒ | f ƒ ‚ q¶t i i | ƒ o  t d
 t d ƒ | f ƒ ‚ q¶| Sn | t j o
 t } n | d j o
 d } nK t! | ƒ t! d ƒ j o t" | ƒ } n" | t j o
 t$ } n | | } y t i% |  ƒ } | i' ƒ  } WnÊ t j
 o% } t d t d ƒ | f ƒ ‚ n› t) j
 o% } t d t d ƒ | f ƒ ‚ nk t* j
 o% } t d t d ƒ | f ƒ ‚ n; t+ j
 o. } t d t d ƒ | i, i- | f ƒ ‚ n Xt. p
 |
 d j o< | t j o | i/ d ƒ o t d t d ƒ ƒ ‚ qjn yÄ | t j o t1 | | | | ƒ nd y t2 | d ƒ } Wn t } n X| i4 | |  t i i | ƒ | ƒ t1 | | | | ƒ | i5 ƒ  | i6 ƒ  | o( y | i7 ƒ  Wq-t8 j
 o q-Xn Wnš t) j
 o% } t d t d ƒ | f ƒ ‚ nk t* j
 o% } t d t d ƒ | f ƒ ‚ n; t+ j
 o. } t d t d ƒ | i, i- | f ƒ ‚ n X| Sd S(   sw  grab the file at <url> and make a local copy at <filename>

    If filename is none, the basename of the url is used.

    copy_local is ignored except for file:// urls, in which case it
    specifies whether urlgrab should still make a copy of the file, or
    simply point to the existing copy.

    close_connection tells urlgrab to close the connection after
    completion.  This is ignored unless the download happens with the
    http keepalive handler.  Otherwise, the connection is left open
    for further use.

    progress_obj is a class instance that supports the following methods:
       po.start(filename, url, basename, length)
       # length will be None if unknown
       po.update(read) # read == bytes read so far
       po.end()

    throttle is a number - if it's an int, it's the bytes/second throttle
       limit.  If it's a float, it is first multiplied by bandwidth.  If
       throttle == 0, throttling is disabled.  If None, the module-level
       default (which can be set with set_throttle) is used.

    bandwidth is the nominal max bandwidth in bytes/second.  If throttle
       is a float and bandwidth == 0, throttling is disabled.  If None,
       the module-level default (which can be set with set_bandwidth) is
       used.

    urlgrab returns the filename of the local file, which may be different
    from the passed-in filename if copy_local == 0.
    s   @s   https   httpsi   s   Bad URL: %ss   adding HTTP auth: %s, %ss   filei   s   Local file does not exist: %si   s   Not a normal file: %si    i   s   IOError: %si   s   OSError: %si   s   HTTP Error (%s): %ss   Content-Lengthi   s9   ERROR: Url Return no Content-Length  - something is wrongN(9   s   urlparses   urls   schemes   hosts   paths   parms   querys   frags   oss   normpaths   auth_handlers   urllib2s	   splitusers   user_passwords   splitpasswds   users   passwords
   ValueErrors   es   URLGrabErrors   _s   DEBUGs   add_passwords   Nones
   urlunparses   filenames   basenames
   copy_locals   existss   isfiles   throttles	   _throttles   raw_throttles   types   floats	   bandwidths
   _bandwidths   urlopens   fos   infos   hdrs   IOErrors   OSErrors   HTTPExceptions	   __class__s   __name__s   have_urllib2s   has_keys   progress_objs   _do_grabs   ints   lengths   starts   ends   closes   close_connections   AttributeError(   s   urls   filenames
   copy_locals   close_connections   progress_objs   throttles	   bandwidths   user_passwords   paths   querys   schemes   frags   parms   hosts   users   es   passwords   fos   hdrs   raw_throttles   length(    (    s   /usr/share/yum/urlgrabber.pys   urlgrabõ   s†    ! !' !   
 
  

   *  
"

    *c         C   s^  t  |  d ƒ } d d } d } | o t i ƒ  }
 n | t	 j o | i
 | ƒ n | i | ƒ } | t | ƒ } | t	 j o | i
 | ƒ n x¶ | o® | oX t | ƒ | } t i ƒ  } | | |
 }	 |	 d j o t i |	 ƒ n t i ƒ  }
 n | i | ƒ | i | ƒ } | t | ƒ } | t	 j o | i
 | ƒ q– q– W| i ƒ  | Sd  S(   Ns   wbi   i   i    (   s   opens   filenames   new_fos   bss   sizes   raw_throttles   times   ttimes   progress_objs   Nones   updates   fos   reads   blocks   lens
   block_times   nows   diffs   sleeps   writes   close(   s   filenames   fos   progress_objs   raw_throttles   sizes   nows
   block_times   new_fos   bss   diffs   ttimes   block(    (    s   /usr/share/yum/urlgrabber.pys   _do_grabi  s6    
     
c         C   s‹   t  |  d ƒ } d d } d } | i | ƒ } | t | ƒ } x8 | o0 | i	 | ƒ | i | ƒ } | t | ƒ } qA W| i
 ƒ  | Sd  S(   Ns   wbi   i   i    (   s   opens   filenames   new_fos   bss   sizes   fos   reads   blocks   lens   writes   close(   s   filenames   fos   progress_objs   raw_throttles   sizes   new_fos   bss   block(    (    s   /usr/share/yum/urlgrabber.pys   _do_simple_grab‹  s    
 
c    
      C   sC  d  k  } y | i d d !\ } } Wn1 t j
 o% d G| i d Gd GH| i ƒ  n Xh  } x@ | i d D]1 }  t i	 |  d d ƒ \ } } t | ƒ | | <qk Wt d ƒ t d d	 ƒ d
 t t f GHy d k l } Wn t j
 o	 } n X| ƒ  | d <y t t | | f | ƒ }	 Wn t j
 o } | GHn Xd G|	 GHd  S(   Ni   i   s   usage:i    s8   <url> <filename> [copy_local=0|1] [close_connection=0|1]s   =f1.0i    i   s)   throttle: %s,  throttle bandwidth: %s B/s(   s   text_progress_meters   progress_objs   LOCAL FILE:(   s   syss   argvs   urls   filenames
   ValueErrors   exits   kwargss   as   strings   splits   ks   vs   ints   set_throttles   set_bandwidths	   _throttles
   _bandwidths   progress_meters   text_progress_meters   ImportErrors   es   applys   urlgrabs   names   URLGrabError(
   s   as   urls   ks   vs   filenames   syss   text_progress_meters   kwargss   es   name(    (    s   /usr/share/yum/urlgrabber.pys
   _main_testœ  s0    	  
    
c    
      C   s)  g  }  g  } t } t d d ƒ y d k l } Wn t j
 o	 } n X| d t	 d d ƒ ƒ } t } t d ƒ x' t d ƒ D] } t d	 d
 d d ƒq~ Wx  t d ƒ D]’ } | a t i ƒ  }	 t d	 d
 d d d | ƒ|  i d t i ƒ  |	 ƒ t a t i ƒ  }	 t d	 d
 d d d | ƒ| i d t i ƒ  |	 ƒ q¨ W|  i ƒ  d } x |  D] } | | } qUW| t |  ƒ } d | |  t t |  ƒ d ƒ t |  ƒ t |  ƒ f GH| i ƒ  d } x | D] } | | } qÅW| t | ƒ } d | | t t | ƒ d ƒ t | ƒ t | ƒ f GHt ƒ  d  S(   Ni   i(   (   s   text_progress_meters   fos	   /dev/nulls   wi    id   s   file:///tmp/tests
   /tmp/test2s
   copy_locali   iè  s   progress_objf0.0sC   [fancy]  mean: %.3f ms, median: %.3f ms, min: %.3f ms, max: %.3f mssC   [simple] mean: %.3f ms, median: %.3f ms, min: %.3f ms, max: %.3f ms(   s   fancy_timess   simple_timess   _do_grabs   _do_fancy_grabs   set_throttles   progress_meters   text_progress_meters   ImportErrors   es   opens   tpms   Nones   ranges   is   urlgrabs   times   ts   appends   _do_simple_grabs   sorts
   fancy_means   lens   ints   mins   maxs   simple_means	   close_all(
   s   fancy_timess   text_progress_meters   simple_means   _do_fancy_grabs   es   is   tpms
   fancy_means   simple_timess   t(    (    s   /usr/share/yum/urlgrabber.pys   _speed_test¶  sP       
  
  5
  5c          C   sN  d  k  } y | i d d !\ } } Wn1 t j
 o% d G| i d Gd GH| i ƒ  n Xh  } x@ | i d D]1 }  t i	 |  d d ƒ \ } } t | ƒ | | <qk Wy d k l } Wn t j
 o	 } n X| ƒ  | d <d	 d
 „ }	 t ƒ  |	 d f h  d d <f | d <y t t | | f | ƒ }
 Wn t j
 o } | GHn Xd G|
 GHd  S(   Ni   i   s   usage:i    s8   <url> <filename> [copy_local=0|1] [close_connection=0|1]s   =(   s   text_progress_meters   progress_objs   fooc         C   su   | G| GHd  k } | i ƒ  } | d j  o d GHt d d ƒ ‚ n | d j  o d GHt d d ƒ ‚ n d GHd  Sd  S(	   Nf0.5s   forcing retryiÿÿÿÿf0.75s   forcing failureiþÿÿÿs   forcing immediate failures   success(   s   hellos   theres   randoms   rnums   URLGrabError(   s   filenames   hellos   theres   randoms   rnum(    (    s   /usr/share/yum/urlgrabber.pys   cfunc	  s    		s   hellos   theres	   checkfuncs   LOCAL FILE:(   s   syss   argvs   urls   filenames
   ValueErrors   exits   kwargss   as   strings   splits   ks   vs   ints   progress_meters   text_progress_meters   ImportErrors   es   cfuncs	   close_alls   applys	   retrygrabs   names   URLGrabError(   s   as   es   urls   ks   vs   filenames   syss   text_progress_meters   kwargss   cfuncs   name(    (    s   /usr/share/yum/urlgrabber.pys   _retry_testö  s2    	       
s   __main__s
   URLGrabber(/   s   os.paths   oss   urlparses   times   strings   DEBUGs   i18ns   _s   ImportErrors   msgs   httplibs   HTTPExceptions   Nones   special_handlerss   urllib2s   urllibs   FancyURLopeners
   _urlopeners   have_urllib2s   auth_handlers   HTTPBasicAuthHandlers   HTTPPasswordMgrWithDefaultRealms   appends	   keepalives   HTTPHandlers   keepalive_handlers   applys   build_openers   openers   install_openers   disable_keepalives   set_user_agents   IOErrors   URLGrabErrors	   close_alls	   _throttles
   _bandwidths   set_throttles   set_bandwidths	   retrygrabs   urlgrabs   _do_grabs   _do_simple_grabs
   _main_tests   _speed_tests   _retry_tests   __name__(   s
   _main_tests   set_user_agents   HTTPHandlers	   close_alls   set_throttles   urlgrabs   urllibs   openers   URLGrabErrors   msgs   keepalive_handlers   _speed_tests   _do_simple_grabs   strings   HTTPExceptions   urllib2s   disable_keepalives   set_bandwidths   auth_handlers   _s   special_handlerss   urlparses   _retry_tests   have_urllib2s   times	   retrygrabs   os(    (    s   /usr/share/yum/urlgrabber.pys   ?   sf   											<	6Mt	"			@	&
