
                             S r SSK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KJ	r	  SS	K
Jr   " S
 S\R                  5      rS r " S S\R                  5      r " S S\5      rSrS rg)z9Adapter to use externalized runtimes loaders from gcloud.    N)ext_runtime)config)
exceptions)execution_utils)log)
properties)
console_ioc                       \ rS rSrSrSrg)NoRuntimeRootError   z6Raised when we can't determine where the runtimes are. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       5lib/googlecloudsdk/api_lib/app/ext_runtime_adapter.pyr   r      s    >r   r   c                      [         R                  R                  R                  R	                  5       n U (       a  U $ [        S5      e)NzUnable to determine the root directory where GAE runtimes are stored.  Please define the CLOUDSDK_APP_RUNTIME_ROOT environmnent variable.)r   VALUESappruntime_rootGetr   )r   s    r   _GetRuntimeDefDirr   "   s=    ""&&33779, ' 	( (r   c                   0    \ rS rSrSrS rS rS rS rSr	g)	GCloudExecutionEnvironment-   z?ExecutionEnvironment implemented using gcloud's core functions.c                 ,    [         R                  " 5       $ N)r   GetPythonExecutableselfs    r   r!   .GCloudExecutionEnvironment.GetPythonExecutable0   s    ..00r   c                 ,    [         R                  " 5       $ r    )r	   	CanPromptr"   s    r   r&   $GCloudExecutionEnvironment.CanPrompt3   s    !!r   c                 .    [         R                  " U5      $ r    )r	   PromptResponser#   messages     r   r)   )GCloudExecutionEnvironment.PromptResponse6   s    $$W--r   c                 @    [         R                  R                  U5      $ r    )r   statusPrintr*   s     r   r/    GCloudExecutionEnvironment.Print9   s    ::G$$r   r   N)
r   r   r   r   r   r!   r&   r)   r/   r   r   r   r   r   r   -   s    G1".%r   r   c                   D    \ rS rSrSrS r\S 5       r\S 5       rS r	Sr
g)	CoreRuntimeLoader=   a.  A loader stub for the core runtimes.

The externalized core runtimes are currently distributed with the cloud sdk.
This class encapsulates the name of a core runtime to avoid having to load
it at module load time.  Instead, the wrapped runtime is demand-loaded when
the Fingerprint() method is called.
c                 6    Xl         S U l        X l        X0l        g r    )_name_rep_visible_name_allowed_runtime_names)r#   namevisible_nameallowed_runtime_namess       r   __init__CoreRuntimeLoader.__init__F   s    JDI%"7r   c                     U R                   $ r    )r8   r"   s    r   ALLOWED_RUNTIME_NAMES'CoreRuntimeLoader.ALLOWED_RUNTIME_NAMESO   s    &&&r   c                     U R                   $ r    )r7   r"   s    r   NAMECoreRuntimeLoader.NAMET   s    r   c                    U R                   (       d_  [        R                  R                  [	        5       U R
                  5      n[        R                  R                  U[        5       5      U l         U R                   R                  X5      $ r    )r6   ospathjoinr   r5   r   ExternalizedRuntimeLoadr   Fingerprint)r#   rF   paramspath_to_runtimes       r   rJ   CoreRuntimeLoader.FingerprintX   s[    99%6%8$**Eo1166
579di99  ..r   )r8   r5   r6   r7   N)r   r   r   r   r   r<   propertyr?   rB   rJ   r   r   r   r   r2   r2   =   s9    8 ' '  /r   r2   zZ("disable_prompts" set to true, run "gcloud config set disable_prompts False" to fix this)c                      [         R                  R                  R                  R	                  5       (       a	  S[
        -   $ g)aw  Returns useful instructions when running non-interactive.

Certain fingerprinting modules require interactive functionality.  It isn't
always obvious why gcloud is running in non-interactive mode (e.g. when
"disable_prompts" is set) so this returns an appropriate addition to the
error message in these circumstances.

Returns:
  (str) The appropriate error message snippet.
  )r   r   coredisable_promptsGetBool_PROMPTS_DISABLED_ERROR_MESSAGEr   r   r   GetNonInteractiveErrorMessagerV   e   s8     ++3355 000 r   )r   rE   gae_ext_runtimer   googlecloudsdk.corer   r   r   r   r   googlecloudsdk.core.consoler	   Errorr   r   ExecutionEnvironmentr   objectr2   rU   rV   r   r   r   <module>r]      sj    @ 
 ' & * / # * 2?)) ?(%!A!A %  /  /H  
r   