def finalize_options(self): if platform.system() != "Windows": self.curl = which('curl') self.bash = which('bash') self.gcloud_url = "https://sdk.cloud.google.com" self.silent = "--disable-prompts" else: self.silent = "/S" self.gcloud_url = "https://dl.google.com/dl/cloudsdk/channels/" \ "rapid/GoogleCloudSDKInstaller.exe" self.package_index = PackageIndex()
def needs_gcloud(self): """Returns true if gcloud is unavailable and needed for authentication.""" gcloud_default_path = ['google-cloud-sdk', 'bin'] if platform.system() != "Windows": gcloud_default_path = os.path.join(os.path.expanduser('~'), *gcloud_default_path) else: gcloud_default_path = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Cloud SDK', *gcloud_default_path) return not os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/') \ and gcloud_default_path not in os.environ["PATH"].split(os.pathsep) \ and which('gcloud') is None
import subprocess import sys import time import logging import docker from firecloud import which from hydrant.ConfigLoader import ConfigLoader from six import u # Convenient shorthands for readability from docker.errors import APIError as apiError from requests.exceptions import ConnectionError as connError # Add credential helpers if they're missing if which('docker') is not None: credHelpers = docker.auth.load_config().get('credHelpers') if not credHelpers or \ sum(helper.endswith('gcr.io') for helper in credHelpers) == 0: logging.info("Credential helpers for gcr.io not found. Attempting to" + " install.") try: output = subprocess.check_output( ['gcloud', 'auth', 'configure-docker', '--quiet'], stderr=subprocess.STDOUT) logging.info(output.decode('utf-8')) except subprocess.CalledProcessError as cpe: logging.warning(u' '.join(cpe.cmd) + u":\n\t" + cpe.output.decode('utf-8'))