fixed encoding problems

* in getNumberIp
* in moveDNSForwardRecord
This commit is contained in:
Иван Дзюбенко 2021-09-24 15:30:31 +03:00
parent 9d75aaf80d
commit 1e79cbe690
2 changed files with 7 additions and 7 deletions

View file

@ -273,6 +273,7 @@ class shareIP:
def getNumberIP(self, ip):
"""По строке ip получаем число (номер ip)"""
ip = ip if isinstance(ip, str) else ip.decode("UTF-8")
octetsIp = [int(x) for x in ip.split(".")]
octetsMult = (0x1, 0x100, 0x10000, 0x1000000)
ipNumb = 0
@ -1293,7 +1294,7 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon, prnServ):
if flagError:
return False
#Запишем переменные в клиентскую секцию
for name,value in dictVar.items():
for name, value in dictVar.items():
value = str(value)
if not value.strip():
self.clVars.Delete(name)
@ -19498,16 +19499,16 @@ class servDns(shareLdap):
return False
# Данные
data = foundOld[0][0][1]
data["zoneName"] = [newZoneName]
data["relativeDomainName"] = [newHostName]
domainEntry = [x.encode("UTF-8") for x in data.items()]
data["zoneName"] = [newZoneName.encode("UTF-8")]
data["relativeDomainName"] = [newHostName.encode("UTF-8")]
domainEntry = [x for x in data.items()]
# Добавляем новую запись
baseDN = self.clVars.Get("ld_dns_dn")
ouZonesDN = self.getOUZonesDN(newZoneName)
zoneBaseDN = "zoneName=%s,%s,%s"%(newZoneName, ouZonesDN, baseDN)
domainDN = self.addDN("relativeDomainName=%s" %newHostName,zoneBaseDN)
domainDN = self.addDN("relativeDomainName=%s" % newHostName, zoneBaseDN)
# Сообщение в случае ошибки
errorMessage = _('Can not add record "%s" in LDAP'%newDomainName)
errorMessage = _('Can not add record "%s" in LDAP' % newDomainName)
# Добавляем запись
if not self.addEntry(domainDN, domainEntry, errorMessage):
return False

View file

@ -45,7 +45,6 @@ def firstChild(element):
return element[0]
def insertBefore(elem, new_child, ref_child):
child_parent = new_child.getparent()
if child_parent is not None:
child_parent.remove(new_child)