Skip to content

Commit

Permalink
Merge branch '2.2' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Nov 3, 2023
2 parents 7136210 + 3a7e06e commit da83230
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 126 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ image: Visual Studio 2022
platform: x64

environment:
PYTHON: "C:\\Python37-x64"
PYTHON: "C:\\Python38-x64"
DISTUTILS_USE_SDK: "1"

install:
Expand Down
14 changes: 14 additions & 0 deletions gns3/dialogs/style_editor_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,20 @@ def __init__(self, parent, items):
if not corner_radius:
corner_radius = first_item.verticalCornerRadius()
self.uiCornerRadiusSpinBox.setValue(corner_radius)
else:
self.uiCornerRadiusLabel.hide()
self.uiCornerRadiusSpinBox.hide()
self.uiRotationSpinBox.setValue(int(first_item.rotation()))
self.uiBorderWidthSpinBox.setValue(pen.width())
if isinstance(first_item, ShapeItem):
rect = first_item.rect()
self.uiWidthSpinBox.setValue(int(rect.width()))
self.uiHeightSpinBox.setValue(int(rect.height()))
else:
self.uiWidthSpinBox.hide()
self.uiWidthLabel.hide()
self.uiHeightSpinBox.hide()
self.uiHeightLabel.hide()
index = self.uiBorderStyleComboBox.findData(pen.style())
if index != -1:
self.uiBorderStyleComboBox.setCurrentIndex(index)
Expand Down Expand Up @@ -136,6 +148,8 @@ def _applyPreferencesSlot(self):
# maybe we support setting them separately in the future
item.setHorizontalCornerRadius(corner_radius)
item.setVerticalCornerRadius(corner_radius)
if isinstance(item, ShapeItem):
item.setWidthAndHeight(self.uiWidthSpinBox.value(), self.uiHeightSpinBox.value())
item.setRotation(self.uiRotationSpinBox.value())

def done(self, result):
Expand Down
3 changes: 3 additions & 0 deletions gns3/items/shape_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def hoverLeaveEvent(self, event):
if not self.locked():
self._graphics_view.setCursor(QtCore.Qt.ArrowCursor)

def setWidthAndHeight(self, width, height):
self.setRect(0, 0, width, height)

def fromSvg(self, svg):
"""
Import element information from SVG
Expand Down
8 changes: 6 additions & 2 deletions gns3/local_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,15 @@ def startLocalServer(self):
try:
if sys.platform.startswith("win"):
# use the string on Windows
self._local_server_process = subprocess.Popen(command, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, stderr=subprocess.PIPE)
self._local_server_process = subprocess.Popen(
command,
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
stderr=subprocess.PIPE,
env=os.environ)
else:
# use arguments on other platforms
args = shlex.split(command)
self._local_server_process = subprocess.Popen(args, stderr=subprocess.PIPE)
self._local_server_process = subprocess.Popen(args, stderr=subprocess.PIPE, env=os.environ)
except (OSError, subprocess.SubprocessError) as e:
log.warning('Could not start local server "{}": {}'.format(command, e))
return False
Expand Down
18 changes: 15 additions & 3 deletions gns3/packet_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,27 @@ def startPacketCaptureAnalyzer(self, link):

# PCAP capture file path
command = command.replace("%c", '"' + capture_file_path + '"')
command = command.replace("{pcap_file}", '"' + capture_file_path + '"')

# Add description
# Add project name
command = command.replace("%P", link.project().name())
command = command.replace("{project}", link.project().name().replace('"', '\\"'))

# Add link description
description = "{}[{}]->{}[{}]".format(link.sourceNode().name(),
link.sourcePort().name(),
link.destinationNode().name(),
link.destinationPort().name())
command = command.replace("%d", description)
command = command.replace("{link_description}", description)

if not sys.platform.startswith("win"):
command = shlex.split(command)
if len(command) == 0:
QtWidgets.QMessageBox.critical(self.parent(), "Packet Capture Analyzer", "No packet capture analyzer program configured")
return
try:
subprocess.Popen(command)
subprocess.Popen(command, env=os.environ)
except OSError as e:
QtWidgets.QMessageBox.critical(self.parent(), "Packet Capture Analyzer", "Can't start packet capture analyzer program {}".format(str(e)))
return
Expand Down Expand Up @@ -204,13 +210,19 @@ def _startPacketCommand(self, link, command):

# PCAP capture file path
command = command.replace("%c", '"' + capture_file_path + '"')
command = command.replace("{pcap_file}", '"' + capture_file_path + '"')

# Add project name
command = command.replace("%P", link.project().name())
command = command.replace("{project}", link.project().name().replace('"', '\\"'))

# Add description
# Add link description
description = "{} {} to {} {}".format(link.sourceNode().name(),
link.sourcePort().name(),
link.destinationNode().name(),
link.destinationPort().name())
command = command.replace("%d", description)
command = command.replace("{link_description}", description)

if "|" in command:
# live traffic capture (using tail)
Expand Down
Loading

0 comments on commit da83230

Please sign in to comment.