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 62644ac
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 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
5 changes: 2 additions & 3 deletions 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 All @@ -26,8 +27,6 @@
redis = None
sentinel = None

from gnocchi import utils


SEP_S = ':'
SEP = b':'
Expand Down Expand Up @@ -155,7 +154,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
2 changes: 1 addition & 1 deletion gnocchi/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def test_list_resources_with_bad_details(self):
result = self.app.get("/v1/resource/generic?details=awesome",
status=400)
self.assertIn(
b"Unable to parse `details': invalid truth value",
b"Unable to parse `details':",
result.body)

def _do_test_list_resources_with_detail(self, request):
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 62644ac

Please sign in to comment.