;ò
øÐ3@c           @   sx  d  k  Z  d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z y d k l	 Z	 d Z
 Wn d Z
 n Xd a d „  a e a d „  Z d f  d „  ƒ  YZ e e e d	 „ Z e d
 „ Z e d j o² e d ƒ Z e GHe e j o e d e d ƒ Z e GHn e d ƒ Z e GHe e j o e d e d ƒ Z e GHn e d ƒ Z e GHe e j o e d e d ƒ Z e GHqtn d  S(   N(   s   FTPi   i    s    c         C   s   t  |  a  d  S(   N(   s	   _ftp_datas   data(   s   data(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   _grab_ftp_data   s     c   	      C   sð   t  i |  d d ƒ } t } t } t } t } t	 | ƒ d j oR | d } t  i | d d d ƒ } | d } t	 | ƒ d j o | d } qœ n | d } t  i | d d ƒ } | d } t	 | ƒ d j o | d } n | | | | f Sd S(   sl   Handle a full location for an URL and chunk it into the 
       appropriate (host, port, user, passwd) list.s   @i   i   i    s   :N(   s   strings   splits
   hoststrings   ls   Nones   hosts   ports   users   passwds   lens   hostports   userinfos   arr(	   s
   hoststrings   arrs   passwds   ls   hosts   users   hostports   ports   userinfo(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys
   split_host%   s$     



s   rhnAppletConnc           B   s\   t  Z d  Z e e e d „ Z e e d „ Z d „  Z d „  Z d „  Z e d e d „ Z	 RS(   s'   Class for handling connections requestsc         C   s   | |  _ | |  _ | |  _ d  S(   N(   s   http_proxy_urls   selfs   __http_proxy_url__s   http_proxy_usernames   __http_proxy_username__s   http_proxy_passwords   __http_proxy_password__(   s   selfs   http_proxy_urls   http_proxy_usernames   http_proxy_password(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   __init__B   s    		c         C   s   | |  _ | |  _ | |  _ d  S(   N(   s   http_proxy_urls   selfs   __http_proxy_url__s   http_proxy_usernames   __http_proxy_username__s   http_proxy_passwords   __http_proxy_password__(   s   selfs   http_proxy_urls   http_proxy_usernames   http_proxy_password(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   set_http_proxyH   s    		c   	      C   s>  | t j o
 | d j o7 t i d | | f ƒ t i d d | | f ƒ ‚ n y  t i t i	 | ƒ d ƒ } Wn. t i d | ƒ t i d d | ƒ ‚ n X| t j o% | t i | d ƒ j o t SqÔ n t i d | ƒ } y t | d ƒ i ƒ  } Wn. t i d | ƒ t i d d | ƒ ‚ n X| | f Sd	 S(
   s   Implements direct file accesss    s   File access uses host %s: %s i   i   s   Failed to stat file: %s s   %a, %d %b %Y %H:%M:%S GMTs   rs   Failed to read file: %s N(   s   hosts   Nones	   rhn_utilss	   log_debugs   bases   rhnAppletNetworkExceptions   times   gmtimes   oss   stats   paths   tims   lastmodifieds   strptimes   strftimes   opens   reads   content(	   s   selfs   schemes   hosts   ports   paths   lastmodifieds   bases   contents   tim(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   __do_file_requestN   s,     	 		c         C   sn  | d j od |  i t j o |  i d j o+ t i i |  i | | |  i	 |  i
 ƒ } qâ t i i | | ƒ } nr | d j od |  i t j o |  i d j o+ t i i |  i | | |  i	 |  i
 ƒ } qâ t i i | | ƒ } n h  d d t i <}
 | t j o | i d | t |
 ƒ n! | |
 d <| i d | t |
 ƒ | i ƒ  }	 |	 i d j o t Sn |	 i d	 j p |	 i d
 j ob y |	 i d ƒ } Wn. t i d | ƒ t i d d | ƒ ‚ n X|  i | | | d | ƒ Sn |	 i d d j o t i d d t ƒ ‚ n y |	 i d ƒ i  ƒ  } Wn t } n X|	 i! ƒ  } y | i# ƒ  Wn n X| | f Sd S(   s|   Implements HTTP and HTTPS protocol request, takes care of
	   modification timestamps, redirection and HTTP proxy if presents   https    s   httpss
   User-Agents   RHN-Applet/s   GETs   If-Modified-Sincei0  i-  i.  s   Locations   Redirect error: %s no Locationi   i   id   i   s   connection error: %ss   Last-ModifiedN($   s   schemes   selfs   __http_proxy_url__s   Nones   rhns   connectionss   HTTPProxyConnections   hosts   ports   __http_proxy_username__s   __http_proxy_password__s   conns   HTTPConnections   HTTPSProxyConnections   HTTPSConnections   rhn_applet_versions   versions   headerss   lastmodifieds   requests   paths   getresponses   responses   statuss	   getheaders   redirs	   rhn_utilss	   log_debugs   bases   rhnAppletNetworkExceptions   counts   urls   strips   reads   datas   close(   s   selfs   schemes   hosts   ports   paths   lastmodifieds   bases   counts   redirs   responses   headerss   datas   conn(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   __do_http_requestj   sT       
 		
c         C   sv  d | | | | | | f GHyR | t j o t | ƒ } n t | | ƒ } | i	 ƒ  d a
 | i | t ƒ } Wn& t i d ƒ t i d d ƒ ‚ n X| t j o | d j o
 t
 | j o t Sn t
 } d a
 y. | i d | t ƒ }	 | i ƒ  | i ƒ  Wn& t i d ƒ t i d d ƒ ‚ n X|	 d d j o# t i d ƒ t i d d ƒ ‚ n t
 }
 d a
 |
 | f Sd  S(	   Ns(   __do_ftp_request: %s, %s, %s, %s, %s, %ss    s   FTP error: failed to connecti   s   RETR %ss   FTP error: failed to fetch datai    s   2(   s   schemes   hosts   ports   paths   lastmodifieds   bases   Nones   FTPs   ftps   logins	   _ftp_datas   dirs   _grab_ftp_datas   statuss	   rhn_utilss	   log_debugs   rhnAppletNetworkExceptions
   retrbinarys   ress   quits   closes   data(   s   selfs   schemes   hosts   ports   paths   lastmodifieds   bases   statuss   ftps   ress   data(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   __do_ftp_request§   sB      
	'
		i    c         C   s  | t j o# t i d ƒ t i d d ƒ ‚ n | t j o
 | } n | d j o+ t i d | ƒ t i d d | ƒ ‚ n y, t i | ƒ \ } } }
 }	 } |
 |	 }
 Wn. t i d | ƒ t i d d | ƒ ‚ n X| d j o+ t i d | ƒ t i d d | ƒ ‚ n t | ƒ \ } } } } y t | ƒ } Wn t } n X| d j p
 | d	 j o# |  i | | | |
 | | | ƒ Sn‚ | d
 j o  |  i | | | |
 | | ƒ SnU | d j o  |  i | | | |
 | | ƒ Sn( t i d | ƒ t i d d | ƒ ‚ d S(   sã   Implement a connection requests, on success and if modified
	   it returns a tuple of the content and a new lastmodified value,
	   on if not modified returns None, and generate an
	   rhnAppletNetworkException in case of errors   URL error: no URLi   i   s#   URL error: %s too many redirectionss   URL error: %ss    s#   Fragment identifier not handled: %ss   https   httpss   files   ftps   unsupported protocol: %sN(   s   urls   Nones	   rhn_utilss	   log_debugs   rhnAppletNetworkExceptions   bases   counts   urlparses   urlsplits   schemes   locations   paths   querys   frags
   split_hosts   hosts   ports   users   passwds   ints   selfs   _rhnAppletConn__do_http_requests   lastmodifieds   _rhnAppletConn__do_file_requests   _rhnAppletConn__do_ftp_request(   s   selfs   urls   lastmodifieds   counts   bases   frags   passwds   hosts   locations   querys   paths   schemes   users   port(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   requestÏ   sN     	
			
	(
   s   __name__s
   __module__s   __doc__s   Nones   __init__s   set_http_proxys   _rhnAppletConn__do_file_requests   _rhnAppletConn__do_http_requests   _rhnAppletConn__do_ftp_requests   request(    (    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   rhnAppletConn@   s    		=	(c         C   se   t  t j o t |  | | ƒ a  n? |  t j p | t j p
 | t j o t  i |  | | ƒ n d S(   s=   Initialize the rhnAppletConnHandler used to serve connectionsN(   s   rhnAppletConnHandlers   Nones   rhnAppletConns   http_proxy_urls   http_proxy_usernames   http_proxy_passwords   set_http_proxy(   s   http_proxy_urls   http_proxy_usernames   http_proxy_password(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   init_connectionsþ   s      '	c         C   sA   t  t j o t ƒ  n t  t j o d Sn t  i |  | ƒ Sd S(   sì   Implement a connection requests, on success and if modified
       it returns a tuple of the content and a new lastmodified value,
       on if not modified returns None, and generate an
       rhnAppletNetworkException in case of erroriÿÿÿÿN(   s   rhnAppletConnHandlers   Nones   init_connectionss   requests   urls   lastmodified(   s   urls   lastmodified(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   request  s      s   __main__s   file:///tmp/tst.xmls   http://veillard.com/tst2.xmls   http://veillard.com/tst.xml(   s   oss   times   strings   urlparses   rhn.connectionss   rhns	   rhn_utilss   rhn_applet_versions   ftplibs   FTPs   have_ftps	   _ftp_datas   _grab_ftp_datas   Nones   rhnAppletConnHandlers
   split_hosts   rhnAppletConns   init_connectionss   requests   __name__s   ress   res2(   s   FTPs   ress   strings   res2s   init_connectionss   times   rhn_applet_versions   rhnAppletConns   urlparses   have_ftps
   split_hosts   rhns   requests   oss	   rhn_utils(    (    s6   /data/usr-share/rhn/rhn_applet/rhn_applet_protocols.pys   ?   sD   							

		¾		