# Path: gslib/context_config.py
# _DEFAULT_METADATA_PATH = os.path.expanduser(
#     os.path.join('~', '.secureConnect', 'context_aware_metadata.json'))
# _CERT_PROVIDER_COMMAND = "cert_provider_command"
# _CERT_PROVIDER_COMMAND_PASSPHRASE_OPTION = "--with_passphrase"
# class CertProvisionError(Exception):
# class ContextConfigSingletonAlreadyExistsError(Exception):
# class _ContextConfig(object):
# def _is_pem_section_marker(line):
# def _split_pem_into_sections(contents, logger):
# def _check_path():
# def _read_metadata_file(metadata_path):
# def _default_command():
#   def __init__(self, logger):
#   def _provision_client_cert(self, cert_path):
#   def _unprovision_client_cert(self):
# def create_context_config(logger):
# def get_context_config():
# 
# Path: gslib/exception.py
# class CommandException(StandardError):
#   """Exception raised when a problem is encountered running a gsutil command.
# 
#   This exception should be used to signal user errors or system failures
#   (like timeouts), not bugs (like an incorrect param value). For the
#   latter you should raise Exception so we can see where/how it happened
#   via gsutil -D (which will include a stack trace for raised Exceptions).
#   """
# 
#   def __init__(self, reason, informational=False):
#     """Instantiate a CommandException.
# 
#     Args:
#       reason: Text describing the problem.
#       informational: Indicates reason should be printed as FYI, not a failure.
#     """
#     StandardError.__init__(self)
#     self.reason = reason
#     self.informational = informational
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'CommandException: %s' % self.reason


import os
import pkgutil
import tempfile
import textwrap
import six
import boto
import boto.auth
import gslib
import httplib2
  import gcs_oauth2_boto_plugin
  import socket
  import ssl
from boto import config
from boto.exception import NoAuthHandlerFound
from boto.gs.connection import GSConnection
from boto.provider import Provider
from boto.pyami.config import BotoConfigLocations
from gslib import context_config
from gslib.exception import CommandException
from gslib.utils import system_util
from gslib.utils.constants import DEFAULT_GCS_JSON_API_VERSION
from gslib.utils.constants import DEFAULT_GSUTIL_STATE_DIR
from gslib.utils.constants import SSL_TIMEOUT_SEC
from gslib.utils.constants import UTF8
from gslib.utils.unit_util import HumanReadableToBytes
from gslib.utils.unit_util import ONE_MIB
from oauth2client.client import HAS_CRYPTO
      from gslib import no_op_auth_plugin  # pylint: disable=unused-variable

  ##Get Proxy configuration from boto file, defaults are None, 0 and False
  proxy_host = config.get('Boto', 'proxy', None)  #needed for if clause below
  boto_proxy_config = {
      'proxy_host':
          proxy_host,
      'proxy_type':
          config.get('Boto', 'proxy_type', 'http'),
      'proxy_port':
          config.getint('Boto', 'proxy_port'),
      'proxy_user':
          config.get('Boto', 'proxy_user', None),
      'proxy_pass':
          config.get('Boto', 'proxy_pass', None),
      'proxy_rdns':
          config.get('Boto', 'proxy_rdns', True if proxy_host else None)
  }

  #Use SetProxyInfo to convert boto config to httplib2.proxyinfo object
  proxy_info = SetProxyInfo(boto_proxy_config)

  # Some installers don't package a certs file with httplib2, so use the
  # one included with gsutil.
  kwargs['ca_certs'] = GetCertsFile()
  # Use a non-infinite SSL timeout to avoid hangs during network flakiness.
  kwargs['timeout'] = SSL_TIMEOUT_SEC
  http = http_class(proxy_info=proxy_info, **kwargs)
  http.disable_ssl_certificate_validation = (not config.getbool(
      'Boto', 'https_validate_certificates'))


# Path: gslib/context_config.py
# _DEFAULT_METADATA_PATH = os.path.expanduser(
#     os.path.join('~', '.secureConnect', 'context_aware_metadata.json'))
# _CERT_PROVIDER_COMMAND = "cert_provider_command"
# _CERT_PROVIDER_COMMAND_PASSPHRASE_OPTION = "--with_passphrase"
# class CertProvisionError(Exception):
# class ContextConfigSingletonAlreadyExistsError(Exception):
# class _ContextConfig(object):
# def _is_pem_section_marker(line):
# def _split_pem_into_sections(contents, logger):
# def _check_path():
# def _read_metadata_file(metadata_path):
# def _default_command():
#   def __init__(self, logger):
#   def _provision_client_cert(self, cert_path):
#   def _unprovision_client_cert(self):
# def create_context_config(logger):
# def get_context_config():
# 
# Path: gslib/exception.py
# class CommandException(StandardError):
#   """Exception raised when a problem is encountered running a gsutil command.
# 
#   This exception should be used to signal user errors or system failures
#   (like timeouts), not bugs (like an incorrect param value). For the
#   latter you should raise Exception so we can see where/how it happened
#   via gsutil -D (which will include a stack trace for raised Exceptions).
#   """
# 
#   def __init__(self, reason, informational=False):
#     """Instantiate a CommandException.
# 
#     Args:
#       reason: Text describing the problem.
#       informational: Indicates reason should be printed as FYI, not a failure.
#     """
#     StandardError.__init__(self)
#     self.reason = reason
#     self.informational = informational
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'CommandException: %s' % self.reason


# Path: gslib/utils/boto_util.py
import os
import pkgutil
import tempfile
import textwrap
import six
import boto
import boto.auth
import gslib
import httplib2
  import gcs_oauth2_boto_plugin
  import socket
  import ssl
from boto import config
from boto.exception import NoAuthHandlerFound
from boto.gs.connection import GSConnection
from boto.provider import Provider
from boto.pyami.config import BotoConfigLocations
from gslib import context_config
from gslib.exception import CommandException
from gslib.utils import system_util
from gslib.utils.constants import DEFAULT_GCS_JSON_API_VERSION
from gslib.utils.constants import DEFAULT_GSUTIL_STATE_DIR
from gslib.utils.constants import SSL_TIMEOUT_SEC
from gslib.utils.constants import UTF8
from gslib.utils.unit_util import HumanReadableToBytes
from gslib.utils.unit_util import ONE_MIB
from oauth2client.client import HAS_CRYPTO
      from gslib import no_op_auth_plugin  # pylint: disable=unused-variable


  ##Get Proxy configuration from boto file, defaults are None, 0 and False
  proxy_host = config.get('Boto', 'proxy', None)  #needed for if clause below
  boto_proxy_config = {
      'proxy_host':
          proxy_host,
      'proxy_type':
          config.get('Boto', 'proxy_type', 'http'),
      'proxy_port':
          config.getint('Boto', 'proxy_port'),
      'proxy_user':
          config.get('Boto', 'proxy_user', None),
      'proxy_pass':
          config.get('Boto', 'proxy_pass', None),
      'proxy_rdns':
          config.get('Boto', 'proxy_rdns', True if proxy_host else None)
  }

  #Use SetProxyInfo to convert boto config to httplib2.proxyinfo object
  proxy_info = SetProxyInfo(boto_proxy_config)

  # Some installers don't package a certs file with httplib2, so use the
  # one included with gsutil.
  kwargs['ca_certs'] = GetCertsFile()
  # Use a non-infinite SSL timeout to avoid hangs during network flakiness.
  kwargs['timeout'] = SSL_TIMEOUT_SEC
  http = http_class(proxy_info=proxy_info, **kwargs)
  http.disable_ssl_certificate_validation = (not config.getbool(
      'Boto', 'https_validate_certificates'))


  global_context_config = context_config.get_context_config()