From: Kefu Chai Date: Sun, 24 May 2020 04:34:59 +0000 (+0800) Subject: mgr/cephadm: drop py2 compatible bits X-Git-Tag: v16.1.0~2153^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c71d733d6327a29617ba05b5d56891d45ad28d8;p=ceph.git mgr/cephadm: drop py2 compatible bits since we've dropped Python3 support in octopus, there is no need to keep the workaround for python2 anymore. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 6fc2f14025782..a88140c23f982 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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]: