-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrtcqs_gui.py
More file actions
executable file
·124 lines (98 loc) · 3.83 KB
/
rtcqs_gui.py
File metadata and controls
executable file
·124 lines (98 loc) · 3.83 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
import PySimpleGUIQt as sg
import rtcqs
import resources as res
rtcqs.gui_status = True
version = rtcqs.version
element_vars = {}
def run_analysis():
try:
rtcqs.main()
except BaseException as err:
print(f'rtcqs exited with error {err=}, {type(err)=}')
for check in rtcqs.output:
img_key = f'{check}_img'
output_key = f'{check}_output'
tab_status = f'{check}_status'
if rtcqs.status[check]:
element_vars[img_key] = res.ok_img
element_vars[tab_status] = '✔'
else:
element_vars[img_key] = res.warning_img
element_vars[tab_status] = '✘'
element_vars[output_key] = rtcqs.output[check]
def create_tab(tab_name, check):
tab_layout = [sg.Tab(f"{element_vars[f'{check}_status']}{tab_name}", [[
sg.Image(data_base64=element_vars[f'{check}_img'],
key=f'{check}_img'),
sg.Multiline(default_text=element_vars[f'{check}_output'],
size=(80, 3.5),
key=f'{check}_output',
disabled=True,
background_color='white',
text_color='black')]],
background_color='#FBFBFB', key=f'{check}_tab')]
return tab_layout
def create_gui():
sg.theme('SystemDefaultForReal')
about_window = False
layout_analysis = [
[sg.TabGroup([
create_tab(' Root User', 'root'),
create_tab(' Audio Group', 'audio_group'),
create_tab(' Background Processes', 'background_process'),
create_tab(' CPU Frequency Scaling', 'governor'),
create_tab(' Kernel Configuration', 'kernel_config'),
], key='tab_group1')],
[sg.TabGroup([
create_tab(' High Resolution Timers', 'high_res_timers'),
create_tab(' System Timer', 'system_timer'),
create_tab(' Tickless Kernel', 'tickless'),
create_tab(' Real-Time Kernel', 'preempt_rt'),
create_tab(' Mitigations', 'mitigations'),
], key='tab_group2')],
[sg.TabGroup([
create_tab(' Real-Time Priorities', 'rt_prio'),
create_tab(' Swappiness', 'swappiness'),
create_tab(' Max User Watches', 'max_user_watches'),
create_tab(' Filesystems', 'filesystems'),
create_tab(' IRQs', 'irqs'),
], key='tab_group3')],
[sg.Button(button_text='About', size=(25, 1), pad=((0, 0), (0, 0))),
sg.Stretch(), sg.Cancel(size=(25, 1), pad=((0, 0), (0, 0)))]]
layout_about = [
[sg.Column([
[sg.Stretch(), sg.Image(data_base64=res.logo),
sg.Stretch()],
[sg.Stretch(),
sg.Text(f'rtcqs - version {version}',
font=('DejaVu Sans', '12', 'normal')),
sg.Stretch()],
[sg.Stretch(),
sg.Text('rtcqs, pronounced arteeseeks, is a Python '
'port of the realtimeconfigquickscan project.'),
sg.Stretch()]], background_color='white')],
[sg.Stretch(), sg.OK(size=(13, 1), pad=((0, 0), (3, 0))),
sg.Stretch()]]
window_analysis = sg.Window(
'rtcqs', layout_analysis, icon=res.icon_data)
window_about = sg.Window(
'rtcqs', layout_about, icon=res.icon_data, disable_close=True)
while True:
event, values = window_analysis.read()
if event in (sg.WIN_CLOSED, 'Cancel'):
break
elif event == 'About':
about_window = True
window_about.un_hide()
choice, _ = window_about.read(close=True)
if choice == 'OK':
window_about.hide()
if about_window:
window_about.close()
window_analysis.close()
def main():
run_analysis()
create_gui()
if __name__ == "__main__":
main()