-
Notifications
You must be signed in to change notification settings - Fork 2
/
IssueBuilder.py
executable file
·96 lines (75 loc) · 3.27 KB
/
IssueBuilder.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
'''
Diese Klasse unterstützt beim erzeugen der Daten für Mantis
'''
import json, subprocess, readhw, base64
from datetime import datetime
def summary(lshwJson):
return lshwJson['vendor'] + " " + lshwJson['product']
def category(lshwJson):
if lshwJson.get("configuration").get("chassis") == 'notebook' or lshwJson.get("configuration").get(
"chassis") == 'laptop' or lshwJson.get("configuration").get("chassis") == 'portable':
return "Notebook"
else:
return "Desktop"
def os():
return subprocess.check_output("grep -i PRETTY_NAME -s -d skip /etc/*-release | awk -F'=' '{ print $2 }'",
shell=True, universal_newlines=True).strip().replace('\"', '')
def build():
print("Sammle Informationen über den Computer...")
lshwRaw = subprocess.check_output("sudo -S lshw -json -quiet", shell=True, universal_newlines=True)
lshwJson = json.loads(str(lshwRaw))[0]
content = open("config.json").read()
config = json.loads(content)
STANDORT = config['standort']
custom_fields = [
{"field": {"name": "cpu"}, "value": readhw.cpu()},
{"field": {"name": "Ram"}, "value": readhw.memory()},
{"field": {"name": "eingang"}, "value": datetime.now().timestamp()},
{"field": {"name": "Festplatte"}, "value": readhw.storage()}, # größe und typ
{"field": {"name": "webcam"}, "value": readhw.check_for_cam()},
{"field": {"name": "wlan"}, "value": readhw.wifi()},
{"field": {"name": "Standort"}, "value": STANDORT}
]
print(
"Jetzt darfst du weitere Informationen eingeben die du der Description hinzufügen möchtest. z.B. Besonderheiten des Computers: Farbe, krasses Display, Beschädigungen oder Defekte, etc. Um zu beenden gib Fertig ein.")
more_description_input = []
while True:
line = input()
if line != "Fertig":
more_description_input.append(line)
else:
break
more_description_input = '\n '.join(more_description_input)
print("Sammle weitere Informationen...")
if more_description_input == "":
description = "USB 3: " + readhw.usb3() + "\n" \
"Grafikkarte: " + readhw.graphicscard() + "\n" \
"" + readhw.resolution(category(lshwJson)) + "\n" \
"" + readhw.cdrom()
else:
description = "USB 3: " + readhw.usb3() + "\n" \
"Grafikkarte: " + readhw.graphicscard() + "\n" \
"" + readhw.resolution(category(lshwJson)) + "\n" \
"" + readhw.cdrom() + "\n" \
"Sonstiges: " + more_description_input
hardwareAttachment = base64.b64encode(subprocess.check_output("sudo lshw -short -quiet", shell=True)).decode()
mantisJson = {
"summary": summary(lshwJson),
"description": description,
"custom_fields": custom_fields,
"os": os(),
"category": {
"name": category(lshwJson)
},
"project": {
"name": "Computerliste"
},
"files": [
{
"name": "lshw_output.txt",
"content": hardwareAttachment
}
]
}
return mantisJson
# build() # Debugging Purpose