add small ui for jenkins runners (#29382)
parent
db287496d8
commit
09ffce8073
4 changed files with 71 additions and 3 deletions
@ -0,0 +1,58 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import signal |
||||||
|
import subprocess |
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL) |
||||||
|
signal.signal(signal.SIGTERM, signal.SIG_DFL) |
||||||
|
|
||||||
|
from PyQt5.QtCore import QTimer # pylint: disable=no-name-in-module, import-error |
||||||
|
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel # pylint: disable=no-name-in-module, import-error |
||||||
|
from selfdrive.ui.qt.python_helpers import set_main_window |
||||||
|
|
||||||
|
class Window(QWidget): |
||||||
|
def __init__(self, parent=None): |
||||||
|
super(Window, self).__init__(parent) |
||||||
|
|
||||||
|
layout = QVBoxLayout() |
||||||
|
self.setLayout(layout) |
||||||
|
|
||||||
|
self.l = QLabel("jenkins runner") |
||||||
|
layout.addWidget(self.l) |
||||||
|
layout.addStretch(1) |
||||||
|
layout.setContentsMargins(20, 20, 20, 20) |
||||||
|
|
||||||
|
cmds = [ |
||||||
|
"cat /etc/hostname", |
||||||
|
"echo AGNOS v$(cat /VERSION)", |
||||||
|
"uptime -p", |
||||||
|
] |
||||||
|
self.labels = {} |
||||||
|
for c in cmds: |
||||||
|
self.labels[c] = QLabel(c) |
||||||
|
layout.addWidget(self.labels[c]) |
||||||
|
|
||||||
|
self.setStyleSheet(""" |
||||||
|
* { |
||||||
|
color: white; |
||||||
|
font-size: 55px; |
||||||
|
background-color: black; |
||||||
|
font-family: "JetBrains Mono"; |
||||||
|
} |
||||||
|
""") |
||||||
|
|
||||||
|
self.timer = QTimer() |
||||||
|
self.timer.timeout.connect(self.update) |
||||||
|
self.timer.start(10 * 1000) |
||||||
|
self.update() |
||||||
|
|
||||||
|
def update(self): |
||||||
|
for cmd, label in self.labels.items(): |
||||||
|
out = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
||||||
|
shell=True, check=False, encoding='utf8').stdout |
||||||
|
label.setText(out.strip()) |
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
app = QApplication([]) |
||||||
|
w = Window() |
||||||
|
set_main_window(w) |
||||||
|
app.exec_() |
Loading…
Reference in new issue