-
Notifications
You must be signed in to change notification settings - Fork 0
/
osfinder.py
32 lines (24 loc) · 1006 Bytes
/
osfinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import subprocess
import platform
def FindOsver():
cat = subprocess.Popen(['cat', '/etc/os-release'], stdout=subprocess.PIPE)
grep = subprocess.Popen(
['grep', "REDHAT_SUPPORT_PRODUCT="], stdin=cat.stdout, stdout=subprocess.PIPE)
is_fedora = True if "Fedora" in (grep.communicate()[0]).decode(
"utf-8").split("=")[1] else False
if is_fedora == False:
raise ValueError("System is not Fedora. Quitting")
else:
cat = subprocess.Popen(
['cat', '/etc/os-release'], stdout=subprocess.PIPE)
grep = subprocess.Popen(
['grep', "VERSION_ID"], stdin=cat.stdout, stdout=subprocess.PIPE)
version = (grep.communicate()[0]).decode("utf-8").split("=")[1].strip()
if version == 36:
return "eln128"
else:
return f"fc{version}"
def FindArch():
arch = subprocess.Popen(['uname', '-m'], stdout=subprocess.PIPE)
return arch.stdout.read().strip().decode("utf-8")
print(FindArch())