
    Vh'                        d dl mZ d dlZd dlZd dlmZmZmZmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZmZ d d
lmZmZ  e       Z G d de      Zy)    )annotationsN)AnsibleConnectionFailureAnsibleErrorAnsibleActionFailAnsibleActionSkip)to_bytesto_text)string_types)boolean)
ActionBase)Display)checksum
checksum_smd5secure_hash)makedirs_safe
is_subpathc                        e Zd Zd fd	Z xZS )ActionModulec                .   |
t               }t        t        |   ||      }~	 | j                  j
                  rt        d      | j                  j                  j                  dd      }| j                  j                  j                  dd      x}}t        | j                  j                  j                  d      d      }t        | j                  j                  j                  dd	      d      }t        | j                  j                  j                  d
d	      d      }	d}
t        |t              sd}
t        |t              sd}
||d}
|
rt        |
      | j                  j                  j                  |      }| j!                  |      }i }d}| j                  j"                  s	 | j%                  ||d	      }|j                  d      }|j                  d      rf|j                  d      rUd	|d<   d|d<   d|d<   |s|dxx   dz  cc<   |d= |d= || j-                  | j                  j                  j.                         S d}|dv r| j1                  dt        |      |      }|j                  d      r|s||d<   d|d<   n|j3                  |       d |j                  dd      v rd!|d<   n&|j                  dd      j5                  d"      rd|d<   || j-                  | j                  j                  j.                         S |d#   d$k(  rt7        j8                  |d%         }|t;        |      }t<        j>                  j@                  | j                  j                  j                  d&d      vr8| j                  j                  jC                  |      }|jE                  d'd(      }n|}tG        ||      st        d)|d*|d+      |rt<        j>                  jI                  tK        |d,            r*|jM                  t<        j@                        st        d-      |jM                  t<        j@                        rxt<        j>                  jO                  |      }t<        j>                  jQ                  ||      }t<        j>                  jI                  tK        |d,            rt        d.| d/      |j5                  d(      s_| jR                  jU                  |      }nCd0|v r|d0   }n| jV                  jX                  }| jR                  jU                  |      d(|d(|}t<        j>                  j[                  |      }t]        |      }||k7  rt_        t<        j>                  ja                  |             || j                  jc                  ||       n9	 te        tK        |d,      d1      }|jg                  |       |ji                          to        |      }	 tq        |      }|	r(||k7  r#|j3                  t        d	|d3||d||4             nD|j3                  d	||d||d5       n+	 tq        |      }|j3                  t        d||||6             | j-                  | j                  j                  j.                         |S # t&        $ r  t(        $ rn}d|d<   ||d<   |rd	|d<   t+        |      |d<   ndt+        |d      z  |d<   |cY d}~| j-                  | j                  j                  j.                         S d}~ww xY w# tj        tl        f$ r}t        d2|z        d}~ww xY w# tr        $ r d}Y Uw xY w# tr        $ r d}Y w xY w# | j-                  | j                  j                  j.                         w xY w)7z handler for fetch operations Nz.check mode not (yet) supported for this modulesrcdestflatF)strictfail_on_missingTvalidate_checksum z<Invalid type supplied for source option, it must be a stringz:Invalid type supplied for dest option, it must be a stringzsrc and dest are required)all_varsfollowchangedfilefailedmsgz%s, ignoredsurrogate_or_replace)errorsr   existsisdirz<remote file is a directory, fetch cannot work on directoriesz, not transferring, ignored)N1r   zansible.legacy.slurp)r   )module_namemodule_args	task_varsz	not foundz9the remote file does not exist, not transferring, ignoredzsource is a directoryencodingbase64contenta\/z;Detected directory traversal, expected to be contained in 'z' but got ''surrogate_or_strictz`dest is an existing directory, use a trailing slash if you want to fetch src into that directoryzcalculated dest 'zY' is an existing directory, use another path that does not point to an existing directoryinventory_hostnamewbzFailed to fetch the file: %szchecksum mismatch)r"   md5sumr#   r!   r   remote_md5sumr   remote_checksum)r    r6   r   r7   r   r8   )r    r6   r!   r   r   ):dictsuperr   run_task
check_moder   argsgetr   
isinstancer
   r   _connection_shell	join_path_remote_expand_userbecome_execute_remote_statr   r   r	   _remove_tmp_pathtmpdir_execute_moduleupdate
startswithr-   	b64decoder   ospathsep_unquotereplacer   r'   r   endswithbasenamejoin_loader	path_dwim_play_contextremote_addrnormpathr   r   dirname
fetch_fileopenwritecloseIOErrorOSErrorr   r   
ValueError)selftmpr+   resultsourceoriginal_destr   r   r   r   r#   remote_statr8   aeremote_dataslurpressource_localbasetarget_namelocal_checksumfenew_checksumnew_md5	local_md5	__class__s                            L/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/action/fetch.pyr;   zActionModule.run#   s
   I|T.sI>g	Bzz$$'(XYYZZ__((5F#'::??#6#6vt#DDMD4::??..v6uED%djjoo&9&9:KT&R[`aO '

(;(;<OQU(V_d eCfl3TdL1R~1',,%%,,66v>F--f5FK"O##**""&";";FY_c";"dK #.//*"=??8,"w/+/x(,1y)(fu  /"5M-JJM &y 1 &x 0%N !!$"2"2"9"9"@"@AI K/1//<R`dio`p  }F/  G<<)*)/v,1y)h/"hll5"&==(cu!eR0;;<ST(fu!j !!$"2"2"9"9"@"@Ag  
+x7&,&6&6x	7J&K".*4[*A ww{{$"2"2"9"9"C"CC"LL))0099&A%~~dC8% dM2'  zG  IM  )N  O  O77==$7L!MNW[WdWdegekekWl+  -O  P  P==( 77++L9D77<<d3Dww}}Xd;P%QR//v  6O  PQ Qs+<<11$7D (94"+,@"AK"&"4"4"@"@K%)\\%;%;D%A;P\]77##D)D &d^N.0bggood34 &$$//=T $7L!MtT,	  +40#!$iG %)HMM$d7+>VRVfj0<o#_ ` MMdgt48l6E#G H
% #D	I d5VZestu !!$"2"2"9"9"@"@AO 0 # 	"(-F9%%+F6N&+/x((/u(5Ka8b(bu!Mt !!$"2"2"9"9"@"@AG	"R $W- T/0NQR0RSST " #"G# " % $I%
 !!$"2"2"9"9"@"@As   F
]# /Z A]# B]# J]# )8\ !]# -\? 8A]# <] ]# \)4\\]# \]# \<)\77\<<]# ?]
]# ]]# ] ]# ]  ]# #1^)NN)__name__
__module____qualname__r;   __classcell__)rt   s   @ru   r   r   !   s    q q    r   )
__future__r   rM   r-   ansible.errorsr   r   r   r   +ansible.module_utils.common.text.convertersr   r	   ansible.module_utils.sixr
   )ansible.module_utils.parsing.convert_boolr   ansible.plugins.actionr   ansible.utils.displayr   ansible.utils.hashingr   r   r   r   ansible.utils.pathr   r   displayr    rz   ru   <module>r      sC   " # 	  g g I 1 = - ) H H 8
)s: srz   