From 5ff6700eb6d07b80a409b2e680de56a0b0fef886 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 24 May 2020 12:34:59 +0800 Subject: [PATCH] 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 (cherry picked from commit 2c71d733d6327a29617ba05b5d56891d45ad28d8) --- src/pybind/mgr/cephadm/module.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index db497013d5140..0f5c825a18a84 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, \ @@ -82,27 +83,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]: -- 2.39.5