I am trying to run the sample code in the “writing web services client applications” section.
I do just run this as regular python code no?
I get an error:
(gedit:4352): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
michael@michael-G41MT-ES2L:~/workspace/device$ sudo python test.py
Traceback (most recent call last):
File "test.py", line 32, in
webservice.endheaders()
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
michael@michael-G41MT-ES2L:~/workspace/device$ sudo gedit test.py
When running:
# The following lines require manual changes
username = "mickpc00" # enter your username
password = "#######" # enter your password
device_id = "000000000000000000409DFFFF5E015C" # enter device id of target
# Nothing below this line should need to be changed
# -------------------------------------------------
import httplib
import base64
# create HTTP basic authentication string, this consists of
# "username:password" base64 encoded
auth = base64.encodestring("%s:%s" % (username, password))[:-1]
# message to send to server
message = """
"""%(device_id)
webservice = httplib.HTTP("login.etherios.com ", 80)
# to what URL to send the request with a given HTTP method
webservice.putrequest("POST", "/ws/sci")
# add the authorization string into the HTTP header
webservice.putheader("Authorization", "Basic %s" % auth)
webservice.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
webservice.putheader("Content-length", "%d" % len(message))
webservice.endheaders()
webservice.send(message)
# get the response
statuscode, statusmessage, header = webservice.getreply()
response_body = webservice.getfile().read()
# print the output to standard out
print (statuscode, statusmessage)
print response_body
Any ideas on the problem?