Merge branch 'develop' into feature/config-service

This commit is contained in:
Blake Harnden 2020-01-17 21:13:07 -08:00
commit 43fe81a86e
13 changed files with 40 additions and 20 deletions

0
Pipfile Normal file
View file

View file

@ -54,7 +54,7 @@ class DistributedServer:
user's home directory
:param wait: True to wait for status, False to background process
:return: stdout when success
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
replace_env = env is not None

View file

@ -184,7 +184,7 @@ class Session:
:param _class: node class to get a node type for
:return: node type
:raises CoreError: when node type does not exist
:raises CoreError: when node type does not exist
"""
node_type = NODES_TYPE.get(_class)
if node_type is None:
@ -757,7 +757,7 @@ class Session:
:param node_id: id of node to update
:param options: data to update node with
:return: True if node updated, False otherwise
:raises core.CoreError: when node to update does not exist
:raises core.CoreError: when node to update does not exist
"""
# get node to update
node = self.get_node(node_id)
@ -1370,7 +1370,7 @@ class Session:
:param _id: node id to retrieve
:return: node for the given id
:raises core.CoreError: when node does not exist
:raises core.CoreError: when node does not exist
"""
if _id not in self.nodes:
raise CoreError(f"unknown node id {_id}")

View file

@ -93,6 +93,9 @@ class CoreClient:
self.handling_throughputs = None
self.handling_events = None
self.xml_dir = None
self.xml_file = None
def reset(self):
# helpers
self.interfaces_manager.reset()

View file

@ -189,6 +189,8 @@ class SessionsDialog(Dialog):
logging.error("querysessiondrawing.py invalid state")
def join_session(self, session_id: int):
if self.app.core.xml_file:
self.app.core.xml_file = None
self.app.statusbar.progress_bar.start(5)
task = BackgroundTask(self.app, self.app.core.join_session, args=(session_id,))
task.start()

View file

@ -133,7 +133,7 @@ class CanvasGraph(tk.Canvas):
self.bind("<ButtonPress-3>", lambda e: self.scan_mark(e.x, e.y))
self.bind("<B3-Motion>", lambda e: self.scan_dragto(e.x, e.y, gain=1))
def hide_context(self):
def hide_context(self, event=None):
if self.context:
self.context.unpost()
self.context = None
@ -642,9 +642,10 @@ class CanvasGraph(tk.Canvas):
if canvas_node:
logging.debug("node context: %s", selected)
self.context = canvas_node.create_context()
self.context.bind("<Leave>", self.hide_context)
self.context.post(event.x_root, event.y_root)
else:
self.hide_context()
# else:
# self.hide_context()
def press_delete(self, event: tk.Event):
"""

View file

@ -3,6 +3,7 @@ The actions taken when each menubar option is clicked
"""
import logging
import os
import tkinter as tk
import webbrowser
from tkinter import filedialog, messagebox
@ -61,8 +62,11 @@ class MenuAction:
def file_save_as_xml(self, event: tk.Event = None):
logging.info("menuaction.py file_save_as_xml()")
init_dir = self.app.core.xml_dir
if not init_dir:
init_dir = str(XMLS_PATH)
file_path = filedialog.asksaveasfilename(
initialdir=str(XMLS_PATH),
initialdir=init_dir,
title="Save As",
filetypes=(("EmulationScript XML files", "*.xml"), ("All files", "*")),
defaultextension=".xml",
@ -71,14 +75,19 @@ class MenuAction:
self.app.core.save_xml(file_path)
def file_open_xml(self, event: tk.Event = None):
init_dir = self.app.core.xml_dir
if not init_dir:
init_dir = str(XMLS_PATH)
logging.info("menuaction.py file_open_xml()")
file_path = filedialog.askopenfilename(
initialdir=str(XMLS_PATH),
initialdir=init_dir,
title="Open",
filetypes=(("XML Files", "*.xml"), ("All Files", "*")),
)
if file_path:
logging.info("opening xml: %s", file_path)
self.app.core.xml_file = file_path
self.app.core.xml_dir = str(os.path.dirname(file_path))
self.prompt_save_running_session()
self.app.statusbar.progress_bar.start(5)
task = BackgroundTask(self.app, self.app.core.open_xml, args=(file_path,))

View file

@ -52,11 +52,9 @@ class Menubar(tk.Menu):
label="Open...", command=self.menuaction.file_open_xml, accelerator="Ctrl+O"
)
self.app.bind_all("<Control-o>", self.menuaction.file_open_xml)
menu.add_command(
label="Save", accelerator="Ctrl+S", command=self.menuaction.file_save_as_xml
)
menu.add_command(label="Save", accelerator="Ctrl+S", command=self.save)
menu.add_command(label="Reload", underline=0, state=tk.DISABLED)
self.app.bind_all("<Control-s>", self.menuaction.file_save_as_xml)
self.app.bind_all("<Control-s>", self.save)
menu.add_separator()
menu.add_command(label="Export Python script...", state=tk.DISABLED)
menu.add_command(label="Execute XML or Python script...", state=tk.DISABLED)
@ -410,3 +408,10 @@ class Menubar(tk.Menu):
)
menu.add_command(label="About", command=self.menuaction.show_about)
self.add_cascade(label="Help", menu=menu)
def save(self):
xml_file = self.app.core.xml_file
if xml_file:
self.app.core.save_xml(xml_file)
else:
self.menuaction.file_save_as_xml()

View file

@ -111,7 +111,7 @@ class NodeBase:
:param wait: True to wait for status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
if self.server is None:
return utils.cmd(args, env, cwd, wait, shell)
@ -426,7 +426,7 @@ class CoreNodeBase(NodeBase):
:param wait: True to wait for status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
raise NotImplementedError
@ -607,7 +607,7 @@ class CoreNode(CoreNodeBase):
:param wait: True to wait for status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
if self.server is None:
return self.client.check_cmd(args, wait=wait, shell=shell)

View file

@ -60,7 +60,7 @@ class VnodeClient:
:param wait: True to wait for command status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises core.CoreCommandError: when there is a non-zero exit status
:raises core.CoreCommandError: when there is a non-zero exit status
"""
self._verify_connection()
args = self.create_cmd(args)

View file

@ -80,7 +80,7 @@ class CoreInterface:
:param wait: True to wait for status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
if self.server is None:
return utils.cmd(args, env, cwd, wait, shell)

View file

@ -309,7 +309,7 @@ class CoreNetwork(CoreNetworkBase):
:param wait: True to wait for status, False otherwise
:param shell: True to use shell, False otherwise
:return: combined stdout and stderr
:raises CoreCommandError: when a non-zero exit status occurs
:raises CoreCommandError: when a non-zero exit status occurs
"""
logging.debug("network node(%s) cmd", self.name)
output = utils.cmd(args, env, cwd, wait, shell)

View file

@ -373,7 +373,7 @@ class Rj45Node(CoreNodeBase, CoreInterface):
:param ifindex: interface index
:param ifname: interface name
:return: interface index
:raises ValueError: when an interface has already been created, one max
:raises ValueError: when an interface has already been created, one max
"""
with self.lock:
if ifindex is None: