Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/upcoming_release_notes/8-ref_sdfconfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ Maintenance
Contributors
------------
- zllentz

23 changes: 23 additions & 0 deletions docs/source/upcoming_release_notes/9-vlan_index_error.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
9 vlan_index_error
#################

API Breaks
----------
- N/A

Features
--------
- N/A

Bugfixes
--------
- Fix an issue where if there are VLANs that don't have hyphens (`-`) in their name,
the GUI crashes.

Maintenance
-----------
- N/A

Contributors
------------
- zllentz
4 changes: 2 additions & 2 deletions switchtool/sdfconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"""

import functools
import subprocess
import json
import subprocess


@functools.lru_cache(maxsize=1000)
def get_host_for_mac(mac_addr: str) -> str:
"""
Returns the hostname associated with a mac_addr

Returns an empty string if the mac as not found.

May raise if sdfconfig is not configured for the user.
Expand Down
55 changes: 41 additions & 14 deletions switchtool/ui/widgets/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from PyQt5.QtCore import QSettings, QTimer, pyqtSignal, pyqtSlot

from ...EpicsQT.qlogdisplay import QLogDisplay
from ...sdfconfig import get_subnet_for_host
from ...switch.switch import Switch
from .. import dialogs
from .vlan import VlanWidget
from ...sdfconfig import get_subnet_for_host


class SwitchWidget(QtWidgets.QWidget):
Expand All @@ -17,11 +17,20 @@ class SwitchWidget(QtWidgets.QWidget):
updated = pyqtSignal()
update_port = pyqtSignal(str, str, str, str, str, str)

def __init__(self, switch, user="admin", pw=None, switch_type=None, timeout=1.0, parent=None):
def __init__(
self, switch, user="admin", pw=None, switch_type=None, timeout=1.0, parent=None
):
super().__init__(parent=parent)
self.resize(660, 700)

self._switch = PyQtSwitch(switch, user=user, pw=pw, enablepw=None, switch_type=switch_type, parent=self)
self._switch = PyQtSwitch(
switch,
user=user,
pw=pw,
enablepw=None,
switch_type=switch_type,
parent=self,
)
self.switch_name = switch.split(".")[0]
self.refresh_timeout = timeout * 3600000 # Now ms!

Expand Down Expand Up @@ -110,7 +119,6 @@ def __init__(self, switch, user="admin", pw=None, switch_type=None, timeout=1.0,
self.repaint()
QTimer.singleShot(100, self.initial_update)


def initial_update(self):
self.updated.connect(self.refresh)
self.update_port.connect(self.refresh_port)
Expand Down Expand Up @@ -326,12 +334,21 @@ def refresh(self):
sub = "PCDSN-CDS-LAS"
if sub in allsubs.keys():
vl.append(allsubs[sub])
cds_vl = []
fez_vl = []
for v in vlist:
if v not in vl and allvlan[v].split("-")[1] == "CDS":
vl.append(v)
for v in vlist:
if v not in vl and allvlan[v].split("-")[1] == "FEZ":
vl.append(v)
if v in vl:
continue
try:
vlan_type = allvlan[v].split("-")[1]
except IndexError:
vlan_type = "NO_TYPE"
if vlan_type == "CDS":
cds_vl.append(v)
elif vlan_type == "FEZ":
fez_vl.append(v)
vl.extend(cds_vl)
vl.extend(fez_vl)
self._vlanList = vl

# Now, go through the prefered vlan list order. Add the
Expand Down Expand Up @@ -421,14 +438,24 @@ def write_memory(self):


class PyQtSwitch(Switch):
def __init__(self, switchname, user="admin", pw=None, enablepw=None, switch_type=None, parent=None):
def __init__(
self,
switchname,
user="admin",
pw=None,
enablepw=None,
switch_type=None,
parent=None,
):
self.parent = parent
if pw is None:
pw = dialogs.passwddialog.getPassword(
"Password for {:}: ".format(user)
)
pw = dialogs.passwddialog.getPassword("Password for {:}: ".format(user))
super().__init__(
switchname, user=user, pw=pw, enablepw=enablepw, switch_type=switch_type,
switchname,
user=user,
pw=pw,
enablepw=enablepw,
switch_type=switch_type,
)

def update(self):
Expand Down
Loading