
                             U d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ej                  dk\  rej                  e   Ze	ed<   nej                  Ze	ed<   dadefd	Z	 dd
ee   dee   defdZy)z'Utilities to run gcloud for the BQ CLI.    N)ListOptional)	TypeAlias)	resources)   	   GcloudPopenreturnc                      t         r t        j                  dt                t         S dt        j                  k(  rd} nd} 	 t        j                  d      } t        j                  d|        | a | S # t        $ r Y %w xY w)z)Returns the string to use to call gcloud.zFound cached gcloud path: %sntz
gcloud.cmdgcloudz#google3/cloud/sdk/gcloud/gcloud.parzFound gcloud path: %s)_gcloud_pathlogginginfoosnamer   GetResourceFilenameFileNotFoundError)binarys    +platform/bq/gcloud_wrapper/gcloud_runner.py_get_gcloud_pathr      sx     LL/>	RWW_FF	**-F 
,,&/,	- 
 		s    A/ /	A;:A;cmdstderrc                     t               }t        j                  d|dj                  |              t	        j
                  |g| z   t        j                  |d      S )z;Runs the given gcloud command and returns the Popen object.zRunning gcloud command: %s %s T)stdoutr   universal_newlines)r   r   r   join
subprocessPopenPIPE)r   r   gcloud_paths      r   run_gcloud_commandr#   1   sO     !"+	,,.SXXc]K			mc__	
     )N)__doc__r   r   r   systypingr   r   typing_extensionsr   pyglibr   version_infor    strr	   __annotations__r   r   intr#    r$   r   <module>r/      s    -  	  
 ! ' v%++C0+y0 &+++y+# 6 -1	c$SMr$   