parkouss / pyewmh

An implementation of EWMH (Extended Window Manager Hints) for python, based on Xlib.
GNU Lesser General Public License v3.0
40 stars 15 forks source link

Xlib.error.ConnectionClosedError: Display connection closed by server #12

Open Aufschlauer opened 8 years ago

Aufschlauer commented 8 years ago

Hi,

we're using pyewmh for a long time on our build server to simulate GUI events.

But since pyewmh-0.1.5 something significant must have been changed. We're no longer able to use ewmh on our build server:

vagrant@vagrant-ubuntu-saucy-64:~$ python3
Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ewmh
>>> l_ewmh = ewmh.EWMH()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/dist-packages/ewmh/ewmh.py", line 50, in __init__
    self.display = _display or display.Display()
  File "/usr/local/lib/python3.3/dist-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 132, in __init__
    auth_prot_data = auth_data)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 1033, in __init__
    display.send_and_recv(request = -1)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 573, in send_and_recv
    raise self.socket_error
Xlib.error.ConnectionClosedError: Display connection closed by server
>>> 
vagrant@vagrant-ubuntu-saucy-64:~$ echo $DISPLAY
localhost:10.0
vagrant@vagrant-ubuntu-saucy-64:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 13.10
Release:        13.10
Codename:       saucy

I've no problem running l_ewmh = ewmh.EWMH() on the desktop, but on build server it fails. Installation of pyewmh-0.1.5 on a clean build server looks like this:

Collecting ewmh
  Downloading ewmh-0.1.5.tar.gz
Collecting python-xlib (from ewmh)
  Downloading python_xlib-0.17-py3-none-any.whl (119kB)
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in /usr/local/lib/python3.3/dist-packages (from python-xlib->ewmh)
Installing collected packages: python-xlib, ewmh
  Running setup.py install for ewmh: started
    Running setup.py install for ewmh: finished with status 'done'
Successfully installed ewmh-0.1.5 python-xlib-0.17

Any ideas what's wrong?

Thanks in advance.

parkouss commented 8 years ago

Hum, since ewmh 0.1.5, we use the xlib package provided on pypi (it was basically a fix for python2):

https://github.com/parkouss/pyewmh/commit/308d4d7c504c966f4d9d69be2a31717c02879d33

It looks like you are using python3, and we changed the dependency from python3-xlib to python-xlib. Maybe this is the issue? I did a quick test and it looked fine, but I am not sure the packages really are the same. Could you could try to change the dependency to python3-xlib, and tell me if that help?

Aufschlauer commented 8 years ago

Well, between ewmh 0.1.4 and 0.1.5 there is at least a change in return value: When you call

self.ewmh.getWmName(l_window)

you get with 0.1.4 a string like

"Window name"

but since ewmh 0.1.5 you get literals:

b'Window name'

both running python3 and values taken from eclipse debugger. But true, this is easily fixable on my side.

But the Xlib.error.ConnectionClosedError remains when I set the install_requires to python3-xlib:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup
import sys, re

if sys.version_info < (2, 6):
    sys.exit("ewmh >= 0.1.3 requires python >= 2.6")

setup(name='ewmh',
      version=re.findall("__version__ = '(.+)'", open('ewmh/__init__.py').read())[0],
      description='python implementation of Extended Window Manager Hints, based on Xlib',
      long_description=open('README.rst').read(),
      author='parkouss',
      author_email="j.parkouss@gmail.com",
      url='https://github.com/parkouss/pyewmh',
      packages=['ewmh'],
      install_requires=['python3-xlib'],
      license='LGPL',
      classifiers=(
          'Programming Language :: Python :: 2',
          'Programming Language :: Python :: 3',
          'Intended Audience :: Developers',
      ),
)

Build and installation looks like this:

vagrant@vagrant-ubuntu-saucy-64:/tmp/ewmh-0.1.5$ sudo python3 setup.py install
running install
Checking .pth file support in /usr/local/lib/python3.3/dist-packages/
/usr/bin/python3 -E -c pass
TEST PASSED: /usr/local/lib/python3.3/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing dependency_links to ewmh.egg-info/dependency_links.txt
writing ewmh.egg-info/PKG-INFO
writing requirements to ewmh.egg-info/requires.txt
writing top-level names to ewmh.egg-info/top_level.txt
reading manifest file 'ewmh.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'doc/_build'
writing manifest file 'ewmh.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/ewmh
copying ewmh/ewmh.py -> build/lib/ewmh
copying ewmh/__init__.py -> build/lib/ewmh
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/ewmh
copying build/lib/ewmh/ewmh.py -> build/bdist.linux-x86_64/egg/ewmh
copying build/lib/ewmh/__init__.py -> build/bdist.linux-x86_64/egg/ewmh
byte-compiling build/bdist.linux-x86_64/egg/ewmh/ewmh.py to ewmh.cpython-33.pyc
byte-compiling build/bdist.linux-x86_64/egg/ewmh/__init__.py to __init__.cpython-33.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying ewmh.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ewmh.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ewmh.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ewmh.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ewmh.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/ewmh-0.1.5-py3.3.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing ewmh-0.1.5-py3.3.egg
creating /usr/local/lib/python3.3/dist-packages/ewmh-0.1.5-py3.3.egg
Extracting ewmh-0.1.5-py3.3.egg to /usr/local/lib/python3.3/dist-packages
Adding ewmh 0.1.5 to easy-install.pth file

Installed /usr/local/lib/python3.3/dist-packages/ewmh-0.1.5-py3.3.egg
Processing dependencies for ewmh==0.1.5
Searching for python3-xlib==0.15
Best match: python3-xlib 0.15
Adding python3-xlib 0.15 to easy-install.pth file

Using /usr/local/lib/python3.3/dist-packages
Finished processing dependencies for ewmh==0.1.5

Trying to get an instance still looks like this:

vagrant@vagrant-ubuntu-saucy-64:/tmp/ewmh-0.1.5$ python3
Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ewmh
>>> l_ewmh = ewmh.EWMH()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./ewmh/ewmh.py", line 50, in __init__
    self.display = _display or display.Display()
  File "/usr/local/lib/python3.3/dist-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 132, in __init__
    auth_prot_data = auth_data)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 1033, in __init__
    display.send_and_recv(request = -1)
  File "/usr/local/lib/python3.3/dist-packages/Xlib/protocol/display.py", line 573, in send_and_recv
    raise self.socket_error
Xlib.error.ConnectionClosedError: Display connection closed by server
>>> 

When I install ewmh like ${PIP3_PATH}/pip3 install ewmh==0.1.4 everything is fine again. So there must be a change somewhere... ;-)