ó
Òbc           @@  sÎ  d  d l  m Z d  d l m Z m Z d  d l Z d  d l Z d  d l Z d d l	 m
 Z
 e j d k rx e Z e Z n e Z d  d l m Z y d  d l m Z Wn' e k
 rË d	 e f d
     YZ n Xy d  d l m Z Wn! e k
 rd  d l m Z n Xd e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d e f d     YZ" d e f d     YZ# d e f d     YZ$ d e f d     YZ% d S(    i    (   t   absolute_import(   t   debugt   errorNi   (   t	   ExitCodesi   (   t   SSLError(   t   CertificateErrort   S3SSLCertificateErrorc           B@  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR      s   (   t
   ParseError(   t
   ExpatErrort   S3Exceptionc           B@  sG   e  Z d  d  Z d   Z d   Z d   Z d   Z e e e  Z RS(   t    c         C@  s   t  j j |  |  _ d  S(   N(   t   S3t   Utilst	   unicodiset   message(   t   selfR   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   __init__-   s    c         C@  s*   t  r |  j   St j j |  j    Sd  S(   N(   t   PY3t   __unicode__R   R   t   deunicodise(   R   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   __str__0   s    
c         C@  s   |  j  S(   N(   R   (   R   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR   8   s    c         C@  s   |  j  S(   N(   t   _message(   R   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   _get_message<   s    c         C@  s   | |  _  d  S(   N(   R   (   R   R   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   _set_message?   s    (	   R   R   R   R   R   R   R   t   propertyR   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR   ,   s   				t   S3Errorc           B@  s2   e  Z d    Z d   Z d   Z e d    Z RS(   c         C@  sb  | d |  _  | d |  _ i d d 6d d 6d d 6|  _ t d |  j  |  j f  d | k r x1 | d D]" } t d	 | | d | f  qi Wn  d
 | k r.| d
 r.y t j j | d
  } Wn t k
 rß t d  q.Xy |  j j |  j	 |   Wq.t
 k
 r*} t d | | d
 f  q.Xn  |  j d |  _ |  j d |  _ |  j d |  _ d  S(   Nt   statust   reasonR   t   Codet   Messaget   Resources   S3Error: %s (%s)t   headerss   HttpHeader: %s: %st   datas   Not an XML responses$   Error parsing xml: %s.  ErrorXML: %s(   R   R   t   infoR   R   t	   BaseUtilst   getTreeFromXmlt   XmlParseErrort   updatet   parse_error_xmlt	   ExceptionR   t   codeR   t   resource(   R   t   responset   headert   treet   e(    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR   E   s,    #c         C@  sg   d |  j  } | d d |  j k r/ |  j d p5 |  j 7} |  j j d  } | rc | d | 7} n  | S(   Nu   %d u   (%s)R   R   u   : %s(   R   R#   R   t   get(   R   t   retvalt	   error_msg(    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR   `   s    -c         C@  sğ   |  j  d k r t j S|  j  d k r, t j S|  j  d
 k rB t j S|  j  d k rX t j S|  j  d k rn t j S|  j  d k r t j S|  j  d k r t j S|  j  d k r° t j	 St j Sd  S(   Ni-  i3  i  i  i  i   iĦ  iġ  iĝ  i  i  i  i  iô  i­  i÷  (   i-  i3  (   i  i  i  i   iĦ  iġ  iĝ  (   i­  i÷  (
   R   R   t   EX_SERVERMOVEDt   EX_SERVERERRORt   EX_ACCESSDENIEDt   EX_NOTFOUNDt   EX_CONFLICTt   EX_PRECONDITIONt   EX_SOFTWAREt
   EX_SERVICE(   R   (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   get_error_codeh   s"    c         C@  sĦ   i  } |  } | j  d k s- |  j d  } n  | d  k	 r xa | D]J } | j d k r@ t d | j  d t | j   | j | | j  <q@ q@ Wn t d   | S(   Nt   Errors   .//ErrorR   s
   ErrorXML: s   : s0   Malformed error XML returned from remote server.(   t   tagt   findt   Nonet   textR   t   reprt   S3ResponseError(   R.   R#   t
   error_nodet   child(    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR(   |   s    "(   R   R   R   R   R;   t   staticmethodR(   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyR   D   s   			t   CloudFrontErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRF      s   t   S3UploadErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRG      s   t   S3DownloadErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRH      s   t   S3RequestErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRI      s   RB   c           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRB      s   t   InvalidFileErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRJ      s   t   ParameterErrorc           B@  s   e  Z RS(    (   R   R   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyRK      s   (   i   i    (&   t
   __future__R    t   loggingR   R   t   syst   S3.BaseUtilsR   t   S3.UtilsR   R   t   version_infot   TrueR   t   strt   unicodet   Falset   sslR   t
   S3SSLErrorR   R   t   ImportErrorR)   t   xml.etree.ElementTreeR	   R&   t   xml.parsers.expatR
   R   R   RF   RG   RH   RI   RB   RJ   RK   (    (    (    sM   /oak/stanford/groups/akundaje/marinovg/programs/s3cmd-master/S3/Exceptions.pyt   <module>	   s6   	H