Evidlo / passhole

A secure hole for your passwords (KeePass CLI)
GNU General Public License v3.0
199 stars 19 forks source link

pynput crashes without X #8

Closed chew-z closed 6 years ago

chew-z commented 6 years ago

Since 1.6 I think passhole on my machine will crash with

Xlib.error.DisplayNameError: Bad display name ""

The reason is that I am running Debian stretch in pure cli environment (via crouton on ChromeOS) without X and pynput crashes.

I have added export DISPLAY=":0" and passhole started working again but perhaps it could have been handled better or mentioned in documentation.

Traceback (most recent call last):
  File "/home/rrj/.local/bin/ph", line 7, in <module>
    from passhole.passhole import main
  File "/home/rrj/.local/lib/python3.5/site-packages/passhole/passhole.py", line 12, in <module>
    from pynput.keyboard import Controller, Key
  File "/home/rrj/.local/lib/python3.5/site-packages/pynput/__init__.py", line 23, in <module>
    from . import keyboard
  File "/home/rrj/.local/lib/python3.5/site-packages/pynput/keyboard/__init__.py", line 49, in <module>
    from ._xorg import KeyCode, Key, Controller, Listener
  File "/home/rrj/.local/lib/python3.5/site-packages/pynput/keyboard/_xorg.py", line 38, in <module>
    from pynput._util.xorg import (
  File "/home/rrj/.local/lib/python3.5/site-packages/pynput/_util/xorg.py", line 38, in <module>
    _check()
  File "/home/rrj/.local/lib/python3.5/site-packages/pynput/_util/xorg.py", line 36, in _check
    display = Xlib.display.Display()
  File "/home/rrj/.local/lib/python3.5/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
  File "/home/rrj/.local/lib/python3.5/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
  File "/home/rrj/.local/lib/python3.5/site-packages/Xlib/protocol/display.py", line 85, in __init__
    name, protocol, host, displayno, screenno = connect.get_display(display)
  File "/home/rrj/.local/lib/python3.5/site-packages/Xlib/support/connect.py", line 73, in get_display
    return mod.get_display(display)
  File "/home/rrj/.local/lib/python3.5/site-packages/Xlib/support/unix_connect.py", line 61, in get_display
    raise error.DisplayNameError(display)
Xlib.error.DisplayNameError: Bad display name ""

[1] This issue

Evidlo commented 6 years ago

Fixed

yogeshwar607 commented 5 years ago

How its solved ? i am getting it for pynput

Evidlo commented 5 years ago

It was fixed by only importing pynput when you use the type command.

shubhamdangare commented 5 years ago

m getting same issue on ec2 instance

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 119, in get_socket s = _get_unix_socket(address) File "/usr/local/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 98, in _get_unix_socket s.connect(address) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 123, in get_socket s = _get_tcp_socket(host, dno) File "/usr/local/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 93, in _get_tcp_socket s.connect((host, 6000 + dno)) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "./demo.py", line 10, in import pynput File "/usr/local/lib/python3.7/site-packages/pynput/init.py", line 40, in from . import keyboard File "/usr/local/lib/python3.7/site-packages/pynput/keyboard/init.py", line 49, in from ._xorg import KeyCode, Key, Controller, Listener File "/usr/local/lib/python3.7/site-packages/pynput/keyboard/_xorg.py", line 39, in from pynput._util.xorg import ( File "/usr/local/lib/python3.7/site-packages/pynput/_util/xorg.py", line 40, in _check() File "/usr/local/lib/python3.7/site-packages/pynput/_util/xorg.py", line 38, in _check display = Xlib.display.Display() File "/usr/local/lib/python3.7/site-packages/Xlib/display.py", line 89, in init self.display = _BaseDisplay(display) File "/usr/local/lib/python3.7/site-packages/Xlib/display.py", line 71, in init protocol_display.Display.init(self, *args, **keys) File "/usr/local/lib/python3.7/site-packages/Xlib/protocol/display.py", line 89, in init self.socket = connect.get_socket(name, protocol, host, displayno) File "/usr/local/lib/python3.7/site-packages/Xlib/support/connect.py", line 87, in get_socket return mod.get_socket(dname, protocol, host, dno) File "/usr/local/lib/python3.7/site-packages/Xlib/support/unix_connect.py", line 127, in get_socket raise error.DisplayConnectionError(dname, str(val)) Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 111] Connection refused

Evidlo commented 5 years ago

What command are you running?

shubhamdangare commented 5 years ago

I have just imported from pynput.keyboard import Key, Controller and ran that script

Evidlo commented 5 years ago

@shubhamdangare I mean when is passhole being invoked/imported?