是否存在IP名称的dns名称会导致此python错误消息?

时间:2016-06-13 19:15:43

标签: python python-2.7 soap suds

我正在尝试使用suds库运行以下脚本:

from suds.client import Client
from suds.transport.http import HttpAuthenticated
import os

t = HttpAuthenticated(username='xxxxxxx', password='xxxxxxxx')
url = 'http://10.14.9.42/NodeBeanService/NodeBean?wsdl'
client = Client(url, transport=t)

filterlimit = client.factory.create('ns3:constraint')
filterlimit.name = "maxObjects"
filterlimit.value = "30000"

filter1 = client.factory.create('ns3:condition')
filter1.name = "status"
filter1.operator = "EQ"
filter1.value = "NORMAL"

filter2 = client.factory.create('ns3:condition')
filter2.name = "notes"
filter2.operator = "NE"
filter2.value = "none"

filter = client.factory.create('ns3:expression')
filter.operator = "AND"
filter.subFilters = [filter1, filter2, filterlimit]

allNodes = client.service.getNodes(filter)
print "Nodes in topology:", len(allNodes.item)

for i in allNodes.item[:]:
  print i.name,i.notes,i.id

此脚本与一台服务器完美配合,但当我尝试另一台没有分配dns名称的服务器时,我不断收到以下错误:

C:\Users\pzsr7z.000\Documents>python testnnm.py
Traceback (most recent call last):
  File "testnnm.py", line 27, in <module>
    allNodes = client.service.getNodes(filter)
  File "C:\Python27\lib\site-packages\suds\client.py", line 521, in __call__
    return client.invoke(args, kwargs)
  File "C:\Python27\lib\site-packages\suds\client.py", line 581, in invoke
    result = self.send(soapenv)
  File "C:\Python27\lib\site-packages\suds\client.py", line 613, in send
    reply = self.options.transport.send(request)
  File "C:\Python27\lib\site-packages\suds\transport\http.py", line 239, in send
    return HttpTransport.send(self, request)
  File "C:\Python27\lib\site-packages\suds\transport\http.py", line 82, in send
    fp = self.u2open(u2request)
  File "C:\Python27\lib\site-packages\suds\transport\http.py", line 132, in u2open
    return url.open(u2request, timeout=tm)
  File "C:\Python27\lib\urllib2.py", line 431, in open
    response = self._open(req, data)
  File "C:\Python27\lib\urllib2.py", line 449, in _open
    '_open', req)
  File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 1227, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python27\lib\urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

可能导致此错误的原因是什么?

编辑: 此脚本也是从Windows 7环境

运行的

1 个答案:

答案 0 :(得分:0)

通过将服务器的IP添加到我的hosts文件,然后将其与服务器上硬编码的主机名相关联,我能够正常工作