Skip to content

Commit ae86fe9

Browse files
committed
Extra py2 specific branches removed and replaced
1 parent 01ae336 commit ae86fe9

2 files changed

Lines changed: 10 additions & 21 deletions

File tree

kubernetes/base/leaderelection/leaderelection.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
"""
2727
This package implements leader election using an annotation in a Kubernetes object.
28-
The onstarted_leading function is run in a thread and when it returns, if it does
28+
The onstarted_leading function is run in a thread and when it returns, if it does
2929
it might not be safe to run it again in a process.
3030
3131
At first all candidates are considered followers. The one to create a lock or update
@@ -115,17 +115,13 @@ def try_acquire_or_renew(self):
115115

116116
# A lock is not created with that name, try to create one
117117
if not lock_status:
118-
# To be removed when support for python2 will be removed
119-
if sys.version_info > (3, 0):
120-
if json.loads(old_election_record.body)['code'] != HTTPStatus.NOT_FOUND:
121-
logger.info("Error retrieving resource lock {} as {}".format(self.election_config.lock.name,
122-
old_election_record.reason))
123-
return False
124-
else:
125-
if json.loads(old_election_record.body)['code'] != HTTPStatus.NOT_FOUND:
126-
logger.info("Error retrieving resource lock {} as {}".format(self.election_config.lock.name,
127-
old_election_record.reason))
128-
return False
118+
if json.loads(old_election_record.body)[
119+
'code'] != HTTPStatus.NOT_FOUND:
120+
logger.info(
121+
"Error retrieving resource lock {} as {}".format(
122+
self.election_config.lock.name,
123+
old_election_record.reason))
124+
return False
129125

130126
logger.info("{} is trying to create a lock".format(leader_election_record.holder_identity))
131127
create_status = self.election_config.lock.create(name=self.election_config.lock.name,

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)