Browse Source

DeviceManager: clean up Username field PR

- Restore the blank line between GetAllAddr and SearchXM, drop the
  stray blank lines added in ConfigXM and the trailing whitespace on
  the new Password label grid call.
- Rename the duplicated self.l6 used for the Username label to self.l8
  so the Password label's self.l6 is no longer shadowed.
- Prefill the Username entry from devices[dev] when the discovered
  value is available, falling back to "admin" only when missing.
- Drop the inline #"admin" comment.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pull/3/head
Dmitry Ilyin 1 month ago
parent
commit
854d41f39d
  1. 11
      DeviceManager.py

11
DeviceManager.py

@ -203,6 +203,7 @@ def GetAllAddr():
if "inet " in x and "127.0." not in x if "inet " in x and "127.0." not in x
] ]
def SearchXM(devices): def SearchXM(devices):
server = socket(AF_INET, SOCK_DGRAM) server = socket(AF_INET, SOCK_DGRAM)
server.bind(("", 34569)) server.bind(("", 34569))
@ -437,7 +438,6 @@ def SearchBeward(devices):
def ConfigXM(data): def ConfigXM(data):
config = {} config = {}
#TODO: may be just copy whwole devices[data[1]] to config? #TODO: may be just copy whwole devices[data[1]] to config?
for k in [u"HostName",u"HttpPort",u"MAC",u"MaxBps",u"MonMode",u"SSLPort",u"TCPMaxConn",u"TCPPort",u"TransferPlan",u"UDPPort","UseHSDownLoad"]: for k in [u"HostName",u"HttpPort",u"MAC",u"MaxBps",u"MonMode",u"SSLPort",u"TCPMaxConn",u"TCPPort",u"TransferPlan",u"UDPPort","UseHSDownLoad"]:
if k in devices[data[1]]: if k in devices[data[1]]:
@ -447,9 +447,8 @@ def ConfigXM(data):
config[u"GateWay"] = SetIP(data[4]) config[u"GateWay"] = SetIP(data[4])
config[u"HostIP"] = SetIP(data[2]) config[u"HostIP"] = SetIP(data[2])
config[u"Submask"] = SetIP(data[3]) config[u"Submask"] = SetIP(data[3])
config[u"Username"] = data[6] #"admin" config[u"Username"] = data[6]
config[u"Password"] = sofia_hash(data[5]) config[u"Password"] = sofia_hash(data[5])
devices[data[1]][u"GateWay"] = config[u"GateWay"] devices[data[1]][u"GateWay"] = config[u"GateWay"]
devices[data[1]][u"HostIP"] = config[u"HostIP"] devices[data[1]][u"HostIP"] = config[u"HostIP"]
devices[data[1]][u"Submask"] = config[u"Submask"] devices[data[1]][u"Submask"] = config[u"Submask"]
@ -935,8 +934,8 @@ class GUITk:
self.l5.grid(row=6, column=0, pady=3, padx=5, sticky=W + N) self.l5.grid(row=6, column=0, pady=3, padx=5, sticky=W + N)
self.tcp = Entry(self.fr_config, width=5, font="6") self.tcp = Entry(self.fr_config, width=5, font="6")
self.tcp.grid(row=6, column=1, pady=3, padx=5, sticky=W + N) self.tcp.grid(row=6, column=1, pady=3, padx=5, sticky=W + N)
self.l6 = Label(self.fr_config, text=_("Username")) self.l8 = Label(self.fr_config, text=_("Username"))
self.l6.grid(row=7, column=0, pady=3, padx=5, sticky=W + N) self.l8.grid(row=7, column=0, pady=3, padx=5, sticky=W + N)
self.username = Entry(self.fr_config, width=15, font="6") self.username = Entry(self.fr_config, width=15, font="6")
self.username.grid(row=7, column=1, pady=3, padx=5, sticky=W + N) self.username.grid(row=7, column=1, pady=3, padx=5, sticky=W + N)
self.l6 = Label(self.fr_config, text=_("Password")) self.l6 = Label(self.fr_config, text=_("Password"))
@ -1026,7 +1025,7 @@ class GUITk:
self.tcp.delete(0, END) self.tcp.delete(0, END)
self.tcp.insert(END, devices[dev]["TCPPort"]) self.tcp.insert(END, devices[dev]["TCPPort"])
self.username.delete(0, END) self.username.delete(0, END)
self.username.insert(END, "admin") self.username.insert(END, devices[dev].get("Username", "admin"))
def setconfig(self): def setconfig(self):
dev = self.table.item(self.table.selection()[0], option="values")[0] dev = self.table.item(self.table.selection()[0], option="values")[0]

Loading…
Cancel
Save