mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
#482 Quickfix to parse mount output
This commit is contained in:
@ -70,6 +70,8 @@ Example:
|
|||||||
...
|
...
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
import re
|
||||||
|
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
|
||||||
|
|
||||||
@ -133,15 +135,25 @@ def _linux_parse(data):
|
|||||||
|
|
||||||
for entry in data:
|
for entry in data:
|
||||||
output_line = {}
|
output_line = {}
|
||||||
parsed_line = entry.split()
|
|
||||||
|
|
||||||
output_line['filesystem'] = parsed_line[0]
|
pattern = re.compile(
|
||||||
output_line['mount_point'] = parsed_line[2]
|
r'''
|
||||||
output_line['type'] = parsed_line[4]
|
(?P<filesystem>\S+)\s+
|
||||||
output_line['options'] = parsed_line[5].lstrip('(').rstrip(')').split(',')
|
on\s+
|
||||||
|
(?P<mount_point>.*?)\s+
|
||||||
|
type\s+
|
||||||
|
(?P<type>\S+)\s+
|
||||||
|
\((?P<options>.*?)\)\s*''',
|
||||||
|
re.VERBOSE)
|
||||||
|
|
||||||
|
match = pattern.match(entry)
|
||||||
|
groups = match.groupdict()
|
||||||
|
|
||||||
|
output_line['filesystem'] = groups["filesystem"]
|
||||||
|
output_line['mount_point'] = groups["mount_point"]
|
||||||
|
output_line['type'] = groups["type"]
|
||||||
|
output_line['options'] = groups["options"].split(',')
|
||||||
output.append(output_line)
|
output.append(output_line)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _aix_parse(data):
|
def _aix_parse(data):
|
||||||
|
Reference in New Issue
Block a user