Skip to content

Commit ad8a275

Browse files
committed
Extra py2 specific branches removed and replaced
1 parent 36fbfea commit ad8a275

2 files changed

Lines changed: 9 additions & 26 deletions

File tree

kubernetes/base/leaderelection/leaderelection.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,13 @@ def try_acquire_or_renew(self):
122122

123123
# A lock is not created with that name, try to create one
124124
if not lock_status:
125-
# To be removed when support for python2 will be removed
126-
if sys.version_info > (3, 0):
127-
if json.loads(old_election_record.body)[
128-
'code'] != HTTPStatus.NOT_FOUND:
129-
logger.info(
130-
"Error retrieving resource lock {} as {}".format(
131-
self.election_config.lock.name,
132-
old_election_record.reason))
133-
return False
134-
else:
135-
if json.loads(old_election_record.body)[
136-
'code'] != HTTPStatus.NOT_FOUND:
137-
logger.info(
138-
"Error retrieving resource lock {} as {}".format(
139-
self.election_config.lock.name,
140-
old_election_record.reason))
141-
return False
125+
if json.loads(old_election_record.body)[
126+
'code'] != HTTPStatus.NOT_FOUND:
127+
logger.info(
128+
"Error retrieving resource lock {} as {}".format(
129+
self.election_config.lock.name,
130+
old_election_record.reason))
131+
return False
142132

143133
logger.info(
144134
"{} is trying to create a lock".format(

kubernetes/base/watch/watch.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import http
1516
import json
1617
import pydoc
17-
import sys
1818

1919
from kubernetes import client
2020

@@ -28,14 +28,7 @@
2828
# provide return_type to Watch class's __init__.
2929
TYPE_LIST_SUFFIX = "List"
3030

31-
32-
PY2 = sys.version_info[0] == 2
33-
if PY2:
34-
import httplib
35-
HTTP_STATUS_GONE = httplib.GONE
36-
else:
37-
import http
38-
HTTP_STATUS_GONE = http.HTTPStatus.GONE
31+
HTTP_STATUS_GONE = http.HTTPStatus.GONE
3932

4033

4134
class SimpleNamespace:

0 commit comments

Comments
 (0)