Skip to content

Commit

Permalink
Get rid of distutils
Browse files Browse the repository at this point in the history
The distutils module was removed from Python 3.12 .
  • Loading branch information
kajinamit committed Oct 4, 2024
1 parent a0d8267 commit 3bf3f79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gnocchi/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import copy
from distutils import spawn
import math
import os
import shutil
import sys

import daiquiri
Expand Down Expand Up @@ -72,7 +72,7 @@ def api():
"No need to pass `--' in gnocchi-api command line anymore, "
"please remove")

uwsgi = conf.api.uwsgi_path or spawn.find_executable("uwsgi")
uwsgi = conf.api.uwsgi_path or shutil.which("uwsgi")
if not uwsgi:
LOG.error("Unable to find `uwsgi'.\n"
"Be sure it is installed and in $PATH.")
Expand Down
3 changes: 2 additions & 1 deletion gnocchi/common/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import re

from oslo_config import cfg
from oslo_utils import strutils
from urllib import parse

try:
Expand Down Expand Up @@ -155,7 +156,7 @@ def get_client(conf, scripts=None):
if a not in options:
continue
if a in CLIENT_BOOL_ARGS:
v = utils.strtobool(options[a][-1])
v = strutils.bool_from_string(options[a][-1])
elif a in CLIENT_LIST_ARGS:
v = options[a]
elif a in CLIENT_INT_ARGS:
Expand Down
3 changes: 2 additions & 1 deletion gnocchi/rest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import uuid

import jsonpatch
from oslo_utils import strutils
import pecan
from pecan import rest
import pyparsing
Expand Down Expand Up @@ -189,7 +190,7 @@ def get_bool_param(name, params, default='false'):
def strtobool(varname, v):
"""Convert a string to a boolean."""
try:
return utils.strtobool(v)
return strutils.bool_from_string(v, strict=True)
except ValueError as e:
abort(400, "Unable to parse `%s': %s" % (varname, str(e)))

Expand Down
7 changes: 0 additions & 7 deletions gnocchi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import distutils.util
import errno
import functools
import itertools
Expand Down Expand Up @@ -198,12 +197,6 @@ def ensure_paths(paths):
raise


def strtobool(v):
if isinstance(v, bool):
return v
return bool(distutils.util.strtobool(v))


class StopWatch(object):
"""A simple timer/stopwatch helper class.
Expand Down

0 comments on commit 3bf3f79

Please sign in to comment.