Merge branch 'coretk' of https://github.com/coreemu/core into coretk

This commit is contained in:
Blake Harnden 2019-12-12 11:10:32 -08:00
commit afd2514728
4 changed files with 101 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -1,29 +1,113 @@
""" """
check engine light check engine light
""" """
import tkinter as tk
from tkinter import ttk from tkinter import ttk
from coretk.dialogs.dialog import Dialog from coretk.dialogs.dialog import Dialog
from coretk.images import ImageEnum, Images
from coretk.themes import PADX, PADY
from coretk.widgets import CodeText
class CheckLight(Dialog): class CheckLight(Dialog):
def __init__(self, master, app): def __init__(self, master, app):
super().__init__(master, app, "CEL", modal=True) super().__init__(master, app, "CEL", modal=True)
self.app = app self.app = app
self.tree = None
self.columnconfigure(0, weight=1) self.text = None
self.draw() self.draw()
def draw(self): def draw(self):
row = 0 row = 0
frame = ttk.Frame(self) frame = ttk.Frame(self)
button = ttk.Button(frame, text="Reset CEL") frame.columnconfigure(0, weight=1)
button.grid(row=0, column=0) frame.columnconfigure(1, weight=1)
button = ttk.Button(frame, text="View core-daemon log") image = Images.get(ImageEnum.ALERT, 18)
button.grid(row=0, column=1) label = ttk.Label(frame, image=image)
button = ttk.Button(frame, text="View node log") label.image = image
button.grid(row=0, column=2) label.grid(row=0, column=0, sticky="e")
button = ttk.Button(frame, text="Close", command=self.destroy) label = ttk.Label(frame, text="Check Emulation Light")
button.grid(row=0, column=3) label.grid(row=0, column=1, sticky="w")
frame.grid(row=row, column=0, padx=PADX, pady=PADY, sticky="nsew")
row = row + 1
frame = ttk.Frame(self)
frame.columnconfigure(0, weight=1)
frame.grid(row=row, column=0, sticky="nsew") frame.grid(row=row, column=0, sticky="nsew")
++row self.tree = ttk.Treeview(
frame, columns=("time", "level", "node", "source"), show="headings"
)
self.tree.grid(row=0, column=0, sticky="nsew")
self.tree.column("time", stretch=tk.YES)
self.tree.heading("time", text="time")
self.tree.column("level", stretch=tk.YES)
self.tree.heading("level", text="level")
self.tree.column("node", stretch=tk.YES)
self.tree.heading("node", text="node")
self.tree.column("source", stretch=tk.YES)
self.tree.heading("source", text="source")
yscrollbar = ttk.Scrollbar(frame, orient="vertical", command=self.tree.yview)
yscrollbar.grid(row=0, column=1, sticky="ns")
self.tree.configure(yscrollcommand=yscrollbar.set)
xscrollbar = ttk.Scrollbar(frame, orient="horizontal", command=self.tree.xview)
xscrollbar.grid(row=1, sticky="ew")
self.tree.configure(xscrollcommand=xscrollbar.set)
row = row + 1
self.text = CodeText(self)
self.text.grid(row=row, column=0, sticky="nsew")
row = row + 1
frame = ttk.Frame(self)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=1)
frame.columnconfigure(2, weight=1)
frame.columnconfigure(3, weight=1)
button = ttk.Button(frame, text="Reset CEL", command=self.reset_cel)
button.grid(row=0, column=0, sticky="nsew", padx=PADX)
button = ttk.Button(frame, text="View core-daemon log", command=self.daemon_log)
button.grid(row=0, column=1, sticky="nsew", padx=PADX)
button = ttk.Button(frame, text="View node log")
button.grid(row=0, column=2, sticky="nsew", padx=PADX)
button = ttk.Button(frame, text="Close", command=self.destroy)
button.grid(row=0, column=3, sticky="nsew", padx=PADX)
frame.grid(row=row, column=0, sticky="nsew")
row = row + 1
def reset_cel(self):
self.text.delete("1.0", tk.END)
def daemon_log(self):
dialog = DaemonLog(self, self.app)
dialog.show()
class DaemonLog(Dialog):
def __init__(self, master, app):
super().__init__(master, app, "core-daemon log", modal=True)
self.columnconfigure(0, weight=1)
self.path = tk.StringVar(value="/var/log/core-daemon.log")
self.draw()
def draw(self):
frame = ttk.Frame(self)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=9)
label = ttk.Label(frame, text="File: ")
label.grid(row=0, column=0)
entry = ttk.Entry(frame, textvariable=self.path, state="disabled")
entry.grid(row=0, column=1, sticky="nsew")
frame.grid(row=0, column=0, sticky="nsew")
try:
file = open("/var/log/core-daemon.log", "r")
log = file.readlines()
except FileNotFoundError:
log = "Log file not found"
text = CodeText(self)
text.insert("1.0", log)
text.see("end")
text.config(state=tk.DISABLED)
text.grid(row=1, column=0, sticky="nsew")

View file

@ -67,3 +67,4 @@ class ImageEnum(Enum):
ANTENNA = "antenna" ANTENNA = "antenna"
DOCKER = "docker" DOCKER = "docker"
LXC = "lxc" LXC = "lxc"
ALERT = "alert"

View file

@ -3,6 +3,7 @@ import tkinter as tk
from tkinter import ttk from tkinter import ttk
from coretk.dialogs.cel import CheckLight from coretk.dialogs.cel import CheckLight
from coretk.images import ImageEnum, Images
class StatusBar(ttk.Frame): class StatusBar(ttk.Frame):
@ -54,9 +55,11 @@ class StatusBar(ttk.Frame):
) )
self.cpu_usage.grid(row=0, column=3, sticky="ew") self.cpu_usage.grid(row=0, column=3, sticky="ew")
self.emulation_light = ttk.Label( image = Images.get(ImageEnum.ALERT, 18)
self, text="CEL TBD", anchor=tk.CENTER, borderwidth=1, relief=tk.RIDGE self.emulation_light = ttk.Button(
self, image=image, text="Alert", compound="left"
) )
self.emulation_light.image = image
self.emulation_light.bind("<Button-1>", self.cel_callback) self.emulation_light.bind("<Button-1>", self.cel_callback)
self.emulation_light.grid(row=0, column=4, sticky="ew") self.emulation_light.grid(row=0, column=4, sticky="ew")