Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 # Munge include path to find the google_api_keys API, and import it. | |
| 27 if __name__ == '__main__': | |
| 28 sys.path.append( | |
| 29 os.path.abspath(os.path.join(sys.path[0], '../../google_apis'))) | |
|
Wez
2012/09/18 01:10:36
This assumes that the path containing "google_apis
Jamie
2012/09/18 01:23:57
It certainly appears to be when you run this using
| |
| 30 import google_api_keys | |
| 31 | |
| 26 def findAndReplace(filepath, findString, replaceString): | 32 def findAndReplace(filepath, findString, replaceString): |
| 27 """Does a search and replace on the contents of a file.""" | 33 """Does a search and replace on the contents of a file.""" |
| 28 oldFilename = os.path.basename(filepath) + '.old' | 34 oldFilename = os.path.basename(filepath) + '.old' |
| 29 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename) | 35 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename) |
| 30 os.rename(filepath, oldFilepath) | 36 os.rename(filepath, oldFilepath) |
| 31 with open(oldFilepath) as input: | 37 with open(oldFilepath) as input: |
| 32 with open(filepath, 'w') as output: | 38 with open(filepath, 'w') as output: |
| 33 for s in input: | 39 for s in input: |
| 34 output.write(s.replace(findString, replaceString)) | 40 output.write(s.replace(findString, replaceString)) |
| 35 os.remove(oldFilepath) | 41 os.remove(oldFilepath) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'" | 183 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'" |
| 178 oauth2RedirectUrlJson = baseUrl + '/dev*' | 184 oauth2RedirectUrlJson = baseUrl + '/dev*' |
| 179 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 185 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 180 "'OAUTH2_REDIRECT_URL'", | 186 "'OAUTH2_REDIRECT_URL'", |
| 181 oauth2RedirectUrlJs) | 187 oauth2RedirectUrlJs) |
| 182 findAndReplace(os.path.join(destination, 'manifest.json'), | 188 findAndReplace(os.path.join(destination, 'manifest.json'), |
| 183 "OAUTH2_REDIRECT_URL", | 189 "OAUTH2_REDIRECT_URL", |
| 184 oauth2RedirectUrlJson) | 190 oauth2RedirectUrlJson) |
| 185 | 191 |
| 186 # Set the correct API keys. | 192 # Set the correct API keys. |
| 187 if (buildtype == 'Official'): | 193 apiClientId = google_api_keys.GetClientID('REMOTING') |
| 188 apiClientId = ('440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.' + | 194 apiClientSecret = google_api_keys.GetClientSecret('REMOTING') |
| 189 'apps.googleusercontent.com') | 195 # TODO(jamiewalch): Get rid of the useOfficialClientId hack. |
|
Wez
2012/09/18 01:10:36
nit: Create & refer to a bug for that work.
Jamie
2012/09/18 01:23:57
Done.
| |
| 190 apiClientSecret = 'Bgur6DFiOMM1h8x-AQpuTQlK' | 196 oauth2UseOfficialClientId = 'true'; |
| 191 oauth2UseOfficialClientId = 'true'; | 197 |
| 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'), | 198 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 198 "'API_CLIENT_ID'", | 199 "'API_CLIENT_ID'", |
| 199 "'" + apiClientId + "'") | 200 "'" + apiClientId + "'") |
| 200 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 201 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 201 "'API_CLIENT_SECRET'", | 202 "'API_CLIENT_SECRET'", |
| 202 "'" + apiClientSecret + "'") | 203 "'" + apiClientSecret + "'") |
| 203 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 204 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 204 "OAUTH2_USE_OFFICIAL_CLIENT_ID", | 205 "OAUTH2_USE_OFFICIAL_CLIENT_ID", |
| 205 oauth2UseOfficialClientId) | 206 oauth2UseOfficialClientId) |
| 206 | 207 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 226 else: | 227 else: |
| 227 files.append(arg) | 228 files.append(arg) |
| 228 | 229 |
| 229 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], | 230 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], |
| 230 sys.argv[6], files, locales) | 231 sys.argv[6], files, locales) |
| 231 return 0 | 232 return 0 |
| 232 | 233 |
| 233 | 234 |
| 234 if __name__ == '__main__': | 235 if __name__ == '__main__': |
| 235 sys.exit(main()) | 236 sys.exit(main()) |
| OLD | NEW |