_appengine_environ.py 957 B

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. This module provides means to detect the App Engine environment.
  3. """
  4. import os
  5. def is_appengine():
  6. return is_local_appengine() or is_prod_appengine()
  7. def is_appengine_sandbox():
  8. """Reports if the app is running in the first generation sandbox.
  9. The second generation runtimes are technically still in a sandbox, but it
  10. is much less restrictive, so generally you shouldn't need to check for it.
  11. see https://cloud.google.com/appengine/docs/standard/runtimes
  12. """
  13. return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27"
  14. def is_local_appengine():
  15. return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
  16. "SERVER_SOFTWARE", ""
  17. ).startswith("Development/")
  18. def is_prod_appengine():
  19. return "APPENGINE_RUNTIME" in os.environ and os.environ.get(
  20. "SERVER_SOFTWARE", ""
  21. ).startswith("Google App Engine/")
  22. def is_prod_appengine_mvms():
  23. """Deprecated."""
  24. return False