]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/subman: migrate to Python 3
authorNathan Cutler <ncutler@suse.com>
Thu, 19 Apr 2018 21:25:25 +0000 (23:25 +0200)
committerNathan Cutler <ncutler@suse.com>
Mon, 23 Apr 2018 08:50:04 +0000 (10:50 +0200)
In Python 3.5, json.loads() wants str input. (This seems to be fixed in Python
3.6, but the Jenkins make check CI is still on 3.5.)

Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/script/subman

index 8ad7d76cc1e07a2eb68bdcc6a7f36d3b63175065..c81aa9800b94df1a192de1f7d03488c6b0e9ef27 100755 (executable)
@@ -1,18 +1,18 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import json
 import os
 import re
 import subprocess
 
-disks = json.loads(subprocess.check_output("ceph-disk list --format json", shell=True))
+disks = json.loads(subprocess.check_output("ceph-disk list --format json", shell=True).decode("utf-8"))
 used = 0
 
 for disk in disks:
     for partition in disk.get('partition', []):
         if partition.get('type') == 'data':
             df = subprocess.check_output("df --output=used " + partition['path'], shell=True)
-            used += int(re.findall('\d+', df)[0])
+            used += int(re.findall(b'\d+', df)[0])
 
 facts_file = os.environ.get("CEPH_FACTS_FILE", "/etc/rhsm/facts/ceph_usage.facts")
 open(facts_file, 'w').write("""\