Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when env doesn't have a DISPLAY #2

Closed
Hornswoggles opened this issue Jul 12, 2011 · 2 comments
Closed

KeyError when env doesn't have a DISPLAY #2

Hornswoggles opened this issue Jul 12, 2011 · 2 comments

Comments

@Hornswoggles
Copy link

xephyr=Display(visible=1, size=(320, 240)).start() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.6/dist-packages/pyvirtualdisplay/abstractdisplay.py", line 65, in start self.old_display_var = os.environ['DISPLAY'] File "/usr/lib/python2.6/UserDict.py", line 22, in __getitem__ raise KeyError(key) KeyError: 'DISPLAY'

Easily fixed by adding DISPLAY to the environment with
$: export DISPLAY=':0'

Could handle the exception with a message or needs some logic to handle if DISPLAY doesn't exist. How about:

-        self.old_display_var = os.environ['DISPLAY']
+         self.old_display_var = os.environ['DISPLAY'] if 'DISPLAY' in os.environ else ':0'
@ponty
Copy link
Owner

ponty commented Jul 13, 2011

Code is updated: ae5fb6f

I don't understand, why there is no DISPLAY variable.
What is your use case?

@Hornswoggles
Copy link
Author

A base ubuntu install without x-server doesn't have a DISPLAY var set. So after manually installing Xvfb, Xephyr and pyvirtualdisplay I encountered this Key Error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants