GNOME Bugzilla – Bug 614249
Connection refused when importing ldtp module
Last modified: 2010-09-28 20:57:24 UTC
In Ubuntu 10.04, when I import ldtp module, I get a connection refused error. After two or three attempts the module is correctly imported. This is happening with ldtp 2.0.4, but it was happening with 2.0.3 as well. In [1]: import ldtp ** (-c:4829): WARNING **: Trying to register gtype 'WnckWindowState' as enum when in fact it is of type 'GFlags' ** (-c:4829): WARNING **: Trying to register gtype 'WnckWindowActions' as enum when in fact it is of type 'GFlags' ** (-c:4829): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as enum when in fact it is of type 'GFlags' --------------------------------------------------------------------------- error Traceback (most recent call last) /home/ara/curro/mago/trunk2/<ipython console> in <module>() /usr/lib/pymodules/python2.6/ldtp/__init__.py in <module>() 255 return None 256 --> 257 _populateNamespace(globals()) 258 _pollEvents = PollEvents() 259 thread.start_new_thread(_pollEvents.run, ()) /usr/lib/pymodules/python2.6/ldtp/__init__.py in _populateNamespace(d) 58 59 def _populateNamespace(d): ---> 60 for method in client._client.system.listMethods(): 61 if method.startswith('system.'): 62 continue /usr/lib/python2.6/xmlrpclib.pyc in __call__(self, *args) 1197 return _Method(self.__send, "%s.%s" % (self.__name, name)) 1198 def __call__(self, *args): -> 1199 return self.__send(self.__name, args) 1200 1201 ## /usr/lib/python2.6/xmlrpclib.pyc in __request(self, methodname, params) 1487 self.__handler, 1488 request, -> 1489 verbose=self.__verbose 1490 ) 1491 /usr/lib/pymodules/python2.6/ldtp/client.pyc in request(self, host, handler, request_body, verbose) 59 # Retry connecting again 60 return xmlrpclib.Transport.request( ---> 61 self, host, handler, request_body, verbose=0) 62 raise 63 except xmlrpclib.Fault, e: /usr/lib/python2.6/xmlrpclib.pyc in request(self, host, handler, request_body, verbose) 1233 self.send_host(h, host) 1234 self.send_user_agent(h) -> 1235 self.send_content(h, request_body) 1236 1237 errcode, errmsg, headers = h.getreply() /usr/lib/python2.6/xmlrpclib.pyc in send_content(self, connection, request_body) 1347 connection.putheader("Content-Type", "text/xml") 1348 connection.putheader("Content-Length", str(len(request_body))) -> 1349 connection.endheaders() 1350 if request_body: 1351 connection.send(request_body) /usr/lib/python2.6/httplib.pyc in endheaders(self) 902 raise CannotSendHeader() 903 --> 904 self._send_output() 905 906 def request(self, method, url, body=None, headers={}): /usr/lib/python2.6/httplib.pyc in _send_output(self) 774 msg = "\r\n".join(self._buffer) 775 del self._buffer[:] --> 776 self.send(msg) 777 778 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): /usr/lib/python2.6/httplib.pyc in send(self, str) 733 if self.sock is None: 734 if self.auto_open: --> 735 self.connect() 736 else: 737 raise NotConnected() /usr/lib/python2.6/httplib.pyc in connect(self) 714 """Connect to the host and port specified in __init__.""" 715 self.sock = socket.create_connection((self.host,self.port), --> 716 self.timeout) 717 718 if self._tunnel_host: /usr/lib/python2.6/socket.pyc in create_connection(address, timeout) 510 except error, msg: 511 if sock is not None: 512 sock.close() 513 --> 514 raise error, msg error: [Errno 111] Connection refused
I am afraid to add that with ldtp 2.0.4 and latest updates in Lucid, the connection refused error always happen.
Created attachment 157432 [details] [review] Proposed patch to fix the issue Ara, could you please try this in Ubuntu 10.04 ? I tried and this worked fine for me.
Review of attachment 157432 [details] [review]: Applied the patch. It seems to work for me with no adverse effects. Of course, the real test will be Ara's system as I have not been able to reproduce this bug.
As per discussion with Ara over IRC, the attached patch fixes the issue, committing to git head
Created attachment 157604 [details] [review] Update ldtpd to send a signal to ldtp when it's ready for requests On a fast system, this will actually slightly speed up the startup time associated with "import ldtp" - from 3 seconds to a little over 1 second. On a slower system, the attached patch will wait for up to 15 seconds for the daemon to report that it is ready to service requests. If the daemon doesn't send the ready signal, it will try anyway after 15 seconds and throw the exception (if any).
Created attachment 157620 [details] [review] Minor update to above patch
Eitan, are you okay with the above patch ?
Review of attachment 157604 [details] [review]: As James Tatum next patch is approved
Review of attachment 157620 [details] [review]: James, thanks for the patch
Committed in git
Today I installed ldtp in Ubuntu 10.04 Lucid. I received the following things when I tried to work with LDTP ~$python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from ldtp import* ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowState' as enum when in fact it is of type 'GFlags' ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowActions' as enum when in fact it is of type 'GFlags' ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as enum when in fact it is of type 'GFlags' Can you please fix this problem? -Mostafiz
There is nothing to fix. Those warnings are innocuous.
Sorry for resubmitting the same comment as comment 13. I opened "gedit". I wrote the following commands ~$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from ldtp import* ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowState' as enum when in fact it is of type 'GFlags' ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowActions' as enum when in fact it is of type 'GFlags' ** (-c:18128): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as enum when in fact it is of type 'GFlags' >>> guiexist ('frm*-gedit') 0 >>> According to the LDTP tutorial the command "guiexist ('frm*-gedit')" should return 1. I do not know what bug is causing this problem. Can you please look into the matter? Thanks -Mostafiz
Can you please try: getwindowlist() and report ? Guess this is a different issue, rather than the current bug. Request to create new bug, if required. Have you enabled accessibility ? Thanks
Thank you Nagappan. Enabling accessibility solves my problem with the command "guiexist ('frm*-gedit')". getWindowList() works perfectly. I hope that the three warning messages will not create problem for me. Regards -Mostafiz
Now, I have a problem for ldtp in Ubuntu 8.04. I installed ldtp and python-ldtp using "apt-get install" command. getapplist() command works without any exception. However, getwindowlist() throws exception >>>getwindowlist() Traceback (most recent call last):
+ Trace 223930
raise ldtpExecutionError(str (msg))
Hello Rahman, On Ubuntu 8.04, it's based on LDTPv1. Uninstall LDTP version, you have installed from Ubuntu repository, get the LDTPv1 source from git repository, compile and install it and see how it works ! http://ldtp.freedesktop.org/wiki/GIT Thanks
Mostafiz, This is a bug report. This is not the place to get support. Please stop posting support requests here. Please use the mailing list or IRC: http://ldtp.freedesktop.org/wiki/Mailing_list/IRC