尝试访问 gandi 时出现 xmlrpclib 错误 'module not found' api
xmlrpclib error 'module not found' when trying to access gandi api
我正在尝试按照 gandi api support doc
中的描述在 gandi api 中设置 DS 记录
它指出 'import xmlrpclib' 但我立即收到错误 'module not found'(全文转载于下方)。
我 found this page 他们使用 'from xmlrpc import client',但在我的上下文中,gandi API 是 none 响应式的。
python3 会话:
>>> import xmlrpclib
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
import xmlrpclib
ImportError: No module named 'xmlrpclib'
>>> from xmlrpc import client
>>> api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#71>", line 1, in <module>
api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlrpclib' is not defined
>>> api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlclient' is not defined
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = '<my_api_key_here>'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
NameError: name 'domain' is not defined
>>> client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
AttributeError: 'module' object has no attribute 'dnssec'
如何通过 gandi 更新 DS 记录 API?
更新:
向我提供了以下代码,并出现无效密钥错误的错误。
我使用的密钥在 PhP
中众所周知
my_in_file = open('/home/ex-mailer-domains/'+domain+'/dsset-'+domain+'.', 'rt')
dstext = my_in_file.read()
dslist = dstext.split()[3:7]
print(dslist[3])
api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
api.domain.dnssec.create(apikey, 'domain2.com', {'algorithm': 8, 'flags': 256, 'public_key': dslist[3]})
xmlrpc.client.Fault: <Fault 510150: 'Error on object : OBJECT_ACCOUNT (CAUSE_NORIGHT) [Invalid API key]'>
更新:
密钥适用于此示例代码
但是在其他调用中使用它,我仍然得到错误:
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('xxxxx', 'domain2.com', 1, 256, '97BF8186C193EBF12A794A75FEF4B331A29C1A26')
我不确定你是否给出了真正的 API 密钥,但我敦促你尽快更改它。无论如何,在 Python 中,顶级 variables/names 不是凭空而来的——它们是由 import
或赋值语句 (x = 123
) 引入的,(或其他一些语句,例如 def
、class
通常)。
您从未将任何东西分配给 domain
变量,那么它不可能工作; xmlrpclib
也是如此;由于 import
语句失败,因此未定义名称。
那么:
>>> from xmlrpc import client
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = '123'
>>> api.domain.dnssec.create(apikey, 'domain2.com', {'algorithm': 42,
'flags': 123, 'public_key': 'foobarbaz'})
xmlrpclib 模块已在 Python 中重命名为 xmlrpc.client 3. 将源代码转换为 Python 时,2to3 工具将自动调整导入 3.
我正在尝试按照 gandi api support doc
中的描述在 gandi api 中设置 DS 记录它指出 'import xmlrpclib' 但我立即收到错误 'module not found'(全文转载于下方)。
我 found this page 他们使用 'from xmlrpc import client',但在我的上下文中,gandi API 是 none 响应式的。
python3 会话:
>>> import xmlrpclib
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
import xmlrpclib
ImportError: No module named 'xmlrpclib'
>>> from xmlrpc import client
>>> api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#71>", line 1, in <module>
api = xmlrpclib.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlrpclib' is not defined
>>> api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
api = xmlclient.ServerProxy('https://rpc.gandi.net/xmlrpc/')
NameError: name 'xmlclient' is not defined
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = '<my_api_key_here>'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
domain.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
NameError: name 'domain' is not defined
>>> client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
client.dnssec.create('KEY', 'domain2.com', 1, 256, 'KEY')
AttributeError: 'module' object has no attribute 'dnssec'
如何通过 gandi 更新 DS 记录 API?
更新: 向我提供了以下代码,并出现无效密钥错误的错误。 我使用的密钥在 PhP
中众所周知my_in_file = open('/home/ex-mailer-domains/'+domain+'/dsset-'+domain+'.', 'rt')
dstext = my_in_file.read()
dslist = dstext.split()[3:7]
print(dslist[3])
api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
api.domain.dnssec.create(apikey, 'domain2.com', {'algorithm': 8, 'flags': 256, 'public_key': dslist[3]})
xmlrpc.client.Fault: <Fault 510150: 'Error on object : OBJECT_ACCOUNT (CAUSE_NORIGHT) [Invalid API key]'>
更新: 密钥适用于此示例代码
但是在其他调用中使用它,我仍然得到错误:
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = 'MyKeyThatWorksInPHPjustFineForOtherScripts'
>>> version = api.version.info(apikey)
>>> print(version)
{'api_version': '3.3.29'}
>>> domain.dnssec.create('xxxxx', 'domain2.com', 1, 256, '97BF8186C193EBF12A794A75FEF4B331A29C1A26')
我不确定你是否给出了真正的 API 密钥,但我敦促你尽快更改它。无论如何,在 Python 中,顶级 variables/names 不是凭空而来的——它们是由 import
或赋值语句 (x = 123
) 引入的,(或其他一些语句,例如 def
、class
通常)。
您从未将任何东西分配给 domain
变量,那么它不可能工作; xmlrpclib
也是如此;由于 import
语句失败,因此未定义名称。
那么:
>>> from xmlrpc import client
>>> api = client.ServerProxy('https://rpc.gandi.net/xmlrpc/')
>>> apikey = '123'
>>> api.domain.dnssec.create(apikey, 'domain2.com', {'algorithm': 42,
'flags': 123, 'public_key': 'foobarbaz'})
xmlrpclib 模块已在 Python 中重命名为 xmlrpc.client 3. 将源代码转换为 Python 时,2to3 工具将自动调整导入 3.