
                            S r SSKJr  SSKJr  SSKJ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.    )absolute_import)division)unicode_literalsN)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)	GCloudExecutionEnvironment0   z?ExecutionEnvironment implemented using gcloud's core functions.c                 ,    [         R                  " 5       $ N)r	   GetPythonExecutableselfs    r   r$   .GCloudExecutionEnvironment.GetPythonExecutable3   s    ..00r   c                 ,    [         R                  " 5       $ r#   )r   	CanPromptr%   s    r   r)   $GCloudExecutionEnvironment.CanPrompt6   s    !!r   c                 .    [         R                  " U5      $ r#   )r   PromptResponser&   messages     r   r,   )GCloudExecutionEnvironment.PromptResponse9   s    $$W--r   c                 @    [         R                  R                  U5      $ r#   )r
   statusPrintr-   s     r   r2    GCloudExecutionEnvironment.Print<   s    ::G$$r   r   N)
r   r   r   r   r   r$   r)   r,   r2   r   r   r   r   r    r    0   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__I   s    JDI%"7r   c                     U R                   $ r#   )r;   r%   s    r   ALLOWED_RUNTIME_NAMES'CoreRuntimeLoader.ALLOWED_RUNTIME_NAMESR   s    &&&r   c                     U R                   $ r#   )r:   r%   s    r   NAMECoreRuntimeLoader.NAMEW   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#   )r9   ospathjoinr   r8   r   ExternalizedRuntimeLoadr    Fingerprint)r&   rI   paramspath_to_runtimes       r   rM   CoreRuntimeLoader.Fingerprint[   s[    99%6%8$**Eo1166
579di99  ..r   )r;   r8   r9   r:   N)r   r   r   r   r   r?   propertyrB   rE   rM   r   r   r   r   r5   r5   @   s9    8 ' '  /r   r5   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   GetNonInteractiveErrorMessagerY   h   s8     ++3355 000 r   )r   
__future__r   r   r   rH   gae_ext_runtimer   googlecloudsdk.corer   r   r	   r
   r   googlecloudsdk.core.consoler   Errorr   r   ExecutionEnvironmentr    objectr5   rX   rY   r   r   r   <module>ra      sq    @ &  ' 	 ' & * / # * 2?)) ?(%!A!A %  /  /H  
r   