ciui.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python3
  2. import signal
  3. import subprocess
  4. signal.signal(signal.SIGINT, signal.SIG_DFL)
  5. signal.signal(signal.SIGTERM, signal.SIG_DFL)
  6. from PyQt5.QtCore import QTimer
  7. from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel
  8. from openpilot.selfdrive.ui.qt.python_helpers import set_main_window
  9. class Window(QWidget):
  10. def __init__(self, parent=None):
  11. super().__init__(parent)
  12. layout = QVBoxLayout()
  13. self.setLayout(layout)
  14. self.l = QLabel("jenkins runner")
  15. layout.addWidget(self.l)
  16. layout.addStretch(1)
  17. layout.setContentsMargins(20, 20, 20, 20)
  18. cmds = [
  19. "cat /etc/hostname",
  20. "echo AGNOS v$(cat /VERSION)",
  21. "uptime -p",
  22. ]
  23. self.labels = {}
  24. for c in cmds:
  25. self.labels[c] = QLabel(c)
  26. layout.addWidget(self.labels[c])
  27. self.setStyleSheet("""
  28. * {
  29. color: white;
  30. font-size: 55px;
  31. background-color: black;
  32. font-family: "JetBrains Mono";
  33. }
  34. """)
  35. self.timer = QTimer()
  36. self.timer.timeout.connect(self.update)
  37. self.timer.start(10 * 1000)
  38. self.update()
  39. def update(self):
  40. for cmd, label in self.labels.items():
  41. out = subprocess.run(cmd, capture_output=True,
  42. shell=True, check=False, encoding='utf8').stdout
  43. label.setText(out.strip())
  44. if __name__ == "__main__":
  45. app = QApplication([])
  46. w = Window()
  47. set_main_window(w)
  48. app.exec_()