3
from checkbox.parsers.modinfo import ModinfoParser
4
from subprocess import Popen, PIPE, check_output, CalledProcessError
8
process = Popen('lsmod', stdout=PIPE, stderr=PIPE, universal_newlines=True)
9
data = process.stdout.readlines()
10
# Delete the first item because it's headers from lsmod output
12
module_list = [module.split()[0].strip() for module in data]
15
for module in sorted(module_list):
19
stream = check_output([cmd, module],
21
universal_newlines=False)
22
except CalledProcessError as e:
26
version = 'Unavailable'
28
stream = stream.decode('utf-8')
30
parser = ModinfoParser(stream)
33
version = parser.get_field('version')
35
version = parser.get_field('vermagic').split()[0]
36
print('%s: %s' % (module, version))
39
if __name__ == '__main__':