File: //opt/cppython/lib/python3.8/site-packages/google/auth/__pycache__/_cloud_sdk.cpython-38.pyc
U
KD�g\ � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ dZdZdZ dZ
d Zd
ZdZ
dZd
d� Zdd� Zdd� Zdd� Zddd�ZdS )z9Helpers for reading the Google Cloud SDK's configuration.� N)�_helpers)�environment_vars)�
exceptionsZgcloud�APPDATAz$application_default_credentials.jsonz
gcloud.cmd)�config�get�project)�authzprint-access-tokenzH764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.comc C s� zt jtj W S tk
r" Y nX t jdkrFt j�t j�d�dt �S zt j�t jt
t �W S tk
r� t j�dd�} t j�| dt � Y S X dS )z�Returns the absolute path the the Cloud SDK's configuration directory.
Returns:
str: The Cloud SDK config path.
�nt�~z.configZSystemDrivezC:�\N)�os�environr ZCLOUD_SDK_CONFIG_DIR�KeyError�name�path�join�
expanduser�_CONFIG_DIRECTORY�_WINDOWS_CONFIG_ROOT_ENV_VARr )�drive� r �C/opt/cppython/lib/python3.8/site-packages/google/auth/_cloud_sdk.py�get_config_path- s
�r c C s t � } tj�| t�S )z�Gets the path to the application default credentials file.
The path may or may not exist.
Returns:
str: The full path to application default credentials.
)r r
r r �_CREDENTIALS_FILENAME)Zconfig_pathr r r �(get_application_default_credentials_pathI s r c C s* t tjd��}tj| |d�}W 5 Q R X |S )zJ Return subprocess.check_output with the given command and ignores stderr.�w��stderr)�openr
�devnull�
subprocess�check_output)�commandr �outputr r r �_run_subprocess_ignore_stderrU s r% c
C sb t jdkrt} nt} z*t| ft �}t�|��� }|r:|ndW S t j
ttfk
r\ Y dS X dS )zaGets the project ID from the Cloud SDK.
Returns:
Optional[str]: The project ID.
r
N)
r
r �_CLOUD_SDK_WINDOWS_COMMAND�_CLOUD_SDK_POSIX_COMMANDr% �%_CLOUD_SDK_CONFIG_GET_PROJECT_COMMANDr �
from_bytes�stripr! �CalledProcessError�OSError�IOError)r# r r r r �get_project_id\ s
�r. c
C s� t jdkrt}nt}zD| r0|ft d| f }n
|ft }tj|tjd�}|�d�� � W S tj
ttfk
r� } zt
�d|�}||�W 5 d}~X Y nX dS )a� Load user access token with the ``gcloud auth print-access-token`` command.
Args:
account (Optional[str]): Account to get the access token for. If not
specified, the current active account will be used.
Returns:
str: The user access token.
Raises:
google.auth.exceptions.UserAccessTokenError: if failed to get access
token from gcloud.
r
z
--account=r zutf-8zFailed to obtain access tokenN)r
r r&