File: no-distutils-usage.diff

package info (click to toggle)
gnocchi 4.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,180 kB
  • sloc: python: 19,372; sh: 282; makefile: 60
file content (61 lines) | stat: -rw-r--r-- 1,835 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Description: Avoid using distutils at runtime
Author: Matthias Klose <doko@ubuntu.com>
Forwarded: https://github.com/gnocchixyz/gnocchi/pull/904
Last-Update: 2018-06-04

Index: gnocchi/gnocchi/cli/api.py
===================================================================
--- gnocchi.orig/gnocchi/cli/api.py
+++ gnocchi/gnocchi/cli/api.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import copy
-from distutils import spawn
+import shutil
 import math
 import os
 import sys
@@ -78,7 +78,7 @@ def api():
             "No need to pass `--' in gnocchi-api command line anymore, "
             "please remove")
 
-    uwsgi = spawn.find_executable("uwsgi")
+    uwsgi = shutil.which("uwsgi")
     if not uwsgi:
         LOG.error("Unable to find `uwsgi'.\n"
                   "Be sure it is installed and in $PATH.")
Index: gnocchi/gnocchi/utils.py
===================================================================
--- gnocchi.orig/gnocchi/utils.py
+++ gnocchi/gnocchi/utils.py
@@ -15,7 +15,6 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 import datetime
-import distutils.util
 import errno
 import itertools
 import multiprocessing
@@ -203,10 +202,17 @@ def ensure_paths(paths):
                 raise
 
 
-def strtobool(v):
-    if isinstance(v, bool):
-        return v
-    return bool(distutils.util.strtobool(v))
+def strtobool(val):
+    if isinstance(val, bool):
+        return val
+    # copied from distutils.util ...
+    val = val.lower()
+    if val in ('y', 'yes', 't', 'true', 'on', '1'):
+        return 1
+    elif val in ('n', 'no', 'f', 'false', 'off', '0'):
+        return 0
+    else:
+        raise ValueError("invalid truth value %r" % (val,))
 
 
 class StopWatch(object):