From: Nathan Cutler Date: Thu, 19 Apr 2018 21:25:25 +0000 (+0200) Subject: script/subman: migrate to Python 3 X-Git-Tag: v13.1.0~96^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0593ca8ef505423da8238db8b4e312a1294bd62f;p=ceph.git script/subman: migrate to Python 3 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 --- diff --git a/src/script/subman b/src/script/subman index 8ad7d76cc1e0..c81aa9800b94 100755 --- a/src/script/subman +++ b/src/script/subman @@ -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("""\