
    g                     |    S SK r S SKrS SKJr  S SKJr  S SKJrJ	r	J
r
Jr  S SKJr   " S S\5      r " S S\5      rg)	    N)system_session)CommandCommandErrorOptionSuperCommand)SamDBc            	           \ rS rSrSrSr\" SSS\SSS	9\" S
S\S9\" SS\S9/r	S/r
\R                  \R                  \R                  S.rS rSrg)cmd_domain_tombstones_expunge"   zZExpunge tombstones from the database.

This command expunges tombstones from the database.z%prog NC [NC [...]] [options]z-Hz--URLz%LDB URL for database or target serverURLH)helptypemetavardestz--current-timezQThe current time to evaluate the tombstone lifetime from, expressed as YYYY-MM-DD)r   r   z--tombstone-lifetimez2Number of days a tombstone should be preserved forznc*)	sambaoptscredoptsversionoptsc                    UR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      nUR                  5       nUR                  U5      n	[        U[	        5       XS9n
Uc+  Uc(  [        SU R                  S9  [        S	U R                  S9  Ub7  [        R                  " US
5      n[        [        R                  " U5      5      nO[        [        R                  " 5       5      n[        U5      S:X  aM  U
R                  SS[        R                  S/S9n/ nUS   S    H  nUR                  [!        U5      5        M     O[#        U5      nSn U
R%                  5         SnU
R'                  UUUS9u  nnU
R/                  5         U R                  R1                  SUU4-  5        g ! [(         a(  nU(       a  U
R+                  5         [-        SU5      eS nAff = f)Nr   r   r   current_timetombstone_lifetime)urlsession_infocredentialslpztNote: without --current-time or --tombstone-lifetime only tombstones already scheduled for deletion will be deleted.)filez5To remove all tombstones, use --tombstone-lifetime=0.z%Y-%m-%dr    namingContexts)
expressionbasescopeattrsFT)r   r   z.Failed to expunge / garbage collect tombstonesz-Removed %d objects and %d links successfully
)getget_loadparmget_credentialsr   r   printoutftimestrptimeintmktimelensearchldb
SCOPE_BASEappendstrlisttransaction_startgarbage_collect_tombstones	Exceptiontransaction_cancelr   transaction_commitwrite)selfncskwargsr   r   r   current_time_stringr   r   credssamdbcurrent_time_objr   resncstarted_transactionremoved_objectsremoved_linkserrs                      @/usr/lib/python3/dist-packages/samba/netcmd/domain/tombstones.pyrun!cmd_domain_tombstones_expunge.run9   s   JJ{+	::j)JJsO$jj8#ZZ(<=##%((,!.*:"'0 &+=+E  &*ii1 Iyy" *#}}-@*Mt{{+;<=L tyy{+Ls8q=,,"2S^^&6%7  9C C!f-.

3r7# / s)C#	V##%"&#>>sLXRd ? f_ 	  "		H*M:; 	<  	V"((*OQTUU	Vs   :&G 
H#G>>H N)__name__
__module____qualname____firstlineno____doc__synopsisr   r1   r*   takes_options
takes_argsoptionsSambaOptionsCredentialsOptionsVersionOptionstakes_optiongroupsrG   __static_attributes__rI       rF   r
   r
   "   s    7 /H 	tW#JQT3	(g	 	%,`gjkM J ))..--4<rX   r
   c                   0    \ rS rSrSr0 r\" 5       \S'   Srg)cmd_domain_tombstonesp   z0Domain tombstone and recycled object management.expungerI   N)rJ   rK   rL   rM   rN   subcommandsr
   rW   rI   rX   rF   rZ   rZ   p   s    :K:<K	rX   rZ   )r(   r.   samba.getoptgetoptrR   
samba.authr   samba.netcmdr   r   r   r   samba.samdbr   r
   rZ   rI   rX   rF   <module>rc      s7   2  
  % D D K<G K<\=L =rX   