decrypt_project_info.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python
  2. # Copyright 2023 Google
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import sys
  16. import plistlib
  17. import json
  18. # Check if the PLIST file path was provided as a command-line argument
  19. if len(sys.argv) != 2:
  20. print("ERROR: cannot find <path_to_googleService-info.plist>")
  21. sys.exit(1)
  22. plist_file_path = sys.argv[1]
  23. # Read the PLIST file
  24. try:
  25. with open(plist_file_path, 'rb') as plist_file:
  26. plist_data = plistlib.readPlist(plist_file)
  27. # For python3 users:
  28. # plist_data = plistlib.load(plist_file)
  29. project_id = plist_data.get('PROJECT_ID')
  30. if project_id:
  31. with open('Firestore/Example/App/project_info.json', 'w') as json_file:
  32. json.dump({'project_id': project_id}, json_file)
  33. else:
  34. print("ERROR: PROJECT_ID key not found in the plist file.")
  35. except Exception as e:
  36. print("Error loading plist data:", e)