splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

Unable to pass the hostname as unicode string?

Open hsebastian opened this issue 14 years ago • 1 comments

Hi,

We're using splunk-sdk and in our code we're getting the hostname as unicode string and pass it in like the example below. Is this be a bug or should my code handle it?

(env26_test)16:19 hsebastian@jemli ~> cat unicode.py 
import splunklib.client

service = splunklib.client.connect(host=u'localhost')
(env26_test)16:19 hsebastian@jemli ~> python unicode.py 
Traceback (most recent call last):
  File "unicode.py", line 3, in <module>
    service = splunklib.client.connect(host=u'localhost')
  File "/Users/hsebastian/storm_repo/env26_test/lib/python2.6/site-packages/splunklib/client.py", line 162, in connect
    return Service(**kwargs).login()
  File "/Users/hsebastian/storm_repo/env26_test/lib/python2.6/site-packages/splunklib/binding.py", line 206, in login
    password=self.password)
  File "/Users/hsebastian/storm_repo/env26_test/lib/python2.6/site-packages/splunklib/binding.py", line 372, in post
    return self.request(url, message)
  File "/Users/hsebastian/storm_repo/env26_test/lib/python2.6/site-packages/splunklib/binding.py", line 375, in request
    response = self.handler(url, message, **kwargs)
  File "/Users/hsebastian/storm_repo/env26_test/lib/python2.6/site-packages/splunklib/binding.py", line 430, in request
    connection.request(method, path, body, head)
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 914, in request
    self._send_request(method, url, body, headers)
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 951, in _send_request
    self.endheaders()
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 908, in endheaders
    self._send_output()
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 780, in _send_output
    self.send(msg)
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 739, in send
    self.connect()
  File "/Users/hsebastian/python267/lib/python2.6/httplib.py", line 1112, in connect
    sock = socket.create_connection((self.host, self.port), self.timeout)
  File "/Users/hsebastian/python267/lib/python2.6/socket.py", line 547, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.error: Int or String expected

hsebastian avatar May 16 '12 23:05 hsebastian

@hsebastian you are correct - it is a bug in the Python SDK. We have a fix, and it should be in the develop branch soon!

itay avatar May 17 '12 22:05 itay