ponty / PyVirtualDisplay

Python wrapper for Xvfb, Xephyr and Xvnc
BSD 2-Clause "Simplified" License
709 stars 78 forks source link

Add VNC -rfbauth option #19

Closed ottothecow closed 5 years ago

ottothecow commented 7 years ago

Due to a bug (here and here) with selenium/chromedriver/chrome not correctly sending keystrokes when running tightvnc server, I had to switch to using vnc4server if I wanted to peek at what was happening while running PyVirtualDisplay.

I believe vnc4server requires a password (at least on my systems it does) and whatever password file it defaults to when called by PyVirtualDisplay was not accessible.

So on import, I redifined XvncDisplay._cmd to specify a password file location (set by running vncpasswd):

from pyvirtualdisplay.xvnc import XvncDisplay
@property
def _cmd(self):
        cmd = ['Xvnc',
               '-depth', str(self.color_depth),
               '-geometry', '%dx%d' % (self.size[0], self.size[1]),
               '-rfbport', str(self.rfbport), '-rfbauth', '/etc/vncpasswd',
               self.new_display_var,
               ]
        return cmd
XvncDisplay._cmd =_cmd

I'd suggest adding this as an option available when creating a Display (or providing a more universal option to add any additional arguments when calling Xvnc).

The same syntax applies to tightvncserver as well as vnc4server (and I believe RealVNC and x11vnc as well, since they all default themselves to the Xvnc executable on install).

ponty commented 5 years ago

Implementation in #36