diff --git a/watch/watch.py b/watch/watch.py index f67dbe45..6410dfab 100644 --- a/watch/watch.py +++ b/watch/watch.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import http import json import pydoc +import sys from kubernetes import client @@ -29,6 +29,15 @@ TYPE_LIST_SUFFIX = "List" +PY2 = sys.version_info[0] == 2 +if PY2: + import httplib + HTTP_STATUS_GONE = httplib.GONE +else: + import http + HTTP_STATUS_GONE = http.HTTPStatus.GONE + + class SimpleNamespace: def __init__(self, **kwargs): @@ -158,7 +167,7 @@ def stream(self, func, *args, **kwargs): # Current request expired, let's retry, # but only if we have not already retried. if not retry_after_410 and \ - obj['code'] == http.HTTPStatus.GONE: + obj['code'] == HTTP_STATUS_GONE: retry_after_410 = True break else: