Ë
    €Ï  ã                   ó  — d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ddlmZ  G d„ de
j                   «      Zd„ Z G d„ dej&                  «      Z G d„ de«      ZdZd„ Zy)z9Adapter to use externalized runtimes loaders from gcloud.é    )Úabsolute_import)Údivision)Úunicode_literalsN)Úext_runtime)Úconfig)Ú
exceptions)Úexecution_utils)Úlog)Ú
properties)Ú
console_ioc                   ó   — e Zd ZdZy)ÚNoRuntimeRootErrorz6Raised when we can't determine where the runtimes are.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú5lib/googlecloudsdk/api_lib/app/ext_runtime_adapter.pyr   r   !   s   „ Ú>r   r   c                  ó„   — t         j                  j                  j                  j	                  «       } | r| S t        d«      ‚)Nz‰Unable 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                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚGCloudExecutionEnvironmentz?ExecutionEnvironment implemented using gcloud's core functions.c                 ó*   — t        j                  «       S ©N)r	   ÚGetPythonExecutable©Úselfs    r   r    z.GCloudExecutionEnvironment.GetPythonExecutable3   s   € Ü×.Ñ.Ó0Ð0r   c                 ó*   — t        j                  «       S r   )r   Ú	CanPromptr!   s    r   r$   z$GCloudExecutionEnvironment.CanPrompt6   s   € Ü×ÑÓ!Ð!r   c                 ó,   — t        j                  |«      S r   )r   ÚPromptResponse©r"   Úmessages     r   r&   z)GCloudExecutionEnvironment.PromptResponse9   s   € Ü×$Ñ$ WÓ-Ð-r   c                 ó@   — t         j                  j                  |«      S r   )r
   ÚstatusÚPrintr'   s     r   r+   z GCloudExecutionEnvironment.Print<   s   € Ü:‰:×Ñ˜GÓ$Ð$r   N)r   r   r   r   r    r$   r&   r+   r   r   r   r   r   0   s   „ ÙGò1ò"ò.ó%r   r   c                   ó<   — e Zd ZdZd„ Zed„ «       Zed„ «       Zd„ Zy)ÚCoreRuntimeLoadera8  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                 ó<   — || _         d | _        || _        || _        y r   )Ú_nameÚ_repÚ_visible_nameÚ_allowed_runtime_names)r"   ÚnameÚvisible_nameÚallowed_runtime_namess       r   Ú__init__zCoreRuntimeLoader.__init__I   s    € Ø€D„JØ€D„IØ%€DÔØ"7€DÕr   c                 ó   — | j                   S r   )r2   r!   s    r   ÚALLOWED_RUNTIME_NAMESz'CoreRuntimeLoader.ALLOWED_RUNTIME_NAMESR   s   € à×&Ñ&Ð&r   c                 ó   — | j                   S r   )r1   r!   s    r   ÚNAMEzCoreRuntimeLoader.NAMEW   s   € à×ÑÐr   c                 ó  — | j                   s_t        j                  j                  t	        «       | j
                  «      }t        j                  j                  |t        «       «      | _         | j                   j                  ||«      S r   )r0   ÚosÚpathÚjoinr   r/   r   ÚExternalizedRuntimeÚLoadr   ÚFingerprint)r"   r=   ÚparamsÚpath_to_runtimes       r   rA   zCoreRuntimeLoader.Fingerprint[   s]   € Ø9Š9ÜŸ™Ÿ™Ô%6Ó%8¸$¿*¹*ÓE€oÜ×1Ñ1×6Ñ6Ø
Ô5Ó7ó9€d„ià9‰9× Ñ   vÓ.Ð.r   N)	r   r   r   r   r6   Úpropertyr8   r:   rA   r   r   r   r-   r-   @   s9   „ ñò8ð ñ'ó ð'ð ñó ðó/r   r-   zZ("disable_prompts" set to true, run "gcloud config set disable_prompts False" to fix this)c                  óz   — t         j                  j                  j                  j	                  «       r	dt
        z   S y)a…  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   ÚGetNonInteractiveErrorMessagerL   h   s5   € ô ×Ñ×Ñ×+Ñ+×3Ñ3Ô5ð Ô0Ñ0Ð0ð r   )r   Ú
__future__r   r   r   r<   Úgae_ext_runtimer   Úgooglecloudsdk.corer   r   r	   r
   r   Úgooglecloudsdk.core.consoler   ÚErrorr   r   ÚExecutionEnvironmentr   Úobjectr-   rK   rL   r   r   r   Ú<module>rT      sq   ðñ @å &Ý Ý 'ã 	å 'å &Ý *Ý /Ý #Ý *Ý 2ô?˜×)Ñ)ô ?ò(ô% ×!AÑ!Aô %ô  /˜ô  /ðHð  ó
r   