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

Side by Side Diff: remoting/webapp/build-webapp.py

Issue 10939005: Remove API keys from source. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated module path comment. Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Creates a directory with with the unpacked contents of the remoting webapp. 6 """Creates a directory with with the unpacked contents of the remoting webapp.
7 7
8 The directory will contain a copy-of or a link-to to all remoting webapp 8 The directory will contain a copy-of or a link-to to all remoting webapp
9 resources. This includes HTML/JS and any plugin binaries. The script also 9 resources. This includes HTML/JS and any plugin binaries. The script also
10 massages resulting files appropriately with host plugin data. Finally, 10 massages resulting files appropriately with host plugin data. Finally,
11 a zip archive for all of the above is produced. 11 a zip archive for all of the above is produced.
12 """ 12 """
13 13
14 # Python 2.5 compatibility 14 # Python 2.5 compatibility
15 from __future__ import with_statement 15 from __future__ import with_statement
16 16
17 import os 17 import os
18 import platform 18 import platform
19 import re 19 import re
20 import shutil 20 import shutil
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 import time 23 import time
24 import zipfile 24 import zipfile
25 25
26 # Update the module path, assuming that this script is in src/remoting/webapp,
27 # and that the google_api_keys module is in src/google_apis. Note that
28 # sys.path[0] refers to the directory containing this script.
Wez 2012/09/18 04:37:39 nit: The first sentence explains the intent; proba
29 if __name__ == '__main__':
30 sys.path.append(
31 os.path.abspath(os.path.join(sys.path[0], '../../google_apis')))
32 import google_api_keys
33
26 def findAndReplace(filepath, findString, replaceString): 34 def findAndReplace(filepath, findString, replaceString):
27 """Does a search and replace on the contents of a file.""" 35 """Does a search and replace on the contents of a file."""
28 oldFilename = os.path.basename(filepath) + '.old' 36 oldFilename = os.path.basename(filepath) + '.old'
29 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename) 37 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename)
30 os.rename(filepath, oldFilepath) 38 os.rename(filepath, oldFilepath)
31 with open(oldFilepath) as input: 39 with open(oldFilepath) as input:
32 with open(filepath, 'w') as output: 40 with open(filepath, 'w') as output:
33 for s in input: 41 for s in input:
34 output.write(s.replace(findString, replaceString)) 42 output.write(s.replace(findString, replaceString))
35 os.remove(oldFilepath) 43 os.remove(oldFilepath)
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'" 185 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'"
178 oauth2RedirectUrlJson = baseUrl + '/dev*' 186 oauth2RedirectUrlJson = baseUrl + '/dev*'
179 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 187 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
180 "'OAUTH2_REDIRECT_URL'", 188 "'OAUTH2_REDIRECT_URL'",
181 oauth2RedirectUrlJs) 189 oauth2RedirectUrlJs)
182 findAndReplace(os.path.join(destination, 'manifest.json'), 190 findAndReplace(os.path.join(destination, 'manifest.json'),
183 "OAUTH2_REDIRECT_URL", 191 "OAUTH2_REDIRECT_URL",
184 oauth2RedirectUrlJson) 192 oauth2RedirectUrlJson)
185 193
186 # Set the correct API keys. 194 # Set the correct API keys.
187 if (buildtype == 'Official'): 195 apiClientId = google_api_keys.GetClientID('REMOTING')
188 apiClientId = ('440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.' + 196 apiClientSecret = google_api_keys.GetClientSecret('REMOTING')
189 'apps.googleusercontent.com') 197 # TODO(jamiewalch): Get rid of the useOfficialClientId hack (crbug.com/150042)
190 apiClientSecret = 'Bgur6DFiOMM1h8x-AQpuTQlK' 198 oauth2UseOfficialClientId = 'true';
191 oauth2UseOfficialClientId = 'true'; 199
192 else:
193 apiClientId = ('440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.' +
194 'apps.googleusercontent.com')
195 apiClientSecret = 'W2ieEsG-R1gIA4MMurGrgMc_'
196 oauth2UseOfficialClientId = 'false';
197 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 200 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
198 "'API_CLIENT_ID'", 201 "'API_CLIENT_ID'",
199 "'" + apiClientId + "'") 202 "'" + apiClientId + "'")
200 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 203 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
201 "'API_CLIENT_SECRET'", 204 "'API_CLIENT_SECRET'",
202 "'" + apiClientSecret + "'") 205 "'" + apiClientSecret + "'")
203 findAndReplace(os.path.join(destination, 'plugin_settings.js'), 206 findAndReplace(os.path.join(destination, 'plugin_settings.js'),
204 "OAUTH2_USE_OFFICIAL_CLIENT_ID", 207 "OAUTH2_USE_OFFICIAL_CLIENT_ID",
205 oauth2UseOfficialClientId) 208 oauth2UseOfficialClientId)
206 209
(...skipping 19 matching lines...) Expand all
226 else: 229 else:
227 files.append(arg) 230 files.append(arg)
228 231
229 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], 232 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5],
230 sys.argv[6], files, locales) 233 sys.argv[6], files, locales)
231 return 0 234 return 0
232 235
233 236
234 if __name__ == '__main__': 237 if __name__ == '__main__':
235 sys.exit(main()) 238 sys.exit(main())
OLDNEW
« google_apis/google_api_keys.py ('K') | « google_apis/google_api_keys.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698