From 6f0cc44f933aa7ac7745d1c82b677448f875b1e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Diemer?= <stephane.diemer@ubicast.eu> Date: Fri, 17 Mar 2017 08:54:29 +0100 Subject: [PATCH] PEP8 --- tests/test_partitions.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/test_partitions.py b/tests/test_partitions.py index 87e987b2..dd2ad85b 100755 --- a/tests/test_partitions.py +++ b/tests/test_partitions.py @@ -13,7 +13,8 @@ BS = 512 def to_gbytes(size_bytes): - return int(round(size_bytes/(1024*1024*1024))) + return int(round(size_bytes / (1024 * 1024 * 1024))) + def read_file(fname): with open(fname, 'r') as f: @@ -38,6 +39,7 @@ paths = [ }, ] + def get_swap_gbytes(): d = read_file('/proc/meminfo') for l in d.split('\n'): @@ -46,12 +48,13 @@ def get_swap_gbytes(): swap_kbytes, unit = swap.split(' ') if unit != 'kB': print('Warning, unexpected unit %s' % unit) - swap_gbytes = int(round(int(swap_kbytes)/(1024*1024))) + swap_gbytes = int(round(int(swap_kbytes) / (1024 * 1024))) return swap_gbytes + def get_path(path): - #Filesystem Type 1B-blocks Used Available Use% Mounted on - #/dev/loop2 ext4 52710469632 38253940736 11755397120 77% / + # Filesystem Type 1B-blocks Used Available Use% Mounted on + # /dev/loop2 ext4 52710469632 38253940736 11755397120 77% / status, output = subprocess.getstatusoutput('df --output="source,fstype,size,used" -B 1 %s | tail -n 1' % path) if status == 0: dev, fstype, size, used = output.split() @@ -59,6 +62,7 @@ def get_path(path): dev = fstype = size = used = None return dev, fstype, to_gbytes(int(size)), to_gbytes(int(used)) + def check_allocation(dev): root_dev = os.path.basename(dev)[:3] d = read_file('/proc/partitions') @@ -86,6 +90,7 @@ def check_allocation(dev): error = False warning = False + def check_path(p): global error global warning @@ -94,10 +99,10 @@ def check_path(p): mount_point = p.get('mount_point') if mount_point: if os.path.isdir(mount_point): - name = mount_point + name = mount_point dev, fstype, psize, used = get_path(p['mount_point']) if fstype not in p.get('recommended_types'): - print('Warning, fs type %s not recommended' % (fstype, p['recommended_types'])) + print('Warning, fs type %s not recommended (recommended: %s)' % (fstype, p['recommended_types'])) warning = True if 'nfs' not in dev: warning = not check_allocation(dev) @@ -110,7 +115,7 @@ def check_path(p): print('%s not found, cannot check' % mount_point) elif p.get('type') == 'swap': name = 'swap' - psize = get_swap_gbytes() + psize = get_swap_gbytes() if psize and psize < p['min_size_gbytes']: print('%s is smaller than the minimum required size (%s GB < %s GB)' % (name, psize, p['min_size_gbytes'])) -- GitLab