
    u                     Z    S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr   " S S\	5      r
g	)
zBase classes for diagnostics.    )absolute_import)division)unicode_literals)log)progress_trackerc                   B    \ rS rSrSrSrS rS rSS jrSS jr	S r
S	rg
)
Diagnostic   zBase class for diagnostics.

Attributes:
  intro: A message to introduce the objectives and tasks of the diagnostic.
  title: The name of the diagnostic.
  checklist: An iterator of checkbase.Check objects to be run by the
     diagnostic.
   c                 (    Xl         X l        X0l        g)a   Initializes Diagnostic with necessary attributes.

Args:
  intro: A message to introduce the objectives and tasks of the diagnostic.
  title: The name of the diagnostic.
  checklist: An iterable of checkbase.Check objects to be run by the
     diagnostic.
N)introtitle	checklist)selfr   r   r   s       6lib/googlecloudsdk/core/diagnostics/diagnostic_base.py__init__Diagnostic.__init__&   s     JJN    c                    U R                  U R                  5        SnU R                   GH   nU R                  U5      u  p4SnUR                  (       dg  U(       a`  XPR
                  :  aQ  US-  nU" 5       nU(       a  U R                  USS9u  p4OSnUR                  (       d  U(       a  XPR
                  :  a  MQ  UR                  (       dF  U(       a?  XPR
                  :X  a0  [        R                  " SR                  U R                  U5      5        UR                  (       d  M  US-  nGM     [        U R                  5      nX:H  nSR                  U R                  UUU(       a  SOS	S
9n	U R                  X(       + S9  U$ )zqRuns one or more checks, tries fixes, and outputs results.

Returns:
  True if the diagnostic ultimately passed.
r      F	first_runNz-Unable to fix {0} failure after {1} attempts.z<{check} {status} ({num_passed}/{num_checks} checks passed).
passedfailed)check
num_passed
num_checksstatus)as_error)_Printr   r   	_RunCheckr   _MAX_RETRIESr   warningformatr   len)
r   num_checks_passedr   resultfixernum_retriesshould_check_againr   r   summarys
             r   	RunChecksDiagnostic.RunChecks3   s?    	KK

nnU+mf k%K:K:K,Kq"W..%.@-&%% %K:K:K,K ]]u8I8I)ICJJJJ% 	&	Q%  ( T^^$J,FNvDJJ!2!+)/XX  ? 
 	KK*K-Mr   c                     [         R                  " SR                  U(       a  SOSUR                  5      5         UR	                  US9u  p4S S S 5        U R                  W5        UW4$ ! , (       d  f       N#= f)Nz{0} {1}Checking
Recheckingr   )r   ProgressTrackerr$   issueCheck_PrintResult)r   r   r   r'   r(   s        r   r!   Diagnostic._RunCheckZ   sk    		)	))*:*:
\5;;+@ 
AkkIk6mf
A 	f5=	
A 
As   A))
A7c                 v    U(       d  [         R                  R                  O[         R                  nU" U5        g N)r   r   Printerror)r   messager   loggers       r   r    Diagnostic._Printa   s     %-SZZ399F
7Or   c                 Z    U R                  UR                  UR                  (       + 5        g r7   )r    r:   r   )r   r'   s     r   r4   Diagnostic._PrintResulte   s    KKFMM 12r   )r   r   r   N)T)F)__name__
__module____qualname____firstlineno____doc__r"   r   r,   r!   r    r4   __static_attributes__ r   r   r	   r	      s(     ,%N3r   r	   N)rC   
__future__r   r   r   googlecloudsdk.corer   googlecloudsdk.core.consoler   objectr	   rE   r   r   <module>rJ      s'     $ &  ' # 8L3 L3r   