+
    gQ                      ~   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
HtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ]P>                  ! 4       t R
t! ! R R]PD                  4      t#R t$R R lt%RR lt&R t'R t(RR lt)R t*R t+R t,R R lt-R R lt.R t/R R R llt0R t1R# )!    Nwraps)Optional)
actionsapidaemonentitlementsevent_logger
exceptionslockmessagesstatusutil)CVE_OR_USN_REGEX)_is_attached)AptProxyScopesetup_apt_proxyUAConfig)machine_tokenz[Kc                   V   a  ] tR t^!t o V 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )	CLIEnableDisableProgressc                    < V ^8  d   QhRS[ /# )   
assume_yesbool)format__classdict__s   "7/usr/lib/python3/dist-packages/uaclient/cli/cli_util.py__annotate__%CLIEnableDisableProgress.__annotate__"   s     % %d %    c               *    V'       * V n         Wn        R # N)is_interactiver   )selfr   s   &$r    __init__!CLIEnableDisableProgress.__init__"   s    ",n$r#   c          	      R   < V ^8  d   QhRS[ RS[ RS[S[,          RS[S[,          /# )r   total_steps
done_stepsprevious_step_messagecurrent_step_message)intr   str)r   r   s   "r    r!   r"   &   s=     	( 	( 	( 		(
  (}	( 'sm	(r#   c               (    Ve   \        V4       R # R # r%   )print)r'   r+   r,   r-   r.   s   &$$$$r    progress!CLIEnableDisableProgress.progress&   s      +&' ,r#   c                    < V ^8  d   QhRS[ /# )r   event)r0   )r   r   s   "r    r!   r"   1   s     5 5s 5r#   c                    VR 8X  d   \        V4       R# VR8X  d>   \        P                  ! W P                  4      '       g   \        P
                  ! 4       hR# R# )infomessage_operationN)r2   r   handle_message_operationsr   r   PromptDeniedError)r'   r6   payloads   &&&r    	_on_event"CLIEnableDisableProgress._on_event1   sH    F?'N))11'??KK 2244 L *r#   )r   r&   N)	__name__
__module____qualname____firstlineno__r(   r3   r=   __static_attributes____classdictcell__)r   s   @r    r   r   !   s#     % %	( 	(5 5r#   r   c                      R # r%    )argskwargss   *,r    _null_printrI   9   s    r#   c                $    V ^8  d   QhR\         /# )r   json_outputr   )r   s   "r    r!   r!   =   s       r#   c                 *    V '       d   \         # \        # r%   )rI   r2   )rK   s   &r    &create_interactive_only_print_functionrM   =   s    r#   c                   a  V 3R lpV# )z1Decorator asserting exclusive access to lock filec                 4   <a  \        S 4      V V3R  l4       pV# )c                    < \         P                  ! S^R7      ;_uu_ 4        S! VRV /VB pRRR4       V#   + '       g   i     X# ; i)   )lock_holder
sleep_timecfgN)r   	RetryLock)rT   rG   rH   retvalfrR   s   $*, r    new_f0assert_lock_file.<locals>.wrapper.<locals>.new_fH   sB    KAFFD4c4V4 GM GFMs	   7A	r   )rW   rX   rR   s   f r    wrapper!assert_lock_file.<locals>.wrapperG   s     	q	 
	
 r#   rF   )rR   rZ   s   f r    assert_lock_filer\   D   s     Nr#   c                0   a  \        S 4      V 3R l4       pV# )zDecorator asserting root userc                  t   < \         P                  ! 4       '       g   \        P                  ! 4       hS! V / VB # r%   )r   we_are_currently_rootr   NonRootUserError)rG   rH   rW   s   *,r    rX   assert_root.<locals>.new_fV   s1    ))++--//d%f%%r#   r   rW   rX   s   f r    assert_rootrc   S   s"     1X& & Lr#   c                0   a  \        S 4      V 3R l4       pV# )z>Decorator to verify if correct params are used for json formatc                    < V '       g   S! V .VO5/ VB # V P                   R 8X  d(   V P                  '       g   \        P                  ! 4       hS! V .VO5/ VB # )json)r   r   r   CLIJSONFormatRequireAssumeYes)cmd_argsrG   rH   rW   s   &*,r    rX   &verify_json_format_args.<locals>.new_fc   sV    X////??f$X-@-@-@::<<X////r#   r   rb   s   f r    verify_json_format_argsrj   `   s"     1X0 0 Lr#   c                   a  V 3R lpV# )zDecorator asserting attached config.
:param msg_function: Optional function to generate a custom message
if raising an UnattachedError
c                 4   <a  \        S 4      V V3R  l4       pV# )c                    < \        V4      P                  '       gC   S'       d&   \        V R R4      p\        V RR4      pS! W4VR7       M\        P                  ! 4       hS! V 3RV/VB # )command service)rn   service_namesrT   rT   )r   is_attachedgetattrr   UnattachedError)rG   rT   rH   rn   rq   rW   raise_custom_error_functions   &&,  r    rX   /assert_attached.<locals>.wrapper.<locals>.new_fw   sf    $000.%dIr:G$+D)R$@M/ '# %4466T-s-f--r#   r   )rW   rX   ru   s   f r    rZ    assert_attached.<locals>.wrapperv   s     	q
	. 

	. r#   rF   )ru   rZ   s   f r    assert_attachedrx   p   s      Nr#   c                0   a  \        S 4      V 3R l4       pV# )z&Decorator asserting unattached config.c                    < \        V4      P                  '       dG   \        P                  ! 4       p\        P
                  ! VP                  P                  R R4      R7      hS! V 3RV/VB # )namero   )account_namerT   )r   rr   r   get_machine_token_filer   AlreadyAttachedErroraccountget)rG   rT   rH   machine_token_filerW   s   &&, r    rX   "assert_not_attached.<locals>.new_f   sc    (((!.!E!E!G11/77;;FBG  )3)&))r#   r   rb   s   f r    assert_not_attachedr      s"     1X* * Lr#   c                    a  V 3R  lpV# )c                 4   <a  \        S 4      VV 3R  l4       pV# )c                    < \        V R R4      p\        P                  ! \        V4      '       g   \        P
                  ! VSR7      hS! V 3RV/VB # )security_issuero   )issuecmdrT   )rs   rematchr   r   InvalidSecurityIssueIdFormat)rG   rT   rH   r   r   rW   s   &&, r    rX   @assert_vulnerability_issue_valid.<locals>.wrapper.<locals>.new_f   sT    $T+;R@N88,n== ==( 
 T-s-f--r#   r   )rW   rX   r   s   f r    rZ   1assert_vulnerability_issue_valid.<locals>.wrapper   s     	q	. 
	. r#   rF   )r   rZ   s   f r     assert_vulnerability_issue_validr      s     Nr#   c                t   \         P                  ! WR7      w  ppV'       dA   V'       d9   \        P                  ! RP	                  V4      V RP	                  V4      RR7      hV'       d(   \        P
                  ! RP	                  V4      V R7      h\        P                  ! V RP	                  V4      RR7      h)zRaises a custom error for enable/disable commands when unattached.

Takes into consideration if the services exist or not, and notify the user
accordingly.)namesrT   z, ro   )valid_service	operationinvalid_serviceservice_msg)r   r   )r   r   r   )r	   get_valid_entitlement_namesr   UnattachedMixedServicesErrorjoinUnattachedValidServicesErrorUnattachedInvalidServicesError)rn   rq   rT   entitlements_foundentitlements_not_founds   &&&  r    &_raise_enable_disable_unattached_errorr      s     	00}N455))$67 II&<=	
 	
 
55))$677
 	
 77 II&<=
 	
r#   c                (    V ^8  d   QhR\         RR/# )r   rT   returnNr   )r   s   "r    r!   r!      s       d r#   c                 4   \         P                  ! V 4      pVP                  pV'       d5   \        P	                  \
        P                  P                  VR 7      4       M#\        P	                  \
        P                  4       \        P                  ! 4        \        P                  ! V 4       \        P                  ! V 4      w  r4\        P                  ! V4      p\        P	                  \        P                   ! V4      4       \        P#                  4        R# ))contract_nameN)r   r}   r   r6   r8   r   ATTACH_SUCCESS_TMPLr   ATTACH_SUCCESS_NO_CONTRACT_NAMEr   stopcleanupr   r   format_tabularr   handle_unicode_charactersprocess_events)rT   r   r   status_dict_retoutputs   &     r    post_cli_attachr      s    &==cB&44M

((//m/L	
 	

8;;<
KKM
NN3s+K"";/F	JJt--f56	r#   c          
      b    V ^8  d   QhR\         R\        R\        R\        \        ,          RR/# )r   rT   scopeset_key	set_valuer   N)r   r   r0   r   )r   s   "r    r!   r!      s>      	  }	
 
r#   c                    V\         P                  8X  d   V P                  pV P                  pM-V\         P                  8X  d   V P
                  pV P                  pRV9   d   TpMTp\        XXVR7       R# )zK
Handles setting part the apt proxies - global and uaclient scoped proxies
https)
http_proxyhttps_proxyproxy_scopeN)r   GLOBALglobal_apt_http_proxyglobal_apt_https_proxyUACLIENTua_apt_http_proxyua_apt_https_proxyr   )rT   r   r   r   r   r   s   &&&&  r    configure_apt_proxyr      sm     $$$..
00	-((	(**
,,'
;Er#   c                    \         P                  ! . RO4      pV P                  4       '       g   \        P                  P                  RP                  V\        V4      \        4      4       \        P                  P                  4        \        P                  ! R4       \        P                  P                  R4       K  R# )|z{}{}{}g?N)r   /-\)	itertoolscycleis_setsysstdoutwriter   nextCLEAR_LINE_ANSI_CODEflushtimesleep)stop_spinnermsgspinners   && r    run_spinnerr      s}    oo34G!!##

c4=2FG	
 	



3

 $r#   c                :    V ^8  d   QhR\         \        ,          /# )r   r   )r   r0   )r   s   "r    r!   r!      s      hsm r#   c                    a  V 3R  lpV# )c                 4   <a  \        S 4      V V3R  l4       pV# )c                  < \         P                  P                  4       '       g   S! V 3R V/VB # \        P                  ! 4       p\        P
                  ! \        VS3R7      pVP                  4        S! V 3R V/VB pVP                  4        VP                  4        \         P                  P                  R\        ,           4       \         P                  P                  4        V# )rT   )targetrG   )r   r   isatty	threadingEventThreadr   startsetr   r   r   r   )rG   rT   rH   r   spinner_threadrV   rW   r   s   &$,   r    rX   ,with_spinner.<locals>.wrapper.<locals>.new_f   s    ::$$&&131&11$??,L&--",)<N   "t///F!JJT$889JJMr#   r   )rW   rX   r   s   f r    rZ   with_spinner.<locals>.wrapper   s     	q	 
	* r#   rF   )r   rZ   s   f r    with_spinnerr      s    2 Nr#   c                 >   V R 8X  dA   \         P                  P                  V ,           \         P                  P                  ,           # V R8X  dA   \         P                  P                  V ,           \         P                  P                  ,           # V R8X  dA   \         P                  P
                  V ,           \         P                  P                  ,           # V R8X  dA   \         P                  P                  V ,           \         P                  P                  ,           # V # )lowmediumhighcritical)r   TxtColorINFOBLUEENDCWARNINGYELLOWORANGEFAIL)prioritys   &r    colorize_priorityr     s    5  ))H4x7H7H7M7MMM	X	++h69J9J9O9OO	
 
V	  ''(2X5F5F5K5KKK	Z	  %%083D3D3I3IIIr#   r%   )ro   )2r   r   r   r   r   	functoolsr   typingr   uaclientr   r   r   r	   r
   r   r   r   r   r   'uaclient.api.u.pro.security.fix._commonr   (uaclient.api.u.pro.status.is_attached.v1r   uaclient.aptr   r   uaclient.configr   uaclient.filesr   get_event_loggerr6   r   AbstractProgressr   rI   rM   r\   rc   rj   rx   r   r   r   r   r   r   r   r   rF   r#   r    <module>r      s     	 
       E A 7 $ (%%'   5s33 50	
 2$
8(0:r#   