36 lines
858 B
Python
36 lines
858 B
Python
#!/usr/bin/env python3
|
|
|
|
import re
|
|
from subprocess import run
|
|
|
|
|
|
class ConfigError(Exception):
|
|
"""Raised when the config file fails validation."""
|
|
|
|
def __init__(self, message, config_file):
|
|
self.config_file = config_file
|
|
self.message = f"{config_file} : {message}"
|
|
super().__init__(self.message)
|
|
|
|
def identifySystem():
|
|
os = None
|
|
with open('/etc/issue', 'r') as f:
|
|
line = f.readline()
|
|
if re.search('Arch Linux', line):
|
|
os = 'ARCHLINUX'
|
|
elif re.search('Ubuntu', line):
|
|
os = 'UBUNTU'
|
|
elif re.search('Debian', line):
|
|
os = 'DEBIAN'
|
|
else:
|
|
os = 'UNKNOWN'
|
|
|
|
return os
|
|
|
|
def getKernelVersion():
|
|
"""
|
|
This function get the kernel version Linux
|
|
"""
|
|
kernelVers = run(['/usr/bin/uname', '-r'])
|
|
return kernelVers.stdout
|