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

This commit is contained in:
Blake Harnden 2019-12-12 20:32:36 -08:00
commit da9d344c54
5 changed files with 83 additions and 9 deletions

View file

@ -149,8 +149,8 @@ class CoreClient:
self.handle_node_event(event.node_event)
elif event.HasField("config_event"):
logging.info("config event: %s", event)
elif event.HasField("throughput_event"):
logging.info("throughput event: %s", event)
elif event.HasField("exception_event"):
self.handle_exception_event(event.exception_event)
else:
logging.info("unhandled event: %s", event)
@ -182,6 +182,11 @@ class CoreClient:
event.interface_throughputs
)
def handle_exception_event(self, event):
print(event)
print(event.node_id)
self.app.statusbar.core_alarms.append(event)
def join_session(self, session_id, query_location=True):
# update session and title
self.session_id = session_id

View file

@ -4,6 +4,9 @@ check engine light
import tkinter as tk
from tkinter import ttk
from grpc import RpcError
from core.api.grpc import core_pb2
from coretk.dialogs.dialog import Dialog
from coretk.images import ImageEnum, Images
from coretk.themes import PADX, PADY
@ -36,17 +39,43 @@ class CheckLight(Dialog):
frame.columnconfigure(0, weight=1)
frame.grid(row=row, column=0, sticky="nsew")
self.tree = ttk.Treeview(
frame, columns=("time", "level", "node", "source"), show="headings"
frame,
columns=("time", "level", "session_id", "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.heading("time", text="time", anchor="w")
self.tree.column("level", stretch=tk.YES)
self.tree.heading("level", text="level")
self.tree.heading("level", text="level", anchor="w")
self.tree.column("session_id", stretch=tk.YES)
self.tree.heading("session_id", text="session id", anchor="w")
self.tree.column("node", stretch=tk.YES)
self.tree.heading("node", text="node")
self.tree.heading("node", text="node", anchor="w")
self.tree.column("source", stretch=tk.YES)
self.tree.heading("source", text="source")
self.tree.heading("source", text="source", anchor="w")
self.tree.bind("<<TreeviewSelect>>", self.click_select)
for alarm in self.app.statusbar.core_alarms:
level = self.get_level(alarm.level)
self.tree.insert(
"",
tk.END,
text=str(alarm.date),
values=(
alarm.date,
level + " (%s)" % alarm.level,
alarm.session_id,
alarm.node_id,
alarm.source,
),
tags=(level,),
)
self.tree.tag_configure("ERROR", background="#ff6666")
self.tree.tag_configure("FATAL", background="#d9d9d9")
self.tree.tag_configure("WARNING", background="#ffff99")
self.tree.tag_configure("NOTICE", background="#85e085")
yscrollbar = ttk.Scrollbar(frame, orient="vertical", command=self.tree.yview)
yscrollbar.grid(row=0, column=1, sticky="ns")
@ -58,6 +87,7 @@ class CheckLight(Dialog):
row = row + 1
self.text = CodeText(self)
self.text.config(state=tk.DISABLED)
self.text.grid(row=row, column=0, sticky="nsew")
row = row + 1
@ -75,15 +105,52 @@ class CheckLight(Dialog):
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)
for item in self.tree.get_children():
self.tree.delete(item)
self.app.statusbar.core_alarms.clear()
def daemon_log(self):
dialog = DaemonLog(self, self.app)
dialog.show()
def get_level(self, level):
if level == core_pb2.ExceptionLevel.ERROR:
return "ERROR"
if level == core_pb2.ExceptionLevel.FATAL:
return "FATAL"
if level == core_pb2.ExceptionLevel.WARNING:
return "WARNING"
if level == core_pb2.ExceptionLevel.NOTICE:
return "NOTICE"
def click_select(self, event):
current = self.tree.selection()
values = self.tree.item(current)["values"]
time = values[0]
level = values[1]
session_id = values[2]
node_id = values[3]
source = values[4]
text = "DATE: %s\nLEVEL: %s\nNODE: %s (%s)\nSESSION: %s\nSOURCE: %s\n\n" % (
time,
level,
node_id,
self.app.core.canvas_nodes[node_id].core_node.name,
session_id,
source,
)
try:
sid = self.app.core.session_id
self.app.core.client.get_node(sid, node_id)
text = text + "node created"
except RpcError:
text = text + "node not created"
self.text.delete("1.0", "end")
self.text.insert("1.0", text)
class DaemonLog(Dialog):
def __init__(self, master, app):

View file

@ -19,6 +19,7 @@ class StatusBar(ttk.Frame):
self.memory = None
self.emulation_light = None
self.running = False
self.core_alarms = []
self.draw()
def draw(self):

View file

@ -222,6 +222,7 @@ class Toolbar(ttk.Frame):
:return: nothing
"""
self.app.statusbar.core_alarms.clear()
self.app.statusbar.progress_bar.start(5)
self.app.canvas.mode = GraphMode.SELECT
thread = threading.Thread(target=self.app.core.start_session)

View file

@ -620,7 +620,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
return core_pb2.ExceptionEvent(
node_id=event.node,
session_id=int(event.session),
level=event.level.value,
level=event.level,
source=event.source,
date=event.date,
text=event.text,