Python-ldap 添加条目使用 Robot Framework 失败
Python-ldap Add entry fails using Robot Framework
我正在尝试使用 python 添加条目并在 Robot TC 中调用它。我的 python 代码是:
#!/usr/bin/env python
import ldap
import ldap.modlist as modlist
def LdapAddObject(l,dn,attributeDict):
attrs={}
for key in sorted(attributeDict.keys()):
Attrib=getattr(attributeDict,key)
attrs[key]=Attrib
print attrs
ldif=modlist.addModlist(attrs)
l.add_s(dn,ldif)
l.unbind_s()
我的机器人代码是:
*** Settings ***
Documentation This testsuite checks the LDAP functionalities of DB nodes.
*** Test Cases ***
Perform Ldap Operations
${ObjList} Create List subscriber
&{DN-Dict} Create Dictionary objectclass=${ObjList} uid='2620105000000'
${ldapObj} ldapopen ${DB_1_EXT_APP_IP}
LdapAddObject ${ldapObj} uid=262010500,ds=hello,o=DEF,dc=LDB ${DN-Dict}
它给我一个错误提示:
TypeError: ('expected a string in the list', u'subscriber')
它肯定是在 add_s 函数中的某处失败了。
python-ldap 曾经有 Unicode 字符串的问题 - 我已经很长时间没有使用它了,不确定它是否在最新版本中修复了。
查看错误,虽然这里看起来就是这种情况 - 只需将任何 unicode 参数转换为字符串,例如使用 RF Convert To String
或 python 的 str()
编辑:例如,投射名单成员:
${subscriber} Convert To String subscriber
${ObjList} Create List ${subs}
与字典值类似。
我正在尝试使用 python 添加条目并在 Robot TC 中调用它。我的 python 代码是:
#!/usr/bin/env python
import ldap
import ldap.modlist as modlist
def LdapAddObject(l,dn,attributeDict):
attrs={}
for key in sorted(attributeDict.keys()):
Attrib=getattr(attributeDict,key)
attrs[key]=Attrib
print attrs
ldif=modlist.addModlist(attrs)
l.add_s(dn,ldif)
l.unbind_s()
我的机器人代码是:
*** Settings ***
Documentation This testsuite checks the LDAP functionalities of DB nodes.
*** Test Cases ***
Perform Ldap Operations
${ObjList} Create List subscriber
&{DN-Dict} Create Dictionary objectclass=${ObjList} uid='2620105000000'
${ldapObj} ldapopen ${DB_1_EXT_APP_IP}
LdapAddObject ${ldapObj} uid=262010500,ds=hello,o=DEF,dc=LDB ${DN-Dict}
它给我一个错误提示:
TypeError: ('expected a string in the list', u'subscriber')
它肯定是在 add_s 函数中的某处失败了。
python-ldap 曾经有 Unicode 字符串的问题 - 我已经很长时间没有使用它了,不确定它是否在最新版本中修复了。
查看错误,虽然这里看起来就是这种情况 - 只需将任何 unicode 参数转换为字符串,例如使用 RF Convert To String
或 python 的 str()
编辑:例如,投射名单成员:
${subscriber} Convert To String subscriber
${ObjList} Create List ${subs}
与字典值类似。