
                             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
ZdZdZd Zd Zd Zd Zy)z/Utility functions for gcloud bigtable emulator.    )absolute_import)division)unicode_literalsN)util)execution_utils)log)	platformsbigtablezGoogle Cloud Bigtable emulatorcbtemulatorc                  4    t        j                  t              S )N)r   
GetDataDirBIGTABLE     9lib/googlecloudsdk/command_lib/emulators/bigtable_util.pyr   r       s    		""r   c                 "   t        j                  t              }t        j                  j                  |t              }t        j                  j                         t        j                  j                  u r|dz  }t        j                  |g|  S )zBuilds the command for starting the bigtable emulator.

  Args:
    args: (list of str) The arguments for the bigtable emulator, excluding the
      program binary.

  Returns:
    A list of command arguments.
  z.exe)r   GetEmulatorRootr   ospathjoinBIGTABLE_EXECUTABLEr	   OperatingSystemCurrentWINDOWSr   ArgsForExecutableTool)argsbigtable_dirbigtable_executables      r   BuildStartArgsr   $   so     %%h/,\3FG&&(I,E,E,M,MM6!		.	./B	JT	JJr   c                 d    d| j                   j                  d| j                   j                  iS )zCReturns an environment variable mapping from an argparse.Namespace.BIGTABLE_EMULATOR_HOST:)	host_porthostport)r   s    r   GetEnvr&   5   s-     ^^(($..*=*=
>
 r   c                    t        t        j                  |             }t        j                  j                  dj                  dj                  |                   t        j                  |      5 }t        j                  t        |       t                      t        j                  |t               d d d        y # 1 sw Y   y xY w)NzExecuting: {0} )r   r   BuildArgsListr   statusPrintformatr   ExecWriteEnvYamlr&   r   PrefixOutputr   )r   bigtable_argsbigtable_processs      r   Startr2   =   s     !3!3D!9:-**#**388M+BCDyy#3fTlJL1&1  s   1AB<<C)__doc__
__future__r   r   r   r   $googlecloudsdk.command_lib.emulatorsr   googlecloudsdk.corer   r   googlecloudsdk.core.utilr	   r   BIGTABLE_TITLEr   r   r   r&   r2   r   r   r   <module>r9      sG    6 &  ' 	 5 / # .1# #K"2r   