
    
                         d 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 ddlmZ dd	lmZ dd
lmZ d Zd Zy)z:Tools for opening URL:s related to the app in the browser.    )absolute_import)division)unicode_literals)
exceptions)deploy_command_util)appinfo)check_browser)log)devshellc                     ddl }t        j                         s.t        j                  j                  dj                  |              |j                  |        y)zfOpen a URL in the default web browser in a new tab.

  Args:
    url: The full HTTP(S) URL to open.
  r   Nz3Opening [{0}] in a new tab in your default browser.)
webbrowserr   IsDevshellEnvironmentr
   statusPrintformatopen_new_tab)urlr   s     8lib/googlecloudsdk/command_lib/app/browser_dispatcher.pyOpenURLr      sD      
	'	'	)JJ=DDSIK#    c                 0   	 t        j                  | ||t        j                  d      }t        j                  |      rt        |       y||xs d|dS # t        j
                  $ r- t        j                  dd       t        j                  |       w xY w)	a  Let you browse the given service at the given version.

  Args:
    project: str, project ID.
    service: str, specific service, 'default' if None
    version: str, specific version, latest if None
    launch_browser: boolean, if False only print url

  Returns:
    None if the browser should open the URL
    The relevant output as a dict for calliope format to print if not

  Raises:
    MissingApplicationError: If an app does not exist.
  F)app_idserviceversionuse_ssldeployzNo app found:T)exc_infoNdefault)r   r   r   )r   GetAppHostnamer   SECURE_HTTPSapitools_exceptionsHttpNotFoundErrorr
   debugr   MissingApplicationErrorr	   ShouldLaunchBrowserr   )projectr   r   launch_browserr   s        r   	BrowseAppr(   0   s     6

,
,$$U4C &&~6CL 'i  
	.	. 6IIo-

,
,W
556s   (A A BN)__doc__
__future__r   r   r   apitools.base.pyr   r!   googlecloudsdk.api_lib.appr   googlecloudsdk.appengine.apir   googlecloudsdk.command_lib.appgooglecloudsdk.command_lib.utilr	   googlecloudsdk.corer
   googlecloudsdk.core.credentialsr   r   r(    r   r   <module>r3      s3     A &  ' > : 0 5 9 # 4"r   