Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: catapult_build/appengine_deploy.py

Issue 2701113002: Migrate to the Google Cloud SDK. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | dashboard/bin/deploy » ('j') | dashboard/docs/getting-set-up.md » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # TODO(qyearsley): Add a step to vulcanize each template HTML file. 5 # TODO(qyearsley): Add a step to vulcanize each template HTML file.
6 # TODO(qyearsley): Add a step to put static files in a versioned 6 # TODO(qyearsley): Add a step to put static files in a versioned
7 # directory and modify app.yaml and request_handler as needed. 7 # directory and modify app.yaml and request_handler as needed.
8 8
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 12
13 from catapult_build import temp_deployment_dir 13 from catapult_build import temp_deployment_dir
14 14
15 15
16 def AppcfgUpdate(paths, app_id, service_name=None): 16 def Deploy(paths, args):
17 """Deploys a new version of an App Engine app from a temporary directory. 17 """Deploys a new version of an App Engine app from a temporary directory.
18 18
19 Args: 19 Args:
20 paths: List of paths to files and directories that should be linked 20 paths: List of paths to files and directories that should be linked
21 (or copied) in the deployment directory. 21 (or copied) in the deployment directory.
22 app_id: The application ID to use. 22 args: Arguments passed to "gcloud app deploy".
23 """ 23 """
24 with temp_deployment_dir.TempDeploymentDir( 24 with temp_deployment_dir.TempDeploymentDir(
25 paths, use_symlinks=False) as temp_dir: 25 paths, use_symlinks=False) as temp_dir:
26 print 'Deploying from "%s".' % temp_dir 26 print 'Deploying from "%s".' % temp_dir
27 27
28 script_path = _FindScriptInPath('appcfg.py') 28 script_path = _FindScriptInPath(os.path.join('..', 'lib', 'gcloud.py'))
perezju 2017/02/20 10:22:26 This seems odd. The error message bellow suggests
dtu 2017/02/22 01:09:40 Done. I've changed it to look for 'gcloud.cmd' on
29 if not script_path: 29 if not script_path:
30 print 'This script requires the App Engine SDK to be in PATH.' 30 print 'This script requires the Google Cloud SDK to be in PATH.'
sullivan 2017/02/20 14:58:36 Can this also link to instructions for installing
dtu 2017/02/22 01:09:40 Done.
31 sys.exit(1) 31 sys.exit(1)
32 32
33 subprocess.call([ 33 subprocess.call([sys.executable, script_path, 'app', 'deploy',
shatch 2017/02/20 21:31:01 I forget if we discussed this in last week's sync,
dtu 2017/02/22 01:09:40 --quiet: No, deployment is fast enough that it sho
34 sys.executable, 34 '--version', _VersionName()] + args)
shatch 2017/02/20 21:31:01 I seemed to need to add cwd=temp_dir otherwise my
dtu 2017/02/22 01:09:40 Done.
35 script_path,
36 '--application=%s' % app_id,
37 '--version=%s' % _VersionName(),
38 'update',
39 os.path.join(temp_dir, service_name) if service_name else temp_dir,
40 ])
41 35
42 36
43 def _FindScriptInPath(script_name): 37 def _FindScriptInPath(script_name):
44 for path in os.environ['PATH'].split(os.pathsep): 38 for path in os.environ['PATH'].split(os.pathsep):
45 script_path = os.path.join(path, script_name) 39 script_path = os.path.join(path, script_name)
46 if os.path.exists(script_path): 40 if os.path.exists(script_path):
47 return script_path 41 return script_path
48 42
49 return None 43 return None
50 44
51 45
52 def _VersionName(): 46 def _VersionName():
53 is_synced = not _Run(['git', 'diff', 'master', '--no-ext-diff']).strip() 47 is_synced = not _Run(['git', 'diff', 'master', '--no-ext-diff']).strip()
54 deployment_type = 'clean' if is_synced else 'dev' 48 deployment_type = 'clean' if is_synced else 'dev'
55 email = _Run(['git', 'config', '--get', 'user.email']) 49 email = _Run(['git', 'config', '--get', 'user.email'])
56 username = email[0:email.find('@')] 50 username = email[0:email.find('@')]
57 commit_hash = _Run(['git', 'rev-parse', '--short=8', 'HEAD']).strip() 51 commit_hash = _Run(['git', 'rev-parse', '--short=8', 'HEAD']).strip()
58 return '%s-%s-%s' % (deployment_type, username, commit_hash) 52 return '%s-%s-%s' % (deployment_type, username, commit_hash)
59 53
60 54
61 def _Run(command): 55 def _Run(command):
62 proc = subprocess.Popen(command, stdout=subprocess.PIPE) 56 proc = subprocess.Popen(command, stdout=subprocess.PIPE)
63 output, _ = proc.communicate() 57 output, _ = proc.communicate()
64 return output 58 return output
OLDNEW
« no previous file with comments | « no previous file | dashboard/bin/deploy » ('j') | dashboard/docs/getting-set-up.md » ('J')

Powered by Google App Engine
This is Rietveld 408576698