def main(): parser = argparse.ArgumentParser() parser.add_argument('--check-credentials', required=False, action='store_true') parser.add_argument('--check-updates', required=False, action='store_true') parser.add_argument('--command-name', required=True) parser.add_argument('--component-id') args = parser.parse_args() bootstrapping.CommandStart(args.command_name, component_id=args.component_id) if args.check_credentials: bootstrapping.CheckCredOrExit() if args.check_updates: bootstrapping.CheckUpdates(args.command_name)
_MaybeAddOption(args, 'project', project) proxy_params = properties.VALUES.proxy _MaybeAddOption(args, 'proxy_address', proxy_params.address.Get()) _MaybeAddOption(args, 'proxy_port', proxy_params.port.Get()) _MaybeAddOption(args, 'proxy_username', proxy_params.username.Get()) _MaybeAddOption(args, 'proxy_password', proxy_params.password.Get()) _MaybeAddOption(args, 'disable_ssl_validation', properties.VALUES.auth.disable_ssl_validation.GetBool()) _MaybeAddOption(args, 'ca_certificates_file', properties.VALUES.core.custom_ca_certs_file.Get()) bootstrapping.ExecutePythonTool('platform/bq', 'bq.py', *args) if __name__ == '__main__': bootstrapping.CommandStart('bq', component_id='bq') blacklist = { 'init': 'To authenticate, run gcloud auth.', } bootstrapping.CheckForBlacklistedCommand(sys.argv, blacklist, warn=True, die=True) cmd_args = [arg for arg in sys.argv[1:] if not arg.startswith('-')] if cmd_args and cmd_args[0] not in ('version', 'help'): # Check for credentials only if they are needed. bootstrapping.CheckCredOrExit() bootstrapping.CheckUpdates('bq') main()
def main(): """Launches bq.""" project, account = bootstrapping.GetActiveProjectAndAccount() json_path = config.Paths().LegacyCredentialsJSONPath(account) gce_metadata = gce.Metadata() if gce_metadata and account in gce_metadata.Accounts(): args = ['--use_gce_service_account'] else: args = ['--credential_file', json_path] if project: args += ['--project', project] bootstrapping.ExecutePythonTool( 'platform/bq', 'bq.py', *args) if __name__ == '__main__': bootstrapping.CommandStart('bq', component_id='bq') blacklist = { 'init': 'To authenticate, run gcloud auth.', } bootstrapping.CheckForBlacklistedCommand(sys.argv, blacklist, warn=True, die=True) bootstrapping.CheckCredOrExit(can_be_gce=True) bootstrapping.CheckUpdates('bq') main()