From: Ganesh Maharaj Mahalingam Date: Mon, 29 Oct 2018 06:29:45 +0000 (-0700) Subject: fix python collections module warning for v3.7 and above X-Git-Tag: v14.1.0~808^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=625868974b67b32afe8f4143813bd70a538594c3;p=ceph.git fix python collections module warning for v3.7 and above Python 3.7 now shows a warning as below. /usr/bin/ceph:128: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working import rados This patch addresses the that particular issue. Signed-off-by: Ganesh Maharaj Mahalingam --- diff --git a/qa/tasks/cephfs/test_data_scan.py b/qa/tasks/cephfs/test_data_scan.py index 0faeb43fc03f..478d2a12a652 100644 --- a/qa/tasks/cephfs/test_data_scan.py +++ b/qa/tasks/cephfs/test_data_scan.py @@ -8,7 +8,10 @@ import logging import os from textwrap import dedent import traceback -from collections import namedtuple, defaultdict +try: + from collections.abc import namedtuple, defaultdict +except ImportError: + from collections import namedtuple, defaultdict from teuthology.orchestra.run import CommandFailedError from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology diff --git a/qa/tasks/cephfs/test_forward_scrub.py b/qa/tasks/cephfs/test_forward_scrub.py index e165780f31f1..6150dbaea4a1 100644 --- a/qa/tasks/cephfs/test_forward_scrub.py +++ b/qa/tasks/cephfs/test_forward_scrub.py @@ -10,7 +10,10 @@ how the functionality responds to damaged metadata. import json import logging -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple from textwrap import dedent from teuthology.orchestra.run import CommandFailedError diff --git a/qa/tasks/cephfs/test_recovery_pool.py b/qa/tasks/cephfs/test_recovery_pool.py index 97049b9c0a33..41fd512f1188 100644 --- a/qa/tasks/cephfs/test_recovery_pool.py +++ b/qa/tasks/cephfs/test_recovery_pool.py @@ -8,7 +8,10 @@ import logging import os from textwrap import dedent import traceback -from collections import namedtuple, defaultdict +try: + from collections.abc import namedtuple, defaultdict +except ImportError: + from collections import namedtuple, defaultdict from teuthology.orchestra.run import CommandFailedError from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology diff --git a/qa/tasks/cephfs/test_scrub.py b/qa/tasks/cephfs/test_scrub.py index 9469dfce6e49..4cc4f7f0c94b 100644 --- a/qa/tasks/cephfs/test_scrub.py +++ b/qa/tasks/cephfs/test_scrub.py @@ -4,7 +4,10 @@ Test CephFS scrub (distinct from OSD scrub) functionality import logging import os import traceback -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple from teuthology.orchestra.run import CommandFailedError from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology diff --git a/qa/tasks/mgr/dashboard/helper.py b/qa/tasks/mgr/dashboard/helper.py index f9c86516bf57..cdf294329cd3 100644 --- a/qa/tasks/mgr/dashboard/helper.py +++ b/qa/tasks/mgr/dashboard/helper.py @@ -4,7 +4,10 @@ from __future__ import absolute_import import json import logging -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple import threading import time diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index bf54af492193..8afafb59eebf 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -26,7 +26,10 @@ Alternative usage: """ from StringIO import StringIO -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict import getpass import signal import tempfile diff --git a/src/ceph-volume/ceph_volume/__init__.py b/src/ceph-volume/ceph_volume/__init__.py index 640fb1e6fb15..fd997eea7089 100644 --- a/src/ceph-volume/ceph_volume/__init__.py +++ b/src/ceph-volume/ceph_volume/__init__.py @@ -1,4 +1,7 @@ -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple sys_info = namedtuple('sys_info', ['devices']) diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index b1c5750f3bdc..9b55613f5d9b 100644 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -15,7 +15,10 @@ import json import socket import struct import time -from collections import OrderedDict +try: + from collections.abc import OrderedDict +except ImportError: + from collections import OrderedDict from fcntl import ioctl from fnmatch import fnmatch from prettytable import PrettyTable, HEADER diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 5f6ee6562b1f..2fb748090cba 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -9,7 +9,10 @@ from libc.stdlib cimport malloc, realloc, free cimport rados -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple from datetime import datetime import errno import os diff --git a/src/pybind/mgr/dashboard/controllers/cephfs.py b/src/pybind/mgr/dashboard/controllers/cephfs.py index df31d4a4f36e..d481e493e7ec 100644 --- a/src/pybind/mgr/dashboard/controllers/cephfs.py +++ b/src/pybind/mgr/dashboard/controllers/cephfs.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict import cherrypy diff --git a/src/pybind/mgr/dashboard/services/ceph_service.py b/src/pybind/mgr/dashboard/services/ceph_service.py index 91b4f351ef6e..b0bec642a1a2 100644 --- a/src/pybind/mgr/dashboard/services/ceph_service.py +++ b/src/pybind/mgr/dashboard/services/ceph_service.py @@ -2,8 +2,12 @@ from __future__ import absolute_import import time -import collections -from collections import defaultdict +try: + import collections.abc + from collections.abc import defaultdict +except ImportError: + import collections + from collections import defaultdict import json import rados diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 3c9510fbdabb..b96886a2579a 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -4,7 +4,10 @@ import ceph_module # noqa import logging import six import threading -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict import rados PG_STATES = [ diff --git a/src/pybind/mgr/restful/api/crush.py b/src/pybind/mgr/restful/api/crush.py index ee8589df0a41..6b2b3646cf96 100644 --- a/src/pybind/mgr/restful/api/crush.py +++ b/src/pybind/mgr/restful/api/crush.py @@ -2,7 +2,10 @@ from pecan import expose from pecan.rest import RestController from restful import common, context -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict from restful.decorators import auth diff --git a/src/pybind/mgr/status/module.py b/src/pybind/mgr/status/module.py index 99d3c7103d5b..7a4f72cb3cdb 100644 --- a/src/pybind/mgr/status/module.py +++ b/src/pybind/mgr/status/module.py @@ -3,7 +3,10 @@ High level status display commands """ -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict from prettytable import PrettyTable import errno import fnmatch diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index f331e1825326..d20b24979b55 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -12,7 +12,10 @@ import uuid import time from datetime import datetime from threading import Event -from collections import defaultdict +try: + from collections.abc import defaultdict +except ImportError: + from collections import defaultdict from mgr_module import MgrModule diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index fa60b87be0ee..6b3a0e858713 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -23,7 +23,10 @@ import sys import threading import time -from collections import Callable +try: + from collections.abc import Callable +except ImportError: + from collections import Callable from datetime import datetime from functools import partial, wraps from itertools import chain diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index b300edd0d1a3..240aac9af5b9 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -23,7 +23,10 @@ from libc.stdint cimport * from libc.stdlib cimport realloc, free from libc.string cimport strdup -from collections import Iterable +try: + from collections.abc import Iterable +except ImportError: + from collections import Iterable from datetime import datetime cimport rados diff --git a/src/pybind/rgw/rgw.pyx b/src/pybind/rgw/rgw.pyx index f512d33f84ab..39476aac86f8 100644 --- a/src/pybind/rgw/rgw.pyx +++ b/src/pybind/rgw/rgw.pyx @@ -10,7 +10,10 @@ from libc.stdlib cimport malloc, realloc, free cimport rados -from collections import namedtuple +try: + from collections.abc import namedtuple +except ImportError: + from collections import namedtuple from datetime import datetime import errno diff --git a/src/tools/rgw/parse-cr-dump.py b/src/tools/rgw/parse-cr-dump.py index 539929b113d8..e979cf33ec8f 100755 --- a/src/tools/rgw/parse-cr-dump.py +++ b/src/tools/rgw/parse-cr-dump.py @@ -1,6 +1,9 @@ #!/usr/bin/python from __future__ import print_function -from collections import Counter +try: + from collections.abc import Counter +except ImportError: + from collections import Counter import argparse import json import re