| 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'))) |
| 30 import google_api_keys |
| 31 |
| 32 |
| 26 def findAndReplace(filepath, findString, replaceString): | 33 def findAndReplace(filepath, findString, replaceString): |
| 27 """Does a search and replace on the contents of a file.""" | 34 """Does a search and replace on the contents of a file.""" |
| 28 oldFilename = os.path.basename(filepath) + '.old' | 35 oldFilename = os.path.basename(filepath) + '.old' |
| 29 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename) | 36 oldFilepath = os.path.join(os.path.dirname(filepath), oldFilename) |
| 30 os.rename(filepath, oldFilepath) | 37 os.rename(filepath, oldFilepath) |
| 31 with open(oldFilepath) as input: | 38 with open(oldFilepath) as input: |
| 32 with open(filepath, 'w') as output: | 39 with open(filepath, 'w') as output: |
| 33 for s in input: | 40 for s in input: |
| 34 output.write(s.replace(findString, replaceString)) | 41 output.write(s.replace(findString, replaceString)) |
| 35 os.remove(oldFilepath) | 42 os.remove(oldFilepath) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'" | 184 oauth2RedirectUrlJs = "'" + baseUrl + "/dev'" |
| 178 oauth2RedirectUrlJson = baseUrl + '/dev*' | 185 oauth2RedirectUrlJson = baseUrl + '/dev*' |
| 179 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 186 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 180 "'OAUTH2_REDIRECT_URL'", | 187 "'OAUTH2_REDIRECT_URL'", |
| 181 oauth2RedirectUrlJs) | 188 oauth2RedirectUrlJs) |
| 182 findAndReplace(os.path.join(destination, 'manifest.json'), | 189 findAndReplace(os.path.join(destination, 'manifest.json'), |
| 183 "OAUTH2_REDIRECT_URL", | 190 "OAUTH2_REDIRECT_URL", |
| 184 oauth2RedirectUrlJson) | 191 oauth2RedirectUrlJson) |
| 185 | 192 |
| 186 # Set the correct API keys. | 193 # Set the correct API keys. |
| 187 if (buildtype == 'Official'): | 194 apiClientId = google_api_keys.GetClientID('REMOTING') |
| 188 apiClientId = ('440925447803-avn2sj1kc099s0r7v62je5s339mu0am1.' + | 195 apiClientSecret = google_api_keys.GetClientSecret('REMOTING') |
| 189 'apps.googleusercontent.com') | 196 if (apiClientId and apiClientSecret): |
| 190 apiClientSecret = 'Bgur6DFiOMM1h8x-AQpuTQlK' | |
| 191 oauth2UseOfficialClientId = 'true'; | 197 oauth2UseOfficialClientId = 'true'; |
| 192 else: | 198 else: |
| 193 apiClientId = ('440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.' + | 199 apiClientId = ('440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.' + |
| 194 'apps.googleusercontent.com') | 200 'apps.googleusercontent.com') |
| 195 apiClientSecret = 'W2ieEsG-R1gIA4MMurGrgMc_' | 201 apiClientSecret = 'W2ieEsG-R1gIA4MMurGrgMc_' |
| 196 oauth2UseOfficialClientId = 'false'; | 202 oauth2UseOfficialClientId = 'false'; |
| 197 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 203 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| 198 "'API_CLIENT_ID'", | 204 "'API_CLIENT_ID'", |
| 199 "'" + apiClientId + "'") | 205 "'" + apiClientId + "'") |
| 200 findAndReplace(os.path.join(destination, 'plugin_settings.js'), | 206 findAndReplace(os.path.join(destination, 'plugin_settings.js'), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 226 else: | 232 else: |
| 227 files.append(arg) | 233 files.append(arg) |
| 228 | 234 |
| 229 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], | 235 buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], |
| 230 sys.argv[6], files, locales) | 236 sys.argv[6], files, locales) |
| 231 return 0 | 237 return 0 |
| 232 | 238 |
| 233 | 239 |
| 234 if __name__ == '__main__': | 240 if __name__ == '__main__': |
| 235 sys.exit(main()) | 241 sys.exit(main()) |
| OLD | NEW |