]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: drop py2 compatible bits 35322/head
authorKefu Chai <kchai@redhat.com>
Sun, 24 May 2020 04:34:59 +0000 (12:34 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 31 May 2020 04:05:12 +0000 (12:05 +0800)
since we've dropped Python3 support in octopus, there is no need to keep
the workaround for python2 anymore.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/cephadm/module.py

index 6fc2f14025782847837e970b5161d08e49d3c9ec..a88140c23f982b6976592bfc842a1cd5d8020084 100644 (file)
@@ -2,8 +2,9 @@ import json
 import errno
 import logging
 from collections import defaultdict
-from threading import Event
 from functools import wraps
+from tempfile import TemporaryDirectory
+from threading import Event
 
 import string
 from typing import List, Dict, Optional, Callable, Tuple, TypeVar, \
@@ -72,27 +73,6 @@ CEPH_DATEFMT = '%Y-%m-%dT%H:%M:%S.%fZ'
 CEPH_TYPES = set(CEPH_UPGRADE_ORDER)
 
 
-# for py2 compat
-try:
-    from tempfile import TemporaryDirectory # py3
-except ImportError:
-    # define a minimal (but sufficient) equivalent for <= py 3.2
-    class TemporaryDirectory(object): # type: ignore
-        def __init__(self):
-            self.name = tempfile.mkdtemp()
-
-        def __enter__(self):
-            if not self.name:
-                self.name = tempfile.mkdtemp()
-            return self.name
-
-        def cleanup(self):
-            shutil.rmtree(self.name)
-
-        def __exit__(self, exc_type, exc_value, traceback):
-            self.cleanup()
-
-
 def forall_hosts(f: Callable[..., T]) -> Callable[..., List[T]]:
     @wraps(f)
     def forall_hosts_wrapper(*args) -> List[T]: