mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
add schema and rename 'avail' to 'available'
This commit is contained in:
@ -66,6 +66,18 @@ $ df | jc --df -p -r
|
|||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
|
''' schema:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"filesystem": string,
|
||||||
|
"1k-blocks": integer,
|
||||||
|
"used": integer,
|
||||||
|
"available": integer,
|
||||||
|
"use_percent": integer,
|
||||||
|
"mounted": string
|
||||||
|
}
|
||||||
|
]
|
||||||
|
'''
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
# change any entry for key with '-blocks' in the name to int
|
# change any entry for key with '-blocks' in the name to int
|
||||||
for k in entry:
|
for k in entry:
|
||||||
@ -84,6 +96,10 @@ def process(proc_data):
|
|||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
entry['used'] = None
|
entry['used'] = None
|
||||||
|
|
||||||
|
# rename 'avail' to 'available'
|
||||||
|
if 'avail' in entry:
|
||||||
|
entry['available'] = entry.pop('avail')
|
||||||
|
|
||||||
# change 'available' to int
|
# change 'available' to int
|
||||||
if 'available' in entry:
|
if 'available' in entry:
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user