37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#!/usr/bin/env python3.5
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Did you just say "a graphic module" ? Is this real ?
|
|
"""
|
|
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
from Common.socketCommands import sendData, recvData
|
|
from Server.errorHandler import serverSendErrHandler, serverRecvErrHandler
|
|
from .CommandException import CommandException
|
|
|
|
|
|
__authors__ = "HorlogeSkynet"
|
|
__copyright__ = "Copyright 2017, ACMS"
|
|
__license__ = "GPLv3"
|
|
__status__ = "Prototype"
|
|
__date__ = "25/04/2017"
|
|
|
|
|
|
def startxController(sock, index):
|
|
if not os.path.exists('VNC/bin/VNCServer'):
|
|
raise CommandException('VNC module is not available on the server.')
|
|
|
|
p = subprocess.Popen(['./VNC/bin/VNCServer', str(index)], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
|
sendData(sock, 'VNCSERVER_RUNNING:' + str(5900 + index), serverSendErrHandler, sock)
|
|
|
|
# We check if the VNC client has correctly started
|
|
if recvData(sock, serverRecvErrHandler, sock) == 'VNCCLIENT_RUNNING':
|
|
# ... now let's wait for the client cue to stop the VNC server
|
|
recvData(sock, serverRecvErrHandler, sock)
|
|
|
|
p.kill()
|