1#!/usr/bin/python 2# Copyright 2015 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import argparse 7import os 8import subprocess 9import sys 10 11 12def _AddToPathIfNeeded(path): 13 if path not in sys.path: 14 sys.path.insert(0, path) 15 16 17def Main(): 18 catapult_path = os.path.abspath(os.path.join( 19 os.path.dirname(__file__), os.path.pardir, os.path.pardir)) 20 parser = argparse.ArgumentParser() 21 parser.add_argument('--appid', default='performance-insights') 22 parser.add_argument('--version', default='pi-test') 23 args = parser.parse_args() 24 25 _AddToPathIfNeeded( 26 os.path.join(catapult_path, 'perf_insights')) 27 from perf_insights.endpoints import cloud_mapper 28 paths = cloud_mapper.PathsForDeployment() 29 30 _AddToPathIfNeeded(catapult_path) 31 from catapult_build import temp_deployment_dir 32 33 file_sets = [ 34 ['app.yaml', 'cron.yaml', 'dispatch.yaml', 'queue.yaml', 'index.yaml', 35 'remote_worker.yaml'] 36 ] 37 for cur_set in file_sets: 38 with temp_deployment_dir.TempDeploymentDir( 39 paths, use_symlinks=False) as temp_dir: 40 cmd = ['gcloud', 'preview', 'app', 'deploy'] 41 cmd += cur_set 42 cmd += [ 43 '--project=%s' % args.appid, 44 '--version=%s' % args.version, 45 '--force', '--quiet', '--no-promote', '--docker-build', 'local'] 46 subprocess.call(cmd, cwd=temp_dir) 47 48if __name__ == '__main__': 49 Main() 50 51