+
    Û1j;v  ã                   ó²   € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	  ^ RI
t
Rt ^ RItRt ! R R4      tR#   ] d    Rt Li ; i  ] d    Rt L&i ; i)	é    N)Úgetpass)Ú_sos)Úis_executableÚTIMEOUT_DEFAULTTFc                   óò  a € ] tR t^ t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRt/ R	RbR
RbRRbR. bRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRRbRR/CtRAR ltR t R t!]"R  4       t#R! t$R" t%R# t&R$ t'R% t(R& t)R' t*R( t+R) t,R* t-R+ t.RBR, lt/R- t0R. t1R/ t2R0 t3R1 t4R2 t5R3 t6R4 t7R5 t8R6 t9R7 t:RAR8 lt;R9 t<RCR: lt=R; t>RCR< lt?R= t@RDR> ltARER? ltBR@tCV tDR# )FÚUploadTargetzÉ
This class is designed to upload files to a distribution
defined location. These files can be either sos reports,
sos collections, or other kind of files like: vmcores,
application cores, logs, etc.

z�
            Upload a file (can be an sos report, a must-gather, or others) to
             a distribution defined remote location
            zGeneric UploadÚgenericNÚ/zhttps://s3.amazonaws.comÚ Úupload_fileÚcase_idÚlow_priorityFÚprofilesÚ
upload_urlÚupload_directoryÚupload_userÚupload_passÚupload_methodÚautoÚupload_no_ssl_verifyÚupload_protocolÚupload_s3_endpointÚupload_s3_regionÚupload_s3_bucketÚupload_s3_access_keyÚupload_s3_secret_keyÚupload_s3_object_prefixÚupload_targetc                ó`   € \         P                  ! R 4      V n        Wn        W0n        W n        R# )Úsos_uiN)ÚloggingÚ	getLoggerÚui_logÚparserÚcmdlineÚargs)Úselfr$   r&   r%   s   &&&&Ú=/usr/lib/python3/dist-packages/sos/upload/targets/__init__.pyÚ__init__ÚUploadTarget.__init__a   s#   € ä×'Ò'¨Ó1ˆŒØŒØŒØŽ	ó    c                ó   € R# )a3  This should be overridden by upload targets

This is called by sos upload on each target type that exists, and
is meant to return True when the upload target matches a criteria
that indicates that is the local upload target that should be used.

Only the first upload target to determine a match is selectedF© ©r'   s   &r(   Úcheck_distributionÚUploadTarget.check_distributionh   s   € ñ r+   c                ó   € V P                   # )N)Úupload_target_idr.   s   &r(   Úget_target_idÚUploadTarget.get_target_idr   s   € Ø×$Ñ$Ð$r+   c                ór   € V P                   '       d   V P                   # V P                  P                  4       # )z-Returns the upload target's name as a string.)Úupload_target_nameÚ__name__Úlower)Úclss   &r(   ÚnameÚUploadTarget.nameu   s/   € ð ×!×!Ð!Ø×)Ñ)Ð)Ø�|‰|×!Ñ!Ó#Ð#r+   c           	     óÆ   € R V P                   R ,          RV P                   R,          RV P                   R ,          P                  RV P                   R ,          P                  /# )ÚcmdlineoptsÚpolicyr   r   )Úhook_commonsr   r   r.   s   &r(   Úget_commonsÚUploadTarget.get_commons|   sX   € à˜4×,Ñ,¨]Õ;Ø�d×'Ñ'¨Õ1Ø�t×(Ñ(¨Õ7×?Ñ?Ø × 1Ñ 1°-Õ @ßÑð
ð 	
r+   c                ó   € Wn         R# )z9Set common host data for the Upload targets
to reference
N)Úcommons)r'   rC   s   &&r(   Úset_commonsÚUploadTarget.set_commons…   s	   € ð Žr+   c                óæ  € Wn         V P                  4       V n        V P                  R ,          pV P                  R,          pVP                  '       d   VP	                  4        VP
                  V n        VP                  V n        VP                  V n        VP                  V n	        RV n
        VP                  V n        VP                  V n        VP                  V n        VP                  V n        VP                  V n        VP                   V n        VP"                  '       gË   VP$                  '       g·   V P'                  4       '       d3   VP(                  R8X  g"   V P+                  4        V P-                  4        MQVP(                  R8X  dA   V P/                  4        V P1                  4        V P3                  4        V P5                  4        V P6                  P9                  R4       R# R# R# )r=   r>   r   Ús3N)r?   r@   rC   r   Ú_configure_low_priorityr   r   r   r   Úupload_passwordÚupload_archive_namer   r   r   r   r   r   ÚbatchÚquietÚget_upload_urlr   Úprompt_for_upload_userÚprompt_for_upload_passwordÚprompt_for_upload_s3_bucketÚprompt_for_upload_s3_endpointÚprompt_for_upload_s3_access_keyÚprompt_for_upload_s3_secret_keyr#   Úinfo)r'   r?   Úcmdline_optsr>   s   &&  r(   Úpre_workÚUploadTarget.pre_work‹   sŠ  € à(ÔØ×'Ñ'Ó)ˆŒØ—|‘| MÕ2ˆØ—‘˜hÕ'ˆà×$×$Ð$Ø×*Ñ*Ô,ð
 '×1Ñ1ˆŒØ'×3Ñ3ˆÔØ ,× =Ñ =ˆÔØ+×7Ñ7ˆÔØ#%ˆÔ à".×"AÑ"AˆÔØ ,× =Ñ =ˆÔØ$0×$EÑ$EˆÔ!Ø ,× =Ñ =ˆÔØ'3×'KÑ'KˆÔ$Ø$0×$EÑ$EˆÔ!ð ×!×!Ð!Ø×"×"Ð"à×"Ñ"×$Ò$Ø$×4Ñ4¸Ô<Ø×+Ñ+Ô-Ø×/Ñ/Õ1Ø×-Ñ-°Ô5Ø×0Ñ0Ô2Ø×2Ñ2Ô4Ø×4Ñ4Ô6Ø×4Ñ4Ô6Ø�K‰K×Ñ˜RÖ ñ #ñ "r+   c                ó²   € V P                  4       '       gA   RV P                  4        RV P                  4        R2p\        \	        V4      4      V n        R# R# )zeShould be overridden by targets to determine if an access key needs
to be provided for upload or not
z0Please provide the upload access key for bucket ú via endpoint ú: N)Úget_upload_s3_access_keyÚget_upload_s3_bucketÚget_upload_s3_endpointÚinputÚ_r   ©r'   Úmsgs   & r(   rR   Ú,UploadTarget.prompt_for_upload_s3_access_keyµ   s^   € ð ×,Ñ,×.Ò.ðØ×-Ñ-Ó/Ð0ð 1Ø×/Ñ/Ó1Ð2°"ð6ð ô
 ).¬a°«f«ˆDÖ%ñ /r+   c                ó    € V P                  4       '       g8   RV P                  4        RV P                  4        R2p\        V4      V n        R# R# )zdShould be overridden by targets to determine if a secret key needs
to be provided for upload or not
z0Please provide the upload secret key for bucket rY   rZ   N)Úget_upload_s3_secret_keyr\   r]   r   r   r`   s   & r(   rS   Ú,UploadTarget.prompt_for_upload_s3_secret_keyÂ   sZ   € ð ×,Ñ,×.Ò.ðØ×-Ñ-Ó/Ð0ð 1Ø×/Ñ/Ó1Ð2°"ð6ð ô
 )0°«ˆDÖ%ñ /r+   c                ó@  € V P                   '       g‚   V P                  '       dF   V P                  P                  R4      '       d%   V P                  R,          V n         V P                   # \        \	        R4      4      pVP                  R4      V n         V P                   # )z`Should be overridden by targets to determine if a bucket needs to
be provided for upload or not
ús3://ºé   NNz"Please provide the upload bucket: r
   )r   r   Ú
startswithr^   r_   Ústrip)r'   Ú
user_inputs   & r(   rP   Ú(UploadTarget.prompt_for_upload_s3_bucketÎ   s}   € ð ×$×$Ð$Ø��ˆ 4§?¡?×#=Ñ#=¸g×#FÒ#FØ(,¯©¸Õ(;�Ô%ð ×$Ñ$Ð$ô #¤1Ð%IÓ#JÓK�
Ø(2×(8Ñ(8¸Ó(=�Ô%Ø×$Ñ$Ð$r+   c                óÎ   € V P                   pV P                  '       g=   RV P                  4        RV R2p\        \	        V4      4      pT;'       g    TV n        V P                  # )zcShould be overridden by targets to determine if an endpoint needs
to be provided for upload or not
z.Please provide the upload endpoint for bucket z (default: z): )Ú_upload_s3_endpointr   r\   r^   r_   )r'   Údefault_endpointra   rl   s   &   r(   rQ   Ú*UploadTarget.prompt_for_upload_s3_endpointÚ   sq   € ð  ×3Ñ3ÐØ×&×&Ð&ðØ×-Ñ-Ó/Ð0ØÐ.Ð/¨sð4ð ô
 œq ›v›ˆJØ&0×&DÐ&DÐ4DˆDÔ#Ø×&Ñ&Ð&r+   c                ó�   € V P                  4       '       g0   RV P                  4        R2p\        \        V4      4      V n        R# R# )zSShould be overridden by targets to determine if a user needs to
be provided or not
zPlease provide upload user for rZ   N)Úget_upload_userrM   r^   r_   r   r`   s   & r(   rN   Ú#UploadTarget.prompt_for_upload_useré   s@   € ð ×#Ñ#×%Ò%Ø3°D×4GÑ4GÓ4IÐ3JÈ"ÐMˆCÜ$¤Q s£V›}ˆDÖñ &r+   c                óÀ   € V P                  4       '       gH   V P                  4       V P                  8w  d'   RV P                  4        R2p\        V4      V n        R# R# R# )zbShould be overridden by targets to determine if a password needs to
be provided for upload or not
z'Please provide the upload password for rZ   N)Úget_upload_passwordrs   Ú_upload_userr   rI   r`   s   & r(   rO   Ú'UploadTarget.prompt_for_upload_passwordñ   s]   € ð ×'Ñ'×)Ò)¨t×/CÑ/CÓ/EØ/3×/@Ñ/@ô0Aà<Ø×*Ñ*Ó,Ð-¨Rð1ˆCä#*¨3£<ˆDÖ ñ	0AÑ)r+   c                ó.  € Wn         V P                  '       g   V P                  4       V n        V P                  '       g   \        R4      hV P	                  4       pV P
                  P                  \        RV P                  4        24      4       V! 4       # )a)  
Entry point for sos attempts to upload the generated archive to a
target or user specified location.

Currently there is support for HTTPS, SFTP, and FTP. HTTPS uploads are
preferred for target-defined defaults.

Targets that need to override uploading methods should override the
respective upload_https(), upload_sftp(), and/or upload_ftp() methods
and should NOT override this method.

:param archive: The archive filepath to use for upload
:type archive: ``str``

In order to enable this for a target, that target needs to implement
the following:

Required Class Attrs

:_upload_url:     The default location to use. Note these MUST include
                  protocol header
:_upload_user:    Default username, if any else None
:_upload_password: Default password, if any else None

The following Class Attrs may optionally be overidden by the Target

:_upload_directory:     Default FTP server directory, if any


The following methods may be overridden by ``Target`` as needed

`prompt_for_upload_user()`
    Determines if sos should prompt for a username or not.

`get_upload_user()`
    Determines if the default or a different username should be used

`get_upload_https_auth()`
    Format authentication data for HTTPS uploads

`get_upload_url_string()`
    Print a more human-friendly string than vendor URLs
zBNo upload destination provided by upload target or by --upload-urlzAttempting upload to )	rJ   r   rM   Ú	ExceptionÚ_determine_upload_typer#   rT   r_   Úget_upload_url_string)r'   ÚarchiveÚupload_funcs   && r(   Úupload_archiveÚUploadTarget.upload_archiveû   sƒ   € ðX $+Ô Ø��ˆØ"×1Ñ1Ó3ˆDŒOØ��ˆÜð 2ó 3ð 3à×1Ñ1Ó3ˆØ�‰×ÑÜÐ% d×&@Ñ&@Ó&BÐ%CÐDÓEô	
ñ ‹}Ðr+   c                óš  € RV P                   RV P                  RV P                  RV P                  /pV P                  R,          P
                  V9   d$   WP                  R,          P
                  ,          # RV P                  9  d   \        R4      hV P                  P                  R4      w  r#W!9  d   \        RV 24      hW,          # )	zâBased on the url provided, determine what type of upload to attempt.

Note that this requires users to provide a FQDN address, such as
https://myvendor.com/api or ftp://myvendor.com instead of
myvendor.com/api or myvendor.com
ÚftpÚsftpÚhttpsrG   r=   z://z#Must provide protocol in upload URLz&Unsupported or unrecognized protocol: )	Ú
upload_ftpÚupload_sftpÚupload_httpsÚ	upload_s3rC   r   r   rz   Úsplit)r'   ÚprotsÚprotr_   s   &   r(   r{   Ú#UploadTarget._determine_upload_type3  s³   € ð �4—?‘?Ø�D×$Ñ$Ø�T×&Ñ&Ø�$—.‘.ð	
ˆð �<‰<˜Õ&×6Ñ6¸%Ô?ØŸ™ mÕ4×DÑDÕEÐEØ˜Ÿ™Ô'ÜÐAÓBÐBØ—/‘/×'Ñ'¨Ó.‰ˆØÔÜÐDÀTÀFÐKÓLÐLØ�{Ðr+   c                ó    € V'       g   V P                  4       pV'       g   V P                  4       p\        P                  P	                  W4      # )a0  Formats the user/password credentials using basic auth

:param user: The username for upload
:type user: ``str``

:param password: Password for `user` to use for upload
:type password: ``str``

:returns: The user/password auth suitable for use in requests calls
:rtype: ``requests.auth.HTTPBasicAuth()``
)rs   rv   ÚrequestsÚauthÚHTTPBasicAuth)r'   ÚuserÚpasswords   &&&r(   Úget_upload_https_authÚ"UploadTarget.get_upload_https_authI  s;   € ÷ Ø×'Ñ'Ó)ˆDßØ×/Ñ/Ó1ˆHä�}‰}×*Ñ*¨4Ó:Ð:r+   c                ó€   € \         P                  ! RR4      ;'       g!    V P                  ;'       g    V P                  # )z«Helper function to determine if we should use the target default
upload access key or one provided by the user

:returns: The access_key to use for upload
:rtype: ``str``
ÚSOSUPLOADS3ACCESSKEYN)ÚosÚgetenvr   Ú_upload_s3_access_keyr.   s   &r(   r[   Ú%UploadTarget.get_upload_s3_access_key\  ó>   € ô —	’	Ð0°$Ó7÷ +ð +Ø×)Ñ)÷+ð +à×*Ñ*ð	,r+   c                ó^   € V P                   '       g   V P                  4        V P                   # )zªHelper function to determine if we should use the target default
upload endpoint or one provided by the user

:returns: The S3 Endpoint to use for upload
:rtype: ``str``
)r   rQ   r.   s   &r(   r]   Ú#UploadTarget.get_upload_s3_endpointg  s(   € ð ×&×&Ð&Ø×.Ñ.Ô0Ø×&Ñ&Ð&r+   c                óB   € V P                   ;'       g    V P                  # )z¦Helper function to determine if we should use the target default
upload region or one provided by the user

:returns: The S3 region to use for upload
:rtype: ``str``
)r   Ú_upload_s3_regionr.   s   &r(   Úget_upload_s3_regionÚ!UploadTarget.get_upload_s3_regionr  s   € ð ×$Ñ$×>Ð>¨×(>Ñ(>Ð>r+   c                óŠ  € V P                   '       dq   V P                   P                  R4      '       dP   V P                   R,          P                  R^4      pV^ ,          V n        \	        V4      ^8”  d   V^,          V n        V P                  '       g   V P                  4        V P                  ;'       g    V P                  # )z¦Helper function to determine if we should use the target default
upload bucket or one provided by the user

:returns: The S3 bucket to use for upload
:rtype: ``str``
rg   rh   r
   )r   rj   r‰   r   Úlenr   rP   Ú_upload_s3_bucket)r'   Úbucket_and_prefixs   & r(   r\   Ú!UploadTarget.get_upload_s3_bucket{  s—   € ð �?�?ˆ?˜tŸ™×9Ñ9¸'×BÒBØ $§¡°Õ 3× 9Ñ 9¸#¸qÓ AÐØ$5°aÕ$8ˆDÔ!ÜÐ$Ó%¨Ô)Ø/@ÀÕ/C�Ô,Ø×$×$Ð$Ø×,Ñ,Ô.Ø×$Ñ$×>Ð>¨×(>Ñ(>Ð>r+   c                óB   € V P                   ;'       g    V P                  # )z´Helper function to determine if we should use the target default
upload object prefix or one provided by the user

:returns: The S3 object prefix to use for upload
:rtype: ``str``
)r   Ú_upload_s3_object_prefixr.   s   &r(   Úget_upload_s3_object_prefixÚ(UploadTarget.get_upload_s3_object_prefix‹  s   € ð ×+Ñ+×LÐL¨t×/LÑ/LÐLr+   c                ó€   € \         P                  ! RR4      ;'       g!    V P                  ;'       g    V P                  # )z®Helper function to determine if we should use the target default
upload secret key or one provided by the user

:returns: The S3 secret key to use for upload
:rtype: ``str``
ÚSOSUPLOADS3SECRETKEYN)r—   r˜   r   Ú_upload_s3_secret_keyr.   s   &r(   rd   Ú%UploadTarget.get_upload_s3_secret_key”  r›   r+   c                ó,  € V P                   '       gd   V P                  '       dR   V P                  '       d@   V P                  '       d.   V P	                  4       pV P                  4       pRV RV 2V n        V P                   ;'       g    V P                  # )z�Helper function to determine if we should use the target default
upload url or one provided by the user

:returns: The URL to use for upload
:rtype: ``str``
rg   r
   )r   r   r   r   r\   r©   Ú_upload_url)r'   ÚbucketÚprefixs   &  r(   rM   ÚUploadTarget.get_upload_urlŸ  sz   € ð ��ˆØ×!×!Ð!Ø×%×%Ð%Ø×%×%Ð%à×.Ñ.Ó0ˆFØ×5Ñ5Ó7ˆFØ!& v h¨a°¨xÐ8ˆDÔØ�‰×2Ð2 $×"2Ñ"2Ð2r+   c                ó:   € R p\         P                  ! VRV4      pV# )z([^:]+://[^:]+:)([^@]+)(@.+)z\1********\3)ÚreÚsub)r'   ÚurlÚpatternÚobfuscated_urls   &&  r(   Ú_get_obfuscated_upload_urlÚ'UploadTarget._get_obfuscated_upload_url°  s   € Ø1ˆÜŸš ¨¸#Ó>ˆØÐr+   c                ó@   € V P                  V P                  4       4      # )z„Used by upload targets to potentially change the string used to
report upload location from the URL to a more human-friendly string
)rº   rM   r.   s   &r(   r|   Ú"UploadTarget.get_upload_url_stringµ  s   € ð ×.Ñ.¨t×/BÑ/BÓ/DÓEÐEr+   c                ó€   € \         P                  ! RR4      ;'       g!    V P                  ;'       g    V P                  # )z£Helper function to determine if we should use the target default
upload user or one provided by the user

:returns: The username to use for upload
:rtype: ``str``
ÚSOSUPLOADUSERN)r—   r˜   r   rw   r.   s   &r(   rs   ÚUploadTarget.get_upload_user»  s=   € ô —	’	˜/¨4Ó0÷ "ð "Ø× Ñ ÷"ð "à×!Ñ!ð	#r+   c                ó€   € \         P                  ! RR4      ;'       g!    V P                  ;'       g    V P                  # )a/  Helper function to determine if we should use the target default
upload password or one provided by the user

A user provided password, either via option or the 'SOSUPLOADPASSWORD'
environment variable will have precendent over any target value

:returns: The password to use for upload
:rtype: ``str``
ÚSOSUPLOADPASSWORDN)r—   r˜   rI   Ú_upload_passwordr.   s   &r(   rv   Ú UploadTarget.get_upload_passwordÆ  s>   € ô —	’	Ð-¨tÓ4÷ &ð &Ø×$Ñ$÷&ð &à×%Ñ%ð	'r+   c                óú  € \        R4      '       g   \        R4      h ^ RIpRpT'       g   T P	                  4       pT'       g   T P                  4       pT P                  4       P                  RR4      pRT R	T 2pTP                  TR
R7      p	RRRTP                  TP                  .p
T	P                  T
^R7      pT^ 8X  d   RpMãT^8X  dw   T	P                  T4       RRTP                  TP                  .pT	P                  T^
R7      ^ 8H  pT'       g-   T	P                  4        \        RT P                  4        24      hMfT^8X  d   \        RT P                  4        R24      hT^8X  d   \        RT P                  4        24      hT^8X  d   \        RT	P                   24      hT'       g-   T	P                  4        \        RT P                  4        24      hT'       d—   RpT	P                  R4       RRTP                  TP                  .pT	P                  T^
R7      ^ 8H  pT'       d%   T	P                  p\         P"                  ! TT4      pMT P$                  P'                  R4       RpT'       d   RpRT P(                   RT'       d   T R2MR T P+                  4        2pT	P                  T4       RTP                  TP                  R.pT	P                  T^´R7      pT^ 8X  d   T	P                  R 4       R# T^8X  d   \        R!4      hT^8X  d   \        R"T	P                   24      hT^8X  d   \        R#4      h\        R$T	P                   24      h  \         d   p\        R4      ThRp?ii ; i)%a}  Attempts to upload the archive to an SFTP location.

Due to the lack of well maintained, secure, and generally widespread
python libraries for SFTP, sos will shell-out to the system's local ssh
installation in order to handle these uploads.

Do not override this method with one that uses python-paramiko, as the
upstream sos team will reject any PR that includes that dependency.
rƒ   zSFTP is not locally supportedNzFSFTP upload requires python3-pexpect, which is not currently installedFzsftp://r   z sftp -oStrictHostKeyChecking=no Ú@zutf-8)Úencodingzsftp>z	password:zConnection refused©ÚtimeoutTzPermission deniedz#Incorrect username or password for zConnection refused by z. Incorrect port?z!Timeout hit trying to connect to z,Unexpected error trying to connect to sftp: zUnable to connect via SFTP to ÚpwdzInvalid command.z…This server does not support the PWD command - unable to verify user directory. Attempting upload without changing to user directory.zput Ú r
   z100%zNo such file or directoryÚbyezTimeout expired while uploadingzUnknown error during upload: z&Unable to write archive to destinationz!Unexpected response from server: )r   rz   ÚpexpectÚImportErrorrs   rv   rM   ÚreplaceÚspawnÚTIMEOUTÚEOFÚexpectÚsendlineÚcloser|   Úbeforerµ   Úsearchr#   ÚwarningrJ   Ú_get_sftp_upload_name)r'   r‘   r’   Úuser_dirrÍ   ÚerrÚsftp_connectedÚsftp_urlÚsftp_cmdÚretÚsftp_expectsÚidxÚpass_expectsÚ
user_matchÚpwd_expectsÚpwd_cmdÚ
raw_outputÚput_cmdÚput_expectsÚput_successs   &&&&                r(   r†   ÚUploadTarget.upload_sftpÔ  s¨  € ô ˜V×$Ò$ÜÐ;Ó<Ð<ð
	@Ûð
 ˆçØ×'Ñ'Ó)ˆDßØ×/Ñ/Ó1ˆHð ×&Ñ&Ó(×0Ñ0°¸BÓ?ˆØ5°d°V¸1¸X¸JÐGˆØ�m‰m˜H¨wˆmÓ7ˆð ØØ Ø�O‰OØ�K‰Kð
ˆð �j‰j˜¨rˆjÓ2ˆà�!Œ8Ø!‰NØ�AŒXØ�L‰L˜Ô"àØ#Ø—‘Ø—‘ð	ˆLð !ŸZ™Z¨¸b˜ZÓAÀQÑFˆNß!Ø—	‘	”ÜÐ EØ#'×#=Ñ#=Ó#?Ð"@ð!Bó Cð Cð "ð �AŒXÜÐ4Ø#×9Ñ9Ó;Ð<Ð<MðOó Pð Pà�AŒXÜÐ?Ø#×9Ñ9Ó;Ð<ð>ó ?ð ?à�AŒXÜÐJØ"Ÿz™z˜lð,ó -ð -÷ Ø�I‰IŒKÜÐ<Ø#×9Ñ9Ó;Ð<ð>ó ?ð ?÷ ØˆJØ�L‰L˜ÔàØ"Ø—‘Ø—‘ð	ˆKð —j‘j °b�jÓ9¸QÑ>ˆGßà ŸZ™Z�
ÜŸYšY t¨ZÓ8‘
à—‘×#Ñ#ð %Bô Cð  �çØ�ð
 �4×+Ñ+Ð,¨Aß!)�(�˜1‰~¨rÐ2Ø×)Ñ)Ó+Ð,ð.ð 	ð
 	�‰�WÔàØ�O‰OØ�K‰KØ'ð	
ˆð —j‘j °c�jÓ:ˆà˜!ÔØ�L‰L˜ÔÙØ˜!ÔÜÐ=Ó>Ð>Ø˜!ÔÜÐ;¸C¿J¹J¸<ÐHÓIÐIØ˜!ÔÜÐDÓEÐEÜÐ;¸C¿J¹J¸<ÐHÓIÐIøô] ô 	@Üð 6ó 7Ø<?ð@ûð	@ús   žM ÍM:Í)M5Í5M:c                óÂ   € V P                   P                  R4      R,          pV P                  '       d+   \        P                  P                  V P                  V4      pV# )züIf a specific file name pattern is required by the SFTP server,
override this method in the relevant Upload Target. Otherwise the
archive's name on disk will be used

:returns:       Filename as it will exist on the SFTP server
:rtype:         ``str``
r
   éÿÿÿÿ)rJ   r‰   r   r—   ÚpathÚjoin)r'   Úfnames   & r(   rÙ   Ú"UploadTarget._get_sftp_upload_nameW  sJ   € ð ×(Ñ(×.Ñ.¨sÓ3°BÕ7ˆØ× × Ð Ü—G‘G—L‘L ×!6Ñ!6¸Ó>ˆEØˆr+   c                óx   € \         P                  ! V P                  4       VV P                  4       V\        R7      # )zºIf upload_https() needs to use requests.put(), use this method.

Targets should override this method instead of the base upload_https()

:param archive:     The open archive file object
)Údatar�   ÚverifyrÉ   )rŽ   ÚputrM   r“   r   )r'   r}   ró   s   &&&r(   Ú_upload_https_putÚUploadTarget._upload_https_putd  s5   € ô �|Š|˜D×/Ñ/Ó1¸Ø!%×!;Ñ!;Ó!=Ø#)´?ôDð 	Dr+   c                ó   € / # )zJDefine any needed headers to be passed with the POST request here
        r-   r.   s   &r(   Ú_get_upload_headersÚ UploadTarget._get_upload_headerso  s	   € ð ˆ	r+   c                óâ   € RVP                   P                  R4      R,          VV P                  4       3/p\        P                  ! V P                  4       VV P                  4       V\        R7      # )z»If upload_https() needs to use requests.post(), use this method.

Targets should override this method instead of the base upload_https()

:param archive:     The open archive file object
Úfiler
   )Úfilesr�   ró   rÉ   rì   )r:   r‰   rø   rŽ   ÚpostrM   r“   r   )r'   r}   ró   rü   s   &&& r(   Ú_upload_https_postÚUploadTarget._upload_https_postt  sj   € ð �W—\‘\×'Ñ'¨Ó,¨RÕ0°'Ø×-Ñ-Ó/ð1ð
ˆô �}Š}˜T×0Ñ0Ó2¸%Ø"&×"<Ñ"<Ó">Ø$*´OôEð 	Er+   c                óz  € \         '       g   \        R4      h\        V P                  R4      ;_uu_ 4       pV P                  R,          P
                  R8X  d   V P                  pMV P                  R,          P
                  pV P                  R,          P                  RJ pVR8X  d   V P                  W4      pMV P                  W4      pVP                  R9  dB   VP                  R8X  d   \        R4      h\        R	VP                   R
VP                   24      h RRR4       R#   + '       g   i     R# ; i)z¥Attempts to upload the archive to an HTTPS location.

:returns: ``True`` if upload is successful
:rtype: ``bool``

:raises: ``Exception`` if upload was unsuccessful
z7Unable to upload due to missing python requests libraryÚrbr=   r   Frô   i‘  z/Authentication failed: invalid user credentialszPOST request returned rZ   NT)éÈ   éÉ   )ÚREQUESTS_LOADEDrz   ÚopenrJ   rC   r   Ú_upload_methodr   rõ   rþ   Ústatus_codeÚreason)r'   ÚarcÚmethodró   Úrs   &    r(   r‡   ÚUploadTarget.upload_httpsƒ  s  € ÷ ‹Üð &ó 'ð 'ô �$×*Ñ*¨D×1Ô1°SØ�|‰|˜MÕ*×8Ñ8¸FÔBØ×,Ñ,‘àŸ™ mÕ4×BÑB�Ø—\‘\ -Õ0×EÑEÈÐNˆFØ˜ŒØ×*Ñ*¨3Ó7‘à×+Ñ+¨CÓ8�Ø�}‰} JÔ.Ø—=‘= CÔ'Ü#ØIóð ô  Ð"8¸¿¹¸ÀrØ#$§8¡8 *ð!.ó /ð /à÷# 2×1×1Ò1ús   ¶C)D)Ä)D:	c                ó^  € ^ RI p^ RIpV'       g   V P                  4       pVf   \        R4      hVP	                  RR4      pV'       g   V P                  4       pV'       g   V P                  4       pV'       g!   V P                  ;'       g    V P                  p VP                  WV^R7      pV'       g   \        R4      hVP                  V4       \!        T P"                  R4      ;_uu_ 4       p
TP%                  RT P"                  P                  R4      R,           2T
4       RRR4       TP'                  4        R#   TP                   d   p\        RT 24      ThRp?iTP                   d   p\        RT 24      ThRp?iTP                   d‚   p\        T4      P                  4       ^ ,          p	T	R	8X  d   \        R
T R24      ThT	R8X  d   \        RT R24      ThT	R8X  d   \        RT 24      Th\        R\        T4       24      ThRp?ii ; i  + '       g   i     Lý; i)aì  Attempts to upload the archive to either the target defined or user
provided FTP location.

:param url: The URL to upload to
:type url: ``str``

:param directory: The directory on the FTP server to write to
:type directory: ``str`` or ``None``

:param user: The user to authenticate with
:type user: ``str``

:param password: The password to use for `user`
:type password: ``str``

:returns: ``True`` if upload is successful
:rtype: ``bool``

:raises: ``Exception`` if upload in unsuccessful
NzPno FTP server specified by upload target, use --upload-url to specify a locationzftp://r   rÈ   z3connection failed, did you set a user and password?z timeout hit while connecting to zunable to connect to Ú503zcould not login as 'Ú'Ú530zinvalid password for user 'Ú550z"could not set upload directory to z#error trying to establish session: r  zSTOR r
   Trì   )ÚftplibÚsocketrM   rz   rÏ   rs   rv   r   Ú_upload_directoryÚFTPÚcwdrÉ   ÚgaierrorÚ
error_permÚstrr‰   r  rJ   Ú
storbinaryÚquit)r'   r·   Ú	directoryr‘   r’   r  r  ÚsessionrÛ   ÚerrnoÚ_arcfiles   &&&&&      r(   r…   ÚUploadTarget.upload_ftp¢  s  € ó* 	ÛçØ×%Ñ%Ó'ˆCØŠ;Üð Eó Fð Fð �k‰k˜( BÓ'ˆçØ×'Ñ'Ó)ˆDçØ×/Ñ/Ó1ˆHçØ×-Ñ-×GÐG°×1GÑ1GˆIð	Ø—j‘j ¨H¸b�jÓAˆGßÜð !,ó -ð -à�K‰K˜	Ô"ô" �$×*Ñ*¨D×1Ô1°XØ×ÑØ˜×0Ñ0×6Ñ6°sÓ;¸BÕ?Ð@ÐAÀ8ô÷ 2ð 	�‰ŒÙøð+ �~‰~ô 	OÜÐ>¸s¸eÐDÓEÈ3ÐNûØ�‰ô 	DÜÐ3°C°5Ð9Ó:ÀÐCûØ× Ñ ô 
	Ü˜“H—N‘NÓ$ QÕ'ˆEØ˜Œ~ÜÐ"6°t°f¸AÐ >Ó?ÀSÐHØ˜Œ~ÜÐ"=¸d¸VÀ1Ð EÓFÈCÐOØ˜Œ~ÜÐ DØ#, +ð!/ó 0Ø58ð9äÐAÄ#ÀcÃ(ÀÐLÓMØðûð
	ú÷ 2×1úsI   Â8E Ã16HÅHÅE!Å!HÅ4HÅ5FÆHÆHÆA<HÈHÈH,	c                ó0  € \         '       g   \        R4      hV'       g   V P                  4       pV'       g   V P                  4       pV'       g    V P	                  4       P                  R4      pV'       ge   V P                  4       pVR8w  d!   VP                  R4      '       d
   VR,          pVR8w  d'   VP                  R4      '       g   V'       d   V R2MRpV'       g   V P                  4       pV'       g   V P                  4       p\        P                  ! RVVVVR7      p W@P                  P                  R4      R
,          ,           pVP                  V P                  W84       R#   \         d   p	\        R\!        T	4       24      T	hR	p	?	ii ; i)a5  Attempts to upload the archive to an S3 bucket.

:param endpoint: The S3 endpoint to upload to
:type endpoint: str

:param region: The S3 region to upload to
:type region: str

:param bucket: The name of the S3 bucket to upload to
:type bucket: str

:param prefix: The prefix for the S3 object/key
:type prefix: str

:param access_key: The access key for the S3 bucket
:type access_key: str

:param secret_key: The secret key for the S3 bucket
:type secret_key: str

:returns: True if upload is successful
:rtype: bool

:raises: Exception if upload is unsuccessful
z4Unable to upload due to missing python boto3 libraryr
   r   :é   NNrG   )Úendpoint_urlÚregion_nameÚaws_access_key_idÚaws_secret_access_keyTzFailed to upload to S3: Nrì   )ÚBOTO3_LOADEDrz   r]   r    r\   rk   r©   rj   Úendswithr[   rd   Úboto3ÚclientrJ   r‰   r   r  )
r'   ÚendpointÚregionr±   r²   Ú
access_keyÚ
secret_keyÚ	s3_clientÚkeyÚes
   &&&&&&&   r(   rˆ   ÚUploadTarget.upload_s3è  sY  € ÷6 ‹|Üð &ó 'ð '÷ Ø×2Ñ2Ó4ˆHßØ×.Ñ.Ó0ˆFçØ×.Ñ.Ó0×6Ñ6°sÓ;ˆFçØ×5Ñ5Ó7ˆFØ˜Œ| × 1Ñ 1°#× 6Ò 6Ø ��Ø˜Œ| F§O¡O°C×$8Ò$8ß)/˜F˜8 1™°R�çØ×6Ñ6Ó8ˆJçØ×6Ñ6Ó8ˆJä—L’L °HØ-3Ø3=Ø7AôCˆ	ð
	HØ×3Ñ3×9Ñ9¸#Ó>¸rÕBÕBˆCØ×!Ñ! $×":Ñ":Ø"(ô/áøÜô 	HÜÐ6´s¸1³v°hÐ?Ó@ÀaÐGûð	Hús   Ä'AE- Å-FÅ8FÆF)r°   r&   r%   rC   r?   r$   r#   rJ   r   rI   r   r   r   r   r   r   r   r   )NNN)NN)T)NNNN)NNNNNN)Er7   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Údescr6   r2   Ú_upload_filer°   r  rw   rÃ   r  ro   r¤   r™   r­   rŸ   r¨   r   r   rI   r   r   r   r   r   r   r   Úarg_defaultsr)   r/   r3   Úclassmethodr:   r@   rD   rV   rR   rS   rP   rQ   rN   rO   r   r{   r“   r[   r]   r    r\   r©   rd   rM   rº   r|   rs   rv   r†   rÙ   rõ   rø   rþ   r‡   r…   rˆ   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r(   r   r       sF  ø‡ € ñð€Dð *ÐØ ÐØ€LØ€KØÐØ€LØÐØ€NØ4ÐØÐØ ÐØ ÐØÐØ!ÐØ€JØ€KØ€OØÐØÐØÐØÐØÐØ"ÐØ€MðØ�rðà�2ðð 	˜ðð 	�Bð	ð
 	�dðð 	˜Dðð 	�tðð 	�tðð 	˜ðð 	 ðð 	˜6ðð 	˜dðð 	˜Dðð 	˜Dðð 	 ðð  	 ð!ð" 	" 4ð#ð$ 	˜ñ%€Lô*òò%ð ñ$ó ð$ò
òò(!òT6ò
5ò
%ò'ò-ò0ò6òpô,;ò&	,ò	'ò?ò?ò Mò	,ò3ò"ò
Fò	#ò'ôAJòFô	Dòô
Eòô>D÷L?Hò ?Hr+   r   )r—   rµ   r!   r   Úsosr   r_   Úsos.utilitiesr   r   rŽ   r  rÎ   r)  r'  r   r-   r+   r(   Ú<module>r@     sl   ðó 
Û 	Û å Ý ß 8ðÛØ€OðÛØ€L÷
GHó GHøð ô Ø‚Oðûð ô Ø‚Lðús    ¢; ©A
 »	AÁAÁ
	AÁA