updates to python based logging to use module named loggers, updated logging config file to align with these changes
This commit is contained in:
parent
55d5bb3859
commit
69652ac577
63 changed files with 717 additions and 606 deletions
|
@ -22,6 +22,7 @@ from core.gui.statusbar import StatusBar
|
|||
from core.gui.themes import PADY
|
||||
from core.gui.toolbar import Toolbar
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
WIDTH: int = 1000
|
||||
HEIGHT: int = 800
|
||||
|
||||
|
@ -171,7 +172,7 @@ class Application(ttk.Frame):
|
|||
def show_grpc_exception(
|
||||
self, message: str, e: grpc.RpcError, blocking: bool = False
|
||||
) -> None:
|
||||
logging.exception("app grpc exception", exc_info=e)
|
||||
logger.exception("app grpc exception", exc_info=e)
|
||||
dialog = ErrorDialog(self, "GRPC Exception", message, e.details())
|
||||
if blocking:
|
||||
dialog.show()
|
||||
|
@ -179,7 +180,7 @@ class Application(ttk.Frame):
|
|||
self.after(0, lambda: dialog.show())
|
||||
|
||||
def show_exception(self, message: str, e: Exception) -> None:
|
||||
logging.exception("app exception", exc_info=e)
|
||||
logger.exception("app exception", exc_info=e)
|
||||
self.after(
|
||||
0, lambda: ErrorDialog(self, "App Exception", message, str(e)).show()
|
||||
)
|
||||
|
|
|
@ -46,6 +46,8 @@ from core.gui.graph.shape import Shape
|
|||
from core.gui.interface import InterfaceManager
|
||||
from core.gui.nodeutils import NodeDraw
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -150,7 +152,7 @@ class CoreClient:
|
|||
if not self.session or event.source == GUI_SOURCE:
|
||||
return
|
||||
if event.session_id != self.session.id:
|
||||
logging.warning(
|
||||
logger.warning(
|
||||
"ignoring event session(%s) current(%s)",
|
||||
event.session_id,
|
||||
self.session.id,
|
||||
|
@ -159,7 +161,7 @@ class CoreClient:
|
|||
if event.link_event:
|
||||
self.app.after(0, self.handle_link_event, event.link_event)
|
||||
elif event.session_event:
|
||||
logging.info("session event: %s", event)
|
||||
logger.info("session event: %s", event)
|
||||
session_event = event.session_event
|
||||
if session_event.event <= SessionState.SHUTDOWN.value:
|
||||
self.session.state = SessionState(session_event.event)
|
||||
|
@ -174,22 +176,22 @@ class CoreClient:
|
|||
else:
|
||||
dialog.set_pause()
|
||||
else:
|
||||
logging.warning("unknown session event: %s", session_event)
|
||||
logger.warning("unknown session event: %s", session_event)
|
||||
elif event.node_event:
|
||||
self.app.after(0, self.handle_node_event, event.node_event)
|
||||
elif event.config_event:
|
||||
logging.info("config event: %s", event)
|
||||
logger.info("config event: %s", event)
|
||||
elif event.exception_event:
|
||||
self.handle_exception_event(event.exception_event)
|
||||
else:
|
||||
logging.info("unhandled event: %s", event)
|
||||
logger.info("unhandled event: %s", event)
|
||||
|
||||
def handle_link_event(self, event: LinkEvent) -> None:
|
||||
logging.debug("Link event: %s", event)
|
||||
logger.debug("Link event: %s", event)
|
||||
node1_id = event.link.node1_id
|
||||
node2_id = event.link.node2_id
|
||||
if node1_id == node2_id:
|
||||
logging.warning("ignoring links with loops: %s", event)
|
||||
logger.warning("ignoring links with loops: %s", event)
|
||||
return
|
||||
canvas_node1 = self.canvas_nodes[node1_id]
|
||||
canvas_node2 = self.canvas_nodes[node2_id]
|
||||
|
@ -207,7 +209,7 @@ class CoreClient:
|
|||
canvas_node1, canvas_node2, event.link
|
||||
)
|
||||
else:
|
||||
logging.warning("unknown link event: %s", event)
|
||||
logger.warning("unknown link event: %s", event)
|
||||
else:
|
||||
if event.message_type == MessageType.ADD:
|
||||
self.app.manager.add_wired_edge(canvas_node1, canvas_node2, event.link)
|
||||
|
@ -216,10 +218,10 @@ class CoreClient:
|
|||
elif event.message_type == MessageType.NONE:
|
||||
self.app.manager.update_wired_edge(event.link)
|
||||
else:
|
||||
logging.warning("unknown link event: %s", event)
|
||||
logger.warning("unknown link event: %s", event)
|
||||
|
||||
def handle_node_event(self, event: NodeEvent) -> None:
|
||||
logging.debug("node event: %s", event)
|
||||
logger.debug("node event: %s", event)
|
||||
node = event.node
|
||||
if event.message_type == MessageType.NONE:
|
||||
canvas_node = self.canvas_nodes[node.id]
|
||||
|
@ -235,10 +237,10 @@ class CoreClient:
|
|||
canvas_node.canvas.delete_selected_objects()
|
||||
elif event.message_type == MessageType.ADD:
|
||||
if node.id in self.session.nodes:
|
||||
logging.error("core node already exists: %s", node)
|
||||
logger.error("core node already exists: %s", node)
|
||||
self.app.manager.add_core_node(node)
|
||||
else:
|
||||
logging.warning("unknown node event: %s", event)
|
||||
logger.warning("unknown node event: %s", event)
|
||||
|
||||
def enable_throughputs(self) -> None:
|
||||
self.handling_throughputs = self.client.throughputs(
|
||||
|
@ -272,24 +274,24 @@ class CoreClient:
|
|||
|
||||
def handle_throughputs(self, event: ThroughputsEvent) -> None:
|
||||
if event.session_id != self.session.id:
|
||||
logging.warning(
|
||||
logger.warning(
|
||||
"ignoring throughput event session(%s) current(%s)",
|
||||
event.session_id,
|
||||
self.session.id,
|
||||
)
|
||||
return
|
||||
logging.debug("handling throughputs event: %s", event)
|
||||
logger.debug("handling throughputs event: %s", event)
|
||||
self.app.after(0, self.app.manager.set_throughputs, event)
|
||||
|
||||
def handle_cpu_event(self, event: core_pb2.CpuUsageEvent) -> None:
|
||||
self.app.after(0, self.app.statusbar.set_cpu, event.usage)
|
||||
|
||||
def handle_exception_event(self, event: ExceptionEvent) -> None:
|
||||
logging.info("exception event: %s", event)
|
||||
logger.info("exception event: %s", event)
|
||||
self.app.statusbar.add_alert(event)
|
||||
|
||||
def join_session(self, session_id: int) -> None:
|
||||
logging.info("joining session(%s)", session_id)
|
||||
logger.info("joining session(%s)", session_id)
|
||||
self.reset()
|
||||
try:
|
||||
self.session = self.client.get_session(session_id)
|
||||
|
@ -314,7 +316,7 @@ class CoreClient:
|
|||
# canvas setting
|
||||
config = self.session.metadata
|
||||
canvas_config = config.get("canvas")
|
||||
logging.debug("canvas metadata: %s", canvas_config)
|
||||
logger.debug("canvas metadata: %s", canvas_config)
|
||||
if canvas_config:
|
||||
canvas_config = json.loads(canvas_config)
|
||||
self.app.manager.parse_metadata(canvas_config)
|
||||
|
@ -324,14 +326,14 @@ class CoreClient:
|
|||
if shapes_config:
|
||||
shapes_config = json.loads(shapes_config)
|
||||
for shape_config in shapes_config:
|
||||
logging.debug("loading shape: %s", shape_config)
|
||||
logger.debug("loading shape: %s", shape_config)
|
||||
Shape.from_metadata(self.app, shape_config)
|
||||
|
||||
# load edges config
|
||||
edges_config = config.get("edges")
|
||||
if edges_config:
|
||||
edges_config = json.loads(edges_config)
|
||||
logging.info("edges config: %s", edges_config)
|
||||
logger.info("edges config: %s", edges_config)
|
||||
for edge_config in edges_config:
|
||||
edge = self.links[edge_config["token"]]
|
||||
edge.width = edge_config["width"]
|
||||
|
@ -347,7 +349,7 @@ class CoreClient:
|
|||
if canvas_node:
|
||||
canvas_node.hide()
|
||||
else:
|
||||
logging.warning("invalid node to hide: %s", _id)
|
||||
logger.warning("invalid node to hide: %s", _id)
|
||||
|
||||
def create_new_session(self) -> None:
|
||||
"""
|
||||
|
@ -355,7 +357,7 @@ class CoreClient:
|
|||
"""
|
||||
try:
|
||||
session_id = self.client.create_session()
|
||||
logging.info("created session: %s", session_id)
|
||||
logger.info("created session: %s", session_id)
|
||||
self.join_session(session_id)
|
||||
location_config = self.app.guiconfig.location
|
||||
self.session.location = SessionLocation(
|
||||
|
@ -377,7 +379,7 @@ class CoreClient:
|
|||
session_id = self.session.id
|
||||
try:
|
||||
response = self.client.delete_session(session_id)
|
||||
logging.info("deleted session(%s), Result: %s", session_id, response)
|
||||
logger.info("deleted session(%s), Result: %s", session_id, response)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Delete Session Error", e)
|
||||
|
||||
|
@ -419,7 +421,7 @@ class CoreClient:
|
|||
dialog = SessionsDialog(self.app, True)
|
||||
dialog.show()
|
||||
except grpc.RpcError as e:
|
||||
logging.exception("core setup error")
|
||||
logger.exception("core setup error")
|
||||
self.app.show_grpc_exception("Setup Error", e, blocking=True)
|
||||
self.app.close()
|
||||
|
||||
|
@ -456,7 +458,7 @@ class CoreClient:
|
|||
result, exceptions = self.client.start_session(
|
||||
self.session, asymmetric_links
|
||||
)
|
||||
logging.info("start session(%s), result: %s", self.session.id, result)
|
||||
logger.info("start session(%s), result: %s", self.session.id, result)
|
||||
if result:
|
||||
self.set_metadata()
|
||||
except grpc.RpcError as e:
|
||||
|
@ -469,7 +471,7 @@ class CoreClient:
|
|||
result = False
|
||||
try:
|
||||
result = self.client.stop_session(session_id)
|
||||
logging.info("stopped session(%s), result: %s", session_id, result)
|
||||
logger.info("stopped session(%s), result: %s", session_id, result)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Stop Session Error", e)
|
||||
return result
|
||||
|
@ -513,7 +515,7 @@ class CoreClient:
|
|||
canvas=canvas_config, shapes=shapes, edges=edges_config, hidden=hidden
|
||||
)
|
||||
response = self.client.set_session_metadata(self.session.id, metadata)
|
||||
logging.debug("set session metadata %s, result: %s", metadata, response)
|
||||
logger.debug("set session metadata %s, result: %s", metadata, response)
|
||||
|
||||
def launch_terminal(self, node_id: int) -> None:
|
||||
try:
|
||||
|
@ -527,7 +529,7 @@ class CoreClient:
|
|||
return
|
||||
node_term = self.client.get_node_terminal(self.session.id, node_id)
|
||||
cmd = f"{terminal} {node_term} &"
|
||||
logging.info("launching terminal %s", cmd)
|
||||
logger.info("launching terminal %s", cmd)
|
||||
os.system(cmd)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Node Terminal Error", e)
|
||||
|
@ -540,16 +542,16 @@ class CoreClient:
|
|||
Save core session as to an xml file
|
||||
"""
|
||||
if not file_path and not self.session.file:
|
||||
logging.error("trying to save xml for session with no file")
|
||||
logger.error("trying to save xml for session with no file")
|
||||
return
|
||||
if not file_path:
|
||||
file_path = str(self.session.file)
|
||||
try:
|
||||
if not self.is_runtime():
|
||||
logging.debug("Send session data to the daemon")
|
||||
logger.debug("Send session data to the daemon")
|
||||
self.send_data()
|
||||
self.client.save_xml(self.session.id, file_path)
|
||||
logging.info("saved xml file %s", file_path)
|
||||
logger.info("saved xml file %s", file_path)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Save XML Error", e)
|
||||
|
||||
|
@ -559,7 +561,7 @@ class CoreClient:
|
|||
"""
|
||||
try:
|
||||
result, session_id = self._client.open_xml(file_path)
|
||||
logging.info(
|
||||
logger.info(
|
||||
"open xml file %s, result(%s) session(%s)",
|
||||
file_path,
|
||||
result,
|
||||
|
@ -573,14 +575,14 @@ class CoreClient:
|
|||
node_service = self.client.get_node_service(
|
||||
self.session.id, node_id, service_name
|
||||
)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"get node(%s) service(%s): %s", node_id, service_name, node_service
|
||||
)
|
||||
return node_service
|
||||
|
||||
def set_node_service(self, node_id: int, config: ServiceConfig) -> NodeServiceData:
|
||||
result = self.client.set_node_service(self.session.id, config)
|
||||
logging.info("set node service result(%s): %s", result, config)
|
||||
logger.info("set node service result(%s): %s", result, config)
|
||||
return self.client.get_node_service(self.session.id, node_id, config.service)
|
||||
|
||||
def get_node_service_file(
|
||||
|
@ -589,7 +591,7 @@ class CoreClient:
|
|||
data = self.client.get_node_service_file(
|
||||
self.session.id, node_id, service_name, file_name
|
||||
)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"get service file for node(%s), service: %s, file: %s, data: %s",
|
||||
node_id,
|
||||
service_name,
|
||||
|
@ -603,7 +605,7 @@ class CoreClient:
|
|||
) -> None:
|
||||
config = ServiceFileConfig(node_id, service_name, file_name, data)
|
||||
result = self.client.set_node_service_file(self.session.id, config)
|
||||
logging.info("set service file config %s: %s", config, result)
|
||||
logger.info("set service file config %s: %s", config, result)
|
||||
|
||||
def create_nodes_and_links(self) -> None:
|
||||
"""
|
||||
|
@ -612,7 +614,7 @@ class CoreClient:
|
|||
self.client.set_session_state(self.session.id, SessionState.DEFINITION)
|
||||
for node in self.session.nodes.values():
|
||||
node_id = self.client.add_node(self.session.id, node, source=GUI_SOURCE)
|
||||
logging.debug("created node: %s", node_id)
|
||||
logger.debug("created node: %s", node_id)
|
||||
asymmetric_links = []
|
||||
for edge in self.links.values():
|
||||
self.add_link(edge.link)
|
||||
|
@ -648,7 +650,7 @@ class CoreClient:
|
|||
"""
|
||||
Clean ups when done using grpc
|
||||
"""
|
||||
logging.debug("close grpc")
|
||||
logger.debug("close grpc")
|
||||
self.client.close()
|
||||
|
||||
def next_node_id(self) -> int:
|
||||
|
@ -704,7 +706,7 @@ class CoreClient:
|
|||
services = self.session.default_services.get(model)
|
||||
if services:
|
||||
node.services = services.copy()
|
||||
logging.info(
|
||||
logger.info(
|
||||
"add node(%s) to session(%s), coordinates(%s, %s)",
|
||||
node.name,
|
||||
self.session.id,
|
||||
|
@ -831,13 +833,13 @@ class CoreClient:
|
|||
return config_service_protos
|
||||
|
||||
def run(self, node_id: int) -> str:
|
||||
logging.info("running node(%s) cmd: %s", node_id, self.observer)
|
||||
logger.info("running node(%s) cmd: %s", node_id, self.observer)
|
||||
_, output = self.client.node_command(self.session.id, node_id, self.observer)
|
||||
return output
|
||||
|
||||
def get_wlan_config(self, node_id: int) -> Dict[str, ConfigOption]:
|
||||
config = self.client.get_wlan_config(self.session.id, node_id)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"get wlan configuration from node %s, result configuration: %s",
|
||||
node_id,
|
||||
config,
|
||||
|
@ -846,7 +848,7 @@ class CoreClient:
|
|||
|
||||
def get_mobility_config(self, node_id: int) -> Dict[str, ConfigOption]:
|
||||
config = self.client.get_mobility_config(self.session.id, node_id)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"get mobility config from node %s, result configuration: %s",
|
||||
node_id,
|
||||
config,
|
||||
|
@ -861,7 +863,7 @@ class CoreClient:
|
|||
config = self.client.get_emane_model_config(
|
||||
self.session.id, node_id, model, iface_id
|
||||
)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"get emane model config: node id: %s, EMANE model: %s, "
|
||||
"interface: %s, config: %s",
|
||||
node_id,
|
||||
|
@ -873,17 +875,17 @@ class CoreClient:
|
|||
|
||||
def execute_script(self, script) -> None:
|
||||
session_id = self.client.execute_script(script)
|
||||
logging.info("execute python script %s", session_id)
|
||||
logger.info("execute python script %s", session_id)
|
||||
if session_id != -1:
|
||||
self.join_session(session_id)
|
||||
|
||||
def add_link(self, link: Link) -> None:
|
||||
result, _, _ = self.client.add_link(self.session.id, link, source=GUI_SOURCE)
|
||||
logging.debug("added link: %s", result)
|
||||
logger.debug("added link: %s", result)
|
||||
if not result:
|
||||
logging.error("error adding link: %s", link)
|
||||
logger.error("error adding link: %s", link)
|
||||
|
||||
def edit_link(self, link: Link) -> None:
|
||||
result = self.client.edit_link(self.session.id, link, source=GUI_SOURCE)
|
||||
if not result:
|
||||
logging.error("error editing link: %s", link)
|
||||
logger.error("error editing link: %s", link)
|
||||
|
|
|
@ -13,6 +13,8 @@ from core.gui.graph.graph import CanvasGraph
|
|||
from core.gui.themes import PADX, PADY
|
||||
from core.gui.widgets import image_chooser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -167,5 +169,5 @@ class CanvasWallpaperDialog(Dialog):
|
|||
try:
|
||||
self.canvas.set_wallpaper(filename)
|
||||
except FileNotFoundError:
|
||||
logging.error("invalid background: %s", filename)
|
||||
logger.error("invalid background: %s", filename)
|
||||
self.destroy()
|
||||
|
|
|
@ -18,6 +18,8 @@ from core.gui.dialogs.dialog import Dialog
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CodeText, ConfigFrame, ListboxScroll
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.coreclient import CoreClient
|
||||
|
@ -97,7 +99,7 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
if service_config:
|
||||
for key, value in service_config.config.items():
|
||||
self.config[key].value = value
|
||||
logging.info("default config: %s", self.default_config)
|
||||
logger.info("default config: %s", self.default_config)
|
||||
for file, data in service_config.templates.items():
|
||||
self.modified_files.add(file)
|
||||
self.temp_service_files[file] = data
|
||||
|
@ -181,7 +183,7 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
self.modes_combobox.bind("<<ComboboxSelected>>", self.handle_mode_changed)
|
||||
self.modes_combobox.grid(row=0, column=1, sticky=tk.EW, pady=PADY)
|
||||
|
||||
logging.info("config service config: %s", self.config)
|
||||
logger.info("config service config: %s", self.config)
|
||||
self.config_frame = ConfigFrame(tab, self.app, self.config)
|
||||
self.config_frame.draw_config()
|
||||
self.config_frame.grid(sticky=tk.NSEW, pady=PADY)
|
||||
|
@ -328,7 +330,7 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
def handle_mode_changed(self, event: tk.Event) -> None:
|
||||
mode = self.modes_combobox.get()
|
||||
config = self.mode_configs[mode]
|
||||
logging.info("mode config: %s", config)
|
||||
logger.info("mode config: %s", config)
|
||||
self.config_frame.set_values(config)
|
||||
|
||||
def update_template_file_data(self, event: tk.Event) -> None:
|
||||
|
@ -350,7 +352,7 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
|
||||
def click_defaults(self) -> None:
|
||||
self.node.config_service_configs.pop(self.service_name, None)
|
||||
logging.info(
|
||||
logger.info(
|
||||
"cleared config service config: %s", self.node.config_service_configs
|
||||
)
|
||||
self.temp_service_files = dict(self.original_service_files)
|
||||
|
@ -358,7 +360,7 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
self.template_text.text.delete(1.0, "end")
|
||||
self.template_text.text.insert("end", self.temp_service_files[filename])
|
||||
if self.config_frame:
|
||||
logging.info("resetting defaults: %s", self.default_config)
|
||||
logger.info("resetting defaults: %s", self.default_config)
|
||||
self.config_frame.set_values(self.default_config)
|
||||
|
||||
def click_copy(self) -> None:
|
||||
|
|
|
@ -13,6 +13,8 @@ from core.gui.nodeutils import NodeDraw
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CheckboxList, ListboxScroll, image_chooser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -209,7 +211,7 @@ class CustomNodesDialog(Dialog):
|
|||
name, node_draw.image_file, list(node_draw.services)
|
||||
)
|
||||
self.app.guiconfig.nodes.append(custom_node)
|
||||
logging.info("saving custom nodes: %s", self.app.guiconfig.nodes)
|
||||
logger.info("saving custom nodes: %s", self.app.guiconfig.nodes)
|
||||
self.app.save_config()
|
||||
self.destroy()
|
||||
|
||||
|
@ -219,7 +221,7 @@ class CustomNodesDialog(Dialog):
|
|||
image_file = str(Path(self.image_file).absolute())
|
||||
custom_node = CustomNode(name, image_file, list(self.services))
|
||||
node_draw = NodeDraw.from_custom(custom_node)
|
||||
logging.info(
|
||||
logger.info(
|
||||
"created new custom node (%s), image file (%s), services: (%s)",
|
||||
name,
|
||||
image_file,
|
||||
|
@ -239,7 +241,7 @@ class CustomNodesDialog(Dialog):
|
|||
node_draw.image_file = str(Path(self.image_file).absolute())
|
||||
node_draw.image = self.image
|
||||
node_draw.services = set(self.services)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"edit custom node (%s), image: (%s), services (%s)",
|
||||
node_draw.model,
|
||||
node_draw.image_file,
|
||||
|
|
|
@ -7,6 +7,8 @@ from core.gui.appconfig import SCRIPT_PATH
|
|||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.themes import FRAME_PAD, PADX
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -83,6 +85,6 @@ class ExecutePythonDialog(Dialog):
|
|||
def script_execute(self) -> None:
|
||||
file = self.file_entry.get()
|
||||
options = self.option_entry.get()
|
||||
logging.info("Execute %s with options %s", file, options)
|
||||
logger.info("Execute %s with options %s", file, options)
|
||||
self.app.core.execute_script(file)
|
||||
self.destroy()
|
||||
|
|
|
@ -6,6 +6,8 @@ from typing import TYPE_CHECKING, Optional
|
|||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -139,8 +141,8 @@ class FindDialog(Dialog):
|
|||
_x, _y, _, _ = canvas_node.canvas.bbox(canvas_node.id)
|
||||
oid = canvas_node.canvas.find_withtag("rectangle")
|
||||
x0, y0, x1, y1 = canvas_node.canvas.bbox(oid[0])
|
||||
logging.debug("Dist to most left: %s", abs(x0 - _x))
|
||||
logging.debug("White canvas width: %s", abs(x0 - x1))
|
||||
logger.debug("Dist to most left: %s", abs(x0 - _x))
|
||||
logger.debug("White canvas width: %s", abs(x0 - x1))
|
||||
|
||||
# calculate the node's location
|
||||
# (as fractions of white canvas's width and height)
|
||||
|
|
|
@ -17,6 +17,8 @@ from core.gui.dialogs.emaneconfig import EmaneModelDialog
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import ListboxScroll, image_chooser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.node import CanvasNode
|
||||
|
@ -261,7 +263,7 @@ class NodeConfigDialog(Dialog):
|
|||
|
||||
if nutils.is_rj45(self.node):
|
||||
ifaces = self.app.core.client.get_ifaces()
|
||||
logging.debug("host machine available interfaces: %s", ifaces)
|
||||
logger.debug("host machine available interfaces: %s", ifaces)
|
||||
ifaces_scroll = ListboxScroll(frame)
|
||||
ifaces_scroll.listbox.config(state=state)
|
||||
ifaces_scroll.grid(
|
||||
|
|
|
@ -12,6 +12,8 @@ from core.gui.dialogs.dialog import Dialog
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CheckboxList, ListboxScroll
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -131,7 +133,7 @@ class NodeConfigServiceDialog(Dialog):
|
|||
|
||||
def click_save(self) -> None:
|
||||
self.node.config_services = self.current_services.copy()
|
||||
logging.info("saved node config services: %s", self.node.config_services)
|
||||
logger.info("saved node config services: %s", self.node.config_services)
|
||||
self.destroy()
|
||||
|
||||
def click_cancel(self) -> None:
|
||||
|
|
|
@ -9,6 +9,8 @@ from core.gui.dialogs.dialog import Dialog
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY, scale_fonts
|
||||
from core.gui.validation import LARGEST_SCALE, SMALLEST_SCALE
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -102,7 +104,7 @@ class PreferencesDialog(Dialog):
|
|||
|
||||
def theme_change(self, event: tk.Event) -> None:
|
||||
theme = self.theme.get()
|
||||
logging.info("changing theme: %s", theme)
|
||||
logger.info("changing theme: %s", theme)
|
||||
self.app.style.theme_use(theme)
|
||||
|
||||
def click_save(self) -> None:
|
||||
|
|
|
@ -20,6 +20,8 @@ from core.gui.images import ImageEnum
|
|||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CodeText, ListboxScroll
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.coreclient import CoreClient
|
||||
|
@ -393,7 +395,7 @@ class ServiceConfigDialog(Dialog):
|
|||
1.0, "end"
|
||||
)
|
||||
else:
|
||||
logging.debug("file already existed")
|
||||
logger.debug("file already existed")
|
||||
|
||||
def delete_filename(self) -> None:
|
||||
cbb = self.filename_combobox
|
||||
|
@ -601,7 +603,7 @@ class ServiceConfigDialog(Dialog):
|
|||
i = dirs.index(d)
|
||||
self.dir_list.listbox.delete(i)
|
||||
except ValueError:
|
||||
logging.debug("directory is not in the list")
|
||||
logger.debug("directory is not in the list")
|
||||
self.directory_entry.delete(0, "end")
|
||||
|
||||
def directory_select(self, event) -> None:
|
||||
|
|
|
@ -10,6 +10,8 @@ from core.gui.dialogs.dialog import Dialog
|
|||
from core.gui.themes import PADX, PADY
|
||||
from core.gui.widgets import ConfigFrame
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -55,7 +57,7 @@ class SessionOptionsDialog(Dialog):
|
|||
try:
|
||||
session_id = self.app.core.session.id
|
||||
result = self.app.core.client.set_session_options(session_id, config)
|
||||
logging.info("saved session config: %s", result)
|
||||
logger.info("saved session config: %s", result)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Set Session Options Error", e)
|
||||
self.destroy()
|
||||
|
|
|
@ -12,6 +12,8 @@ from core.gui.images import ImageEnum
|
|||
from core.gui.task import ProgressTask
|
||||
from core.gui.themes import PADX, PADY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -31,7 +33,7 @@ class SessionsDialog(Dialog):
|
|||
def get_sessions(self) -> List[SessionSummary]:
|
||||
try:
|
||||
sessions = self.app.core.client.get_sessions()
|
||||
logging.info("sessions: %s", sessions)
|
||||
logger.info("sessions: %s", sessions)
|
||||
return sorted(sessions, key=lambda x: x.id)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Get Sessions Error", e)
|
||||
|
@ -175,7 +177,7 @@ class SessionsDialog(Dialog):
|
|||
self.selected_id = None
|
||||
self.delete_button.config(state=tk.DISABLED)
|
||||
self.connect_button.config(state=tk.DISABLED)
|
||||
logging.debug("selected session: %s", self.selected_session)
|
||||
logger.debug("selected session: %s", self.selected_session)
|
||||
|
||||
def click_connect(self) -> None:
|
||||
if not self.selected_session:
|
||||
|
@ -199,7 +201,7 @@ class SessionsDialog(Dialog):
|
|||
def click_delete(self) -> None:
|
||||
if not self.selected_session:
|
||||
return
|
||||
logging.info("click delete session: %s", self.selected_session)
|
||||
logger.info("click delete session: %s", self.selected_session)
|
||||
self.tree.delete(self.selected_id)
|
||||
self.app.core.delete_session(self.selected_session)
|
||||
session_id = None
|
||||
|
|
|
@ -11,6 +11,8 @@ from core.gui.frames.link import EdgeInfoFrame, WirelessEdgeInfoFrame
|
|||
from core.gui.graph import tags
|
||||
from core.gui.utils import bandwidth_text, delay_jitter_text
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.graph import CanvasGraph
|
||||
|
@ -393,7 +395,7 @@ class Edge:
|
|||
self.dst.canvas.coords(self.dst_label2, *dst_pos)
|
||||
|
||||
def delete(self) -> None:
|
||||
logging.debug("deleting canvas edge, id: %s", self.id)
|
||||
logger.debug("deleting canvas edge, id: %s", self.id)
|
||||
self.src.canvas.delete(self.id)
|
||||
self.src.canvas.delete(self.src_label)
|
||||
self.src.canvas.delete(self.dst_label)
|
||||
|
@ -488,7 +490,7 @@ class CanvasWirelessEdge(Edge):
|
|||
token: str,
|
||||
link: Link,
|
||||
) -> None:
|
||||
logging.debug("drawing wireless link from node %s to node %s", src, dst)
|
||||
logger.debug("drawing wireless link from node %s to node %s", src, dst)
|
||||
super().__init__(app, src, dst)
|
||||
self.src.wireless_edges.add(self)
|
||||
self.dst.wireless_edges.add(self)
|
||||
|
@ -622,7 +624,7 @@ class CanvasEdge(Edge):
|
|||
self.draw_link_options()
|
||||
|
||||
def complete(self, dst: "CanvasNode", link: Link = None) -> None:
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"completing wired link from node(%s) to node(%s)",
|
||||
self.src.core_node.name,
|
||||
dst.core_node.name,
|
||||
|
|
|
@ -18,6 +18,8 @@ from core.gui.graph.node import CanvasNode, ShadowNode
|
|||
from core.gui.graph.shape import Shape
|
||||
from core.gui.graph.shapeutils import ShapeType, is_draw_shape, is_marker
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.manager import CanvasManager
|
||||
|
@ -184,7 +186,7 @@ class CanvasGraph(tk.Canvas):
|
|||
"""
|
||||
Draw a node or finish drawing an edge according to the current graph mode
|
||||
"""
|
||||
logging.debug("click release")
|
||||
logger.debug("click release")
|
||||
x, y = self.canvas_xy(event)
|
||||
if not self.inside_canvas(x, y):
|
||||
return
|
||||
|
@ -210,7 +212,7 @@ class CanvasGraph(tk.Canvas):
|
|||
else:
|
||||
self.focus_set()
|
||||
self.selected = self.get_selected(event)
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"click release selected(%s) mode(%s)", self.selected, self.manager.mode
|
||||
)
|
||||
if self.manager.mode == GraphMode.EDGE:
|
||||
|
@ -228,7 +230,7 @@ class CanvasGraph(tk.Canvas):
|
|||
edge = self.drawing_edge
|
||||
self.drawing_edge = None
|
||||
# edge dst must be a node
|
||||
logging.debug("current selected: %s", self.selected)
|
||||
logger.debug("current selected: %s", self.selected)
|
||||
dst_node = self.nodes.get(self.selected)
|
||||
if not dst_node:
|
||||
edge.delete()
|
||||
|
@ -331,8 +333,8 @@ class CanvasGraph(tk.Canvas):
|
|||
self.offset[0] * factor + event.x * (1 - factor),
|
||||
self.offset[1] * factor + event.y * (1 - factor),
|
||||
)
|
||||
logging.debug("ratio: %s", self.ratio)
|
||||
logging.debug("offset: %s", self.offset)
|
||||
logger.debug("ratio: %s", self.ratio)
|
||||
logger.debug("offset: %s", self.offset)
|
||||
self.app.statusbar.set_zoom(self.ratio)
|
||||
if self.wallpaper:
|
||||
self.redraw_wallpaper()
|
||||
|
@ -347,10 +349,10 @@ class CanvasGraph(tk.Canvas):
|
|||
|
||||
self.cursor = x, y
|
||||
selected = self.get_selected(event)
|
||||
logging.debug("click press(%s): %s", self.cursor, selected)
|
||||
logger.debug("click press(%s): %s", self.cursor, selected)
|
||||
x_check = self.cursor[0] - self.offset[0]
|
||||
y_check = self.cursor[1] - self.offset[1]
|
||||
logging.debug("click press offset(%s, %s)", x_check, y_check)
|
||||
logger.debug("click press offset(%s, %s)", x_check, y_check)
|
||||
is_node = selected in self.nodes
|
||||
if self.manager.mode == GraphMode.EDGE and is_node:
|
||||
node = self.nodes[selected]
|
||||
|
@ -387,7 +389,7 @@ class CanvasGraph(tk.Canvas):
|
|||
node = self.nodes[selected]
|
||||
self.select_object(node.id)
|
||||
self.selected = selected
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"selected node(%s), coords: (%s, %s)",
|
||||
node.core_node.name,
|
||||
node.core_node.position.x,
|
||||
|
@ -397,7 +399,7 @@ class CanvasGraph(tk.Canvas):
|
|||
shadow_node = self.shadow_nodes[selected]
|
||||
self.select_object(shadow_node.id)
|
||||
self.selected = selected
|
||||
logging.debug(
|
||||
logger.debug(
|
||||
"selected shadow node(%s), coords: (%s, %s)",
|
||||
shadow_node.node.core_node.name,
|
||||
shadow_node.node.core_node.position.x,
|
||||
|
@ -418,7 +420,7 @@ class CanvasGraph(tk.Canvas):
|
|||
self.cursor = x, y
|
||||
|
||||
# handle multiple selections
|
||||
logging.debug("control left click: %s", event)
|
||||
logger.debug("control left click: %s", event)
|
||||
selected = self.get_selected(event)
|
||||
if (
|
||||
selected not in self.selection
|
||||
|
@ -489,12 +491,12 @@ class CanvasGraph(tk.Canvas):
|
|||
"""
|
||||
delete selected nodes and any data that relates to it
|
||||
"""
|
||||
logging.debug("press delete key")
|
||||
logger.debug("press delete key")
|
||||
if not self.app.core.is_runtime():
|
||||
self.delete_selected_objects()
|
||||
self.app.default_info()
|
||||
else:
|
||||
logging.debug("node deletion is disabled during runtime state")
|
||||
logger.debug("node deletion is disabled during runtime state")
|
||||
|
||||
def double_click(self, event: tk.Event) -> None:
|
||||
selected = self.get_selected(event)
|
||||
|
@ -606,10 +608,10 @@ class CanvasGraph(tk.Canvas):
|
|||
self.draw_wallpaper(image)
|
||||
|
||||
def redraw_canvas(self, dimensions: Tuple[int, int] = None) -> None:
|
||||
logging.debug("redrawing canvas to dimensions: %s", dimensions)
|
||||
logger.debug("redrawing canvas to dimensions: %s", dimensions)
|
||||
|
||||
# reset scale and move back to original position
|
||||
logging.debug("resetting scaling: %s %s", self.ratio, self.offset)
|
||||
logger.debug("resetting scaling: %s %s", self.ratio, self.offset)
|
||||
factor = 1 / self.ratio
|
||||
self.scale(tk.ALL, self.offset[0], self.offset[1], factor, factor)
|
||||
self.move(tk.ALL, -self.offset[0], -self.offset[1])
|
||||
|
@ -628,11 +630,11 @@ class CanvasGraph(tk.Canvas):
|
|||
|
||||
def redraw_wallpaper(self) -> None:
|
||||
if self.adjust_to_dim.get():
|
||||
logging.debug("drawing wallpaper to canvas dimensions")
|
||||
logger.debug("drawing wallpaper to canvas dimensions")
|
||||
self.resize_to_wallpaper()
|
||||
else:
|
||||
option = ScaleOption(self.scale_option.get())
|
||||
logging.debug("drawing canvas using scaling option: %s", option)
|
||||
logger.debug("drawing canvas using scaling option: %s", option)
|
||||
if option == ScaleOption.UPPER_LEFT:
|
||||
self.wallpaper_upper_left()
|
||||
elif option == ScaleOption.CENTERED:
|
||||
|
@ -640,7 +642,7 @@ class CanvasGraph(tk.Canvas):
|
|||
elif option == ScaleOption.SCALED:
|
||||
self.wallpaper_scaled()
|
||||
elif option == ScaleOption.TILED:
|
||||
logging.warning("tiled background not implemented yet")
|
||||
logger.warning("tiled background not implemented yet")
|
||||
self.organize()
|
||||
|
||||
def organize(self) -> None:
|
||||
|
@ -648,7 +650,7 @@ class CanvasGraph(tk.Canvas):
|
|||
self.tag_raise(tag)
|
||||
|
||||
def set_wallpaper(self, filename: Optional[str]) -> None:
|
||||
logging.info("setting canvas(%s) background: %s", self.id, filename)
|
||||
logger.info("setting canvas(%s) background: %s", self.id, filename)
|
||||
if filename:
|
||||
img = Image.open(filename)
|
||||
self.wallpaper = img
|
||||
|
@ -673,10 +675,10 @@ class CanvasGraph(tk.Canvas):
|
|||
|
||||
def copy(self) -> None:
|
||||
if self.core.is_runtime():
|
||||
logging.debug("copy is disabled during runtime state")
|
||||
logger.debug("copy is disabled during runtime state")
|
||||
return
|
||||
if self.selection:
|
||||
logging.debug("to copy nodes: %s", self.selection)
|
||||
logger.debug("to copy nodes: %s", self.selection)
|
||||
self.to_copy.clear()
|
||||
for node_id in self.selection.keys():
|
||||
canvas_node = self.nodes[node_id]
|
||||
|
@ -684,7 +686,7 @@ class CanvasGraph(tk.Canvas):
|
|||
|
||||
def paste(self) -> None:
|
||||
if self.core.is_runtime():
|
||||
logging.debug("paste is disabled during runtime state")
|
||||
logger.debug("paste is disabled during runtime state")
|
||||
return
|
||||
# maps original node canvas id to copy node canvas id
|
||||
copy_map = {}
|
||||
|
@ -825,7 +827,7 @@ class CanvasGraph(tk.Canvas):
|
|||
wallpaper = Path(wallpaper)
|
||||
if not wallpaper.is_file():
|
||||
wallpaper = appconfig.BACKGROUNDS_PATH.joinpath(wallpaper)
|
||||
logging.info("canvas(%s), wallpaper: %s", self.id, wallpaper)
|
||||
logger.info("canvas(%s), wallpaper: %s", self.id, wallpaper)
|
||||
if wallpaper.is_file():
|
||||
self.set_wallpaper(str(wallpaper))
|
||||
else:
|
||||
|
|
|
@ -19,6 +19,8 @@ from core.gui.graph.node import CanvasNode
|
|||
from core.gui.graph.shapeutils import ShapeType
|
||||
from core.gui.nodeutils import NodeDraw
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.coreclient import CoreClient
|
||||
|
@ -166,7 +168,7 @@ class CanvasManager:
|
|||
canvas_id = self._next_id()
|
||||
self.notebook.add(tab, text=f"Canvas {canvas_id}")
|
||||
unique_id = self.notebook.tabs()[-1]
|
||||
logging.info("creating canvas(%s)", canvas_id)
|
||||
logger.info("creating canvas(%s)", canvas_id)
|
||||
self.canvas_ids[unique_id] = canvas_id
|
||||
self.unique_ids[canvas_id] = unique_id
|
||||
|
||||
|
@ -213,7 +215,7 @@ class CanvasManager:
|
|||
self.unique_ids.clear()
|
||||
self.edges.clear()
|
||||
self.wireless_edges.clear()
|
||||
logging.info("cleared canvases")
|
||||
logger.info("cleared canvases")
|
||||
|
||||
# reset settings
|
||||
self.show_node_labels.set(True)
|
||||
|
@ -289,7 +291,7 @@ class CanvasManager:
|
|||
for canvas_config in config.get("canvases", []):
|
||||
canvas_id = canvas_config.get("id")
|
||||
if canvas_id is None:
|
||||
logging.error("canvas config id not provided")
|
||||
logger.error("canvas config id not provided")
|
||||
continue
|
||||
canvas = self.get(canvas_id)
|
||||
canvas.parse_metadata(canvas_config)
|
||||
|
@ -297,7 +299,7 @@ class CanvasManager:
|
|||
def add_core_node(self, core_node: Node) -> None:
|
||||
# get canvas tab for node
|
||||
canvas_id = core_node.canvas if core_node.canvas > 0 else 1
|
||||
logging.info("adding core node canvas(%s): %s", core_node.name, canvas_id)
|
||||
logger.info("adding core node canvas(%s): %s", core_node.name, canvas_id)
|
||||
canvas = self.get(canvas_id)
|
||||
image = nutils.get_icon(core_node, self.app)
|
||||
x = core_node.position.x
|
||||
|
@ -354,7 +356,7 @@ class CanvasManager:
|
|||
network_id = link.network_id if link.network_id else None
|
||||
token = create_wireless_token(src.id, dst.id, network_id)
|
||||
if token in self.wireless_edges:
|
||||
logging.warning("ignoring link that already exists: %s", link)
|
||||
logger.warning("ignoring link that already exists: %s", link)
|
||||
return
|
||||
edge = CanvasWirelessEdge(self.app, src, dst, network_id, token, link)
|
||||
self.wireless_edges[token] = edge
|
||||
|
|
|
@ -24,6 +24,8 @@ from core.gui.graph.edges import CanvasEdge, CanvasWirelessEdge
|
|||
from core.gui.graph.tooltip import CanvasTooltip
|
||||
from core.gui.images import ImageEnum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.graph import CanvasGraph
|
||||
|
@ -87,7 +89,7 @@ class CanvasNode:
|
|||
self.canvas.tag_bind(self.id, "<Button-1>", self.show_info)
|
||||
|
||||
def delete(self) -> None:
|
||||
logging.debug("Delete canvas node for %s", self.core_node)
|
||||
logger.debug("Delete canvas node for %s", self.core_node)
|
||||
self.canvas.delete(self.id)
|
||||
self.canvas.delete(self.text_id)
|
||||
self.delete_antennas()
|
||||
|
@ -110,7 +112,7 @@ class CanvasNode:
|
|||
"""
|
||||
delete one antenna
|
||||
"""
|
||||
logging.debug("Delete an antenna on %s", self.core_node.name)
|
||||
logger.debug("Delete an antenna on %s", self.core_node.name)
|
||||
if self.antennas:
|
||||
antenna_id = self.antennas.pop()
|
||||
self.canvas.delete(antenna_id)
|
||||
|
@ -120,7 +122,7 @@ class CanvasNode:
|
|||
"""
|
||||
delete all antennas
|
||||
"""
|
||||
logging.debug("Remove all antennas for %s", self.core_node.name)
|
||||
logger.debug("Remove all antennas for %s", self.core_node.name)
|
||||
for antenna_id in self.antennas:
|
||||
self.canvas.delete(antenna_id)
|
||||
self.antennas.clear()
|
||||
|
@ -400,7 +402,7 @@ class CanvasNode:
|
|||
|
||||
def update_icon(self, icon_path: str) -> None:
|
||||
if not Path(icon_path).exists():
|
||||
logging.error(f"node icon does not exist: {icon_path}")
|
||||
logger.error(f"node icon does not exist: {icon_path}")
|
||||
return
|
||||
self.core_node.icon = icon_path
|
||||
self.image = images.from_file(icon_path, width=images.NODE_SIZE)
|
||||
|
|
|
@ -5,6 +5,8 @@ from core.gui.dialogs.shapemod import ShapeDialog
|
|||
from core.gui.graph import tags
|
||||
from core.gui.graph.shapeutils import ShapeType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.graph import CanvasGraph
|
||||
|
@ -92,7 +94,7 @@ class Shape:
|
|||
shape = Shape(app, canvas, shape_type, *coords, data=data)
|
||||
canvas.shapes[shape.id] = shape
|
||||
except ValueError:
|
||||
logging.exception("unknown shape: %s", shape_type)
|
||||
logger.exception("unknown shape: %s", shape_type)
|
||||
|
||||
def draw(self) -> None:
|
||||
if self.created:
|
||||
|
@ -139,7 +141,7 @@ class Shape:
|
|||
state=self.app.manager.show_annotations.state(),
|
||||
)
|
||||
else:
|
||||
logging.error("unknown shape type: %s", self.shape_type)
|
||||
logger.error("unknown shape type: %s", self.shape_type)
|
||||
self.created = True
|
||||
|
||||
def get_font(self) -> List[Union[int, str]]:
|
||||
|
@ -192,7 +194,7 @@ class Shape:
|
|||
self.canvas.move(self.text_id, x_offset, y_offset)
|
||||
|
||||
def delete(self) -> None:
|
||||
logging.debug("Delete shape, id(%s)", self.id)
|
||||
logger.debug("Delete shape, id(%s)", self.id)
|
||||
self.canvas.delete(self.id)
|
||||
self.canvas.delete(self.text_id)
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ from core.gui import nodeutils as nutils
|
|||
from core.gui.graph.edges import CanvasEdge
|
||||
from core.gui.graph.node import CanvasNode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -196,12 +198,12 @@ class InterfaceManager:
|
|||
else:
|
||||
self.current_subnets = self.next_subnets()
|
||||
else:
|
||||
logging.info("ignoring subnet change for link between network nodes")
|
||||
logger.info("ignoring subnet change for link between network nodes")
|
||||
|
||||
def find_subnets(
|
||||
self, canvas_node: CanvasNode, visited: Set[int] = None
|
||||
) -> Optional[IPNetwork]:
|
||||
logging.info("finding subnet for node: %s", canvas_node.core_node.name)
|
||||
logger.info("finding subnet for node: %s", canvas_node.core_node.name)
|
||||
subnets = None
|
||||
if not visited:
|
||||
visited = set()
|
||||
|
@ -220,7 +222,7 @@ class InterfaceManager:
|
|||
else:
|
||||
subnets = self.find_subnets(check_node, visited)
|
||||
if subnets:
|
||||
logging.info("found subnets: %s", subnets)
|
||||
logger.info("found subnets: %s", subnets)
|
||||
break
|
||||
return subnets
|
||||
|
||||
|
@ -244,7 +246,7 @@ class InterfaceManager:
|
|||
iface1=src_iface,
|
||||
iface2=dst_iface,
|
||||
)
|
||||
logging.info("added link between %s and %s", src_node.name, dst_node.name)
|
||||
logger.info("added link between %s and %s", src_node.name, dst_node.name)
|
||||
return link
|
||||
|
||||
def create_iface(self, canvas_node: CanvasNode, wireless_link: bool) -> Interface:
|
||||
|
@ -266,5 +268,5 @@ class InterfaceManager:
|
|||
ip6=ip6,
|
||||
ip6_mask=ip6_mask,
|
||||
)
|
||||
logging.info("create node(%s) interface(%s)", node.name, iface)
|
||||
logger.info("create node(%s) interface(%s)", node.name, iface)
|
||||
return iface
|
||||
|
|
|
@ -27,6 +27,8 @@ from core.gui.graph.manager import CanvasManager
|
|||
from core.gui.observers import ObserversMenu
|
||||
from core.gui.task import ProgressTask
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -274,10 +276,10 @@ class Menubar(tk.Menu):
|
|||
|
||||
def open_recent_files(self, file_path: Path) -> None:
|
||||
if file_path.is_file():
|
||||
logging.debug("Open recent file %s", file_path)
|
||||
logger.debug("Open recent file %s", file_path)
|
||||
self.open_xml_task(file_path)
|
||||
else:
|
||||
logging.warning("File does not exist %s", file_path)
|
||||
logger.warning("File does not exist %s", file_path)
|
||||
|
||||
def update_recent_files(self) -> None:
|
||||
self.recent_menu.delete(0, tk.END)
|
||||
|
@ -429,23 +431,23 @@ class Menubar(tk.Menu):
|
|||
canvas.show_hidden()
|
||||
|
||||
def click_session_options(self) -> None:
|
||||
logging.debug("Click options")
|
||||
logger.debug("Click options")
|
||||
dialog = SessionOptionsDialog(self.app)
|
||||
if not dialog.has_error:
|
||||
dialog.show()
|
||||
|
||||
def click_sessions(self) -> None:
|
||||
logging.debug("Click change sessions")
|
||||
logger.debug("Click change sessions")
|
||||
dialog = SessionsDialog(self.app)
|
||||
dialog.show()
|
||||
|
||||
def click_hooks(self) -> None:
|
||||
logging.debug("Click hooks")
|
||||
logger.debug("Click hooks")
|
||||
dialog = HooksDialog(self.app)
|
||||
dialog.show()
|
||||
|
||||
def click_servers(self) -> None:
|
||||
logging.debug("Click emulation servers")
|
||||
logger.debug("Click emulation servers")
|
||||
dialog = ServersDialog(self.app)
|
||||
dialog.show()
|
||||
|
||||
|
@ -458,7 +460,7 @@ class Menubar(tk.Menu):
|
|||
padding = (images.NODE_SIZE / 2) + 10
|
||||
layout_size = padding + images.NODE_SIZE
|
||||
col_count = width // layout_size
|
||||
logging.info(
|
||||
logger.info(
|
||||
"auto grid layout: dimension(%s, %s) col(%s)", width, height, col_count
|
||||
)
|
||||
canvas = self.manager.current()
|
||||
|
|
|
@ -8,6 +8,8 @@ from core.gui import images
|
|||
from core.gui.appconfig import CustomNode, GuiConfig
|
||||
from core.gui.images import ImageEnum
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -118,11 +120,11 @@ def get_icon(node: Node, app: "Application") -> PhotoImage:
|
|||
try:
|
||||
image = images.from_file(node.icon, width=images.NODE_SIZE, scale=scale)
|
||||
except OSError:
|
||||
logging.error("invalid icon: %s", node.icon)
|
||||
logger.error("invalid icon: %s", node.icon)
|
||||
# custom node
|
||||
elif is_custom(node):
|
||||
image_file = _get_custom_file(app.guiconfig, node.model)
|
||||
logging.info("custom node file: %s", image_file)
|
||||
logger.info("custom node file: %s", image_file)
|
||||
if image_file:
|
||||
image = images.from_file(image_file, width=images.NODE_SIZE, scale=scale)
|
||||
# built in node
|
||||
|
|
|
@ -4,6 +4,8 @@ import time
|
|||
import tkinter as tk
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional, Tuple
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -43,7 +45,7 @@ class ProgressTask:
|
|||
if self.callback:
|
||||
self.app.after(0, self.callback, *values)
|
||||
except Exception as e:
|
||||
logging.exception("progress task exception")
|
||||
logger.exception("progress task exception")
|
||||
self.app.show_exception("Task Error", e)
|
||||
finally:
|
||||
self.app.after(0, self.complete)
|
||||
|
|
|
@ -20,6 +20,8 @@ from core.gui.task import ProgressTask
|
|||
from core.gui.themes import Styles
|
||||
from core.gui.tooltip import Tooltip
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -338,7 +340,7 @@ class Toolbar(ttk.Frame):
|
|||
type_enum: NodeTypeEnum,
|
||||
image: PhotoImage,
|
||||
) -> None:
|
||||
logging.debug("update button(%s): %s", button, node_draw)
|
||||
logger.debug("update button(%s): %s", button, node_draw)
|
||||
button.configure(image=image)
|
||||
button.image = image
|
||||
self.app.manager.node_draw = node_draw
|
||||
|
@ -399,7 +401,7 @@ class Toolbar(ttk.Frame):
|
|||
"""
|
||||
redraw buttons on the toolbar, send node and link messages to grpc server
|
||||
"""
|
||||
logging.info("clicked stop button")
|
||||
logger.info("clicked stop button")
|
||||
self.app.menubar.set_state(is_runtime=False)
|
||||
self.app.core.close_mobility_players()
|
||||
enable_buttons(self.runtime_frame, enabled=False)
|
||||
|
@ -415,7 +417,7 @@ class Toolbar(ttk.Frame):
|
|||
def update_annotation(
|
||||
self, shape_type: ShapeType, image_enum: ImageEnum, image: PhotoImage
|
||||
) -> None:
|
||||
logging.debug("clicked annotation")
|
||||
logger.debug("clicked annotation")
|
||||
self.annotation_button.configure(image=image)
|
||||
self.annotation_button.image = image
|
||||
self.app.manager.annotation_type = shape_type
|
||||
|
@ -433,7 +435,7 @@ class Toolbar(ttk.Frame):
|
|||
self.marker_frame.grid()
|
||||
|
||||
def click_run_button(self) -> None:
|
||||
logging.debug("Click on RUN button")
|
||||
logger.debug("Click on RUN button")
|
||||
dialog = RunToolDialog(self.app)
|
||||
dialog.show()
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ from core.gui import appconfig, themes, validation
|
|||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -161,7 +163,7 @@ class ConfigFrame(ttk.Notebook):
|
|||
)
|
||||
entry.grid(row=index, column=1, sticky=tk.EW)
|
||||
else:
|
||||
logging.error("unhandled config option type: %s", option.type)
|
||||
logger.error("unhandled config option type: %s", option.type)
|
||||
self.values[option.name] = value
|
||||
|
||||
def parse_config(self) -> Dict[str, str]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue