Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop relying on SERVER_SOFTWARE being set #1704

Merged
merged 5 commits into from Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/urllib3/contrib/_appengine_environ.py
Expand Up @@ -6,27 +6,31 @@


def is_appengine():
return is_local_appengine() or is_prod_appengine() or is_prod_appengine_mvms()
return "APPENGINE_RUNTIME" in os.environ


def is_appengine_sandbox():
return is_appengine() and not is_prod_appengine_mvms()
"""Reports if the app is running in the first generation sandbox.

The second generation runtimes are technically still in a sandbox, but it
is much less restrictive, so generally you shouldn't need to check for it.
see https://cloud.google.com/appengine/docs/standard/runtimes
"""
return is_appengine() and os.environ["APPENGINE_RUNTIME"] == "python27"


def is_local_appengine():
return (
"APPENGINE_RUNTIME" in os.environ
and "Development/" in os.environ["SERVER_SOFTWARE"]
return is_appengine() and os.environ.get("SERVER_SOFTWARE", "").startswith(
"Development/"
)


def is_prod_appengine():
return (
"APPENGINE_RUNTIME" in os.environ
and "Google App Engine/" in os.environ["SERVER_SOFTWARE"]
and not is_prod_appengine_mvms()
return is_appengine() and os.environ.get("SERVER_SOFTWARE", "").startswith(
"Google App Engine/"
)


def is_prod_appengine_mvms():
theacodes marked this conversation as resolved.
Show resolved Hide resolved
return os.environ.get("GAE_VM", False) == "true"
"""Deprecated."""
return False
7 changes: 0 additions & 7 deletions src/urllib3/contrib/appengine.py
Expand Up @@ -108,13 +108,6 @@ def __init__(
"URLFetch is not available in this environment."
)

if is_prod_appengine_mvms():
raise AppEnginePlatformError(
"Use normal urllib3.PoolManager instead of AppEngineManager"
"on Managed VMs, as using URLFetch is not necessary in "
"this environment."
)

warnings.warn(
"urllib3 is using URLFetch on Google App Engine sandbox instead "
"of sockets. To use sockets directly instead of URLFetch see "
Expand Down