Skip to content

Commit

Permalink
fix show errors in status line
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Pflug committed Feb 14, 2024
1 parent 0082868 commit 635ab5d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modBind/Zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
prioTypes=['MX', 'NS', 'SRV', 'TXT']
individualTypes=['A', 'AAAA', 'CNAME', 'PTR']

def admSetError(location, msg):
adm.SetStatus(xlt("DNS %s failed: %s") % (location, rcode.to_text(msg.rcode())))

class Zone(adm.Node):
typename=xlt("DNS Zone")
Expand All @@ -44,7 +46,7 @@ def GetInstances(parentNode):
if not parentNode.GetServer().IsCatalogZone(zone):
instances.append(Zone(parentNode, zone))
return instances

def MayHaveChildren(self):
if self.zones:
return True
Expand Down Expand Up @@ -322,7 +324,7 @@ def OnExecute(_parentWin, node):
if msg.rcode() == rcode.NOERROR:
wx.MessageBox(xlt("Incremented SOA serial number to %d") % node.soa[0].serial, xlt("New SOA serial number"))
else:
adm.SetStatus(xlt("DNS update failed: %s") % rcode.to_text(msg.rcode()))
admSetError("update", msg)

return True

Expand Down Expand Up @@ -530,6 +532,9 @@ def Check(self):

ok=self.CheckValid(ok, timeToFloat(self.TTL), xlt("Please enter valid TTL value"))
return ok

def SetError(self, msg):
self.node.GetServer().lastError=xlt("DNS update failed: %s") % rcode.to_text(msg.rcode())


class SingleValRecords(Record):
Expand Down Expand Up @@ -584,7 +589,7 @@ def _save(self, rds):
self.page.Display(None, False)
return True
else:
self.SetStatus(xlt("DNS update failed: %s") % rcode.to_text(msg.rcode()))
self.SetError(msg)
return False

def Check(self):
Expand Down Expand Up @@ -885,7 +890,7 @@ def Save(self):
updater.add(name, h6)
msg=self.node.GetServer().Send(updater)
if msg.rcode() != rcode.NOERROR:
self.SetStatus(xlt("DNS update failed: %s") % rcode.to_text(msg.rcode()))
self.SetError(msg)
return False
self.node.hosts4[name] = h4
self.node.hosts6[name] = h6
Expand Down Expand Up @@ -1014,7 +1019,8 @@ def Delete(self, _parentWin, names, types):

msg=node.GetServer().Send(updater)
if msg.rcode() != rcode.NOERROR:
self.SetStatus(xlt("DNS delete failed: %s") % rcode.to_text(msg.rcode()))
admSetError("delete", msg)

return False
for i in range(len(names)):
name=names[i]
Expand Down Expand Up @@ -1063,7 +1069,7 @@ def Delete(self, _parentWin, names, _types):
updater.delete(name, "AAAA")
msg=node.GetServer().Send(updater)
if msg.rcode() != rcode.NOERROR:
adm.SetStatus(xlt("DNS delete failed: %s") % rcode.to_text(msg.rcode()))
admSetError("delete", msg)
return False
for name in names:
if name in node.hosts4:
Expand Down

0 comments on commit 635ab5d

Please sign in to comment.