def server_start(port="5900", password="******"): if os.name == "nt": # Convert the password to a 3DES VNC hash password = vnc_hash.get_vnc_hash(password) # Launch the VNC Server command = ["vncserver.exe", "PortNumber=" + port, "SecurityTypes=VncAuth", "Password="******"posix": # Generate the password file using x11vncserver server_password(password) command = ["./x11vncserver_" + platform.machine(), "-rfbauth", "/tmp/connect.vnc"] return Popen(command, stdout=PIPE, stderr=PIPE, startupinfo=startupinfo)
def client_connect(host="localhost", port="5900", password="******"): if os.name == "nt": # Convert the password to a 3DES VNC hash password = vnc_hash.get_vnc_hash(password) print password # Generate the connection profile profile = "[Connection]\n\ Host=" + host + ":" + port + "\n\ Password="******"\n\ [Options]\n\ UseLocalCursor=1\n\ UseDesktopResize=1\n\ FullScreen=0\n\ FullColour=0\n\ LowColourLevel=2\n\ PreferredEncoding=hextile\n\ AutoSelect=1\n\ Shared=0\n\ SendPtrEvents=1\n\ SendKeyEvents=1\n\ SendCutText=1\n\ AcceptCutText=1\n\ DisableWinKeys=1\n\ Emulate3=0\n\ PointerEventInterval=0\n\ MenuKey=F8\n\ AutoReconnect=1" config = open("connect.vnc", "w") config.write(profile) # Connect to the remote VNC Server through the SSH Tunnel using the connection profile command = ["vncviewer.exe", "-config", "connect.vnc"] elif os.name == "posix": # Generate the password file using x11vncserver server_password(password) # Connect to the remote VNC server using x11vncserver using the generated vnc password command = ["./xvnc4viewer_" + platform.machine(), "-PasswordFile=/tmp/connect.vnc", "localhost::" + port] return Popen(command, stdout=PIPE, stderr=PIPE, startupinfo=startupinfo)