예제 #1
0
파일: prcclient.py 프로젝트: 0x1001/PRC
    def _receiveConsoleOutput(self):
        """
            This function receives and prints console output

            Input:
            Nothing

            Returns:
            Nothing
        """
        import sys
        from comm import protocol, sendAndReceive, CommClientException

        while True:
            if self._exit.is_set(): break

            try:
                frame = sendAndReceive(self._ip,self._port,protocol.frame(prc.PRC_OUTPUT,self._session_id))
            except CommClientException as error:
                self._exit.set()
                raise PRCClientException("Connection problem: " + str(error))

            cmd,data = protocol.analyze(frame)
            if cmd == prc.PRC_OUTPUT:
                sys.stdout.write(data)
            elif cmd == prc.PRC_CONFIRM:
                self._synch.release()
            elif cmd == prc.PRC_EXIT:
                self._synch.release()
                self._exit.set()
예제 #2
0
파일: prcclient.py 프로젝트: 0x1001/PRC
    def _start_session(self):
        """
            This function starts PRC session

            Input:
            Nothing

            Returns:
            Nothing
        """
        from comm import protocol, sendAndReceive, CommClientException

        try:
            sendAndReceive(self._ip,self._port,protocol.frame(prc.PRC_NEW_SESSION,self._session_id))
        except CommClientException as error:
            self._exit.set()
            raise PRCClientException("Connection problem: " + str(error))
예제 #3
0
파일: prcclient.py 프로젝트: 0x1001/PRC
    def _prompt(self):
        """
            This function gets prompt from server

            Input:
            Nothing

            Returns:
            prompt
        """
        from comm import protocol, sendAndReceive, CommClientException

        try:
            frame = sendAndReceive(self._ip,self._port,protocol.frame(prc.PRC_PROMPT,self._session_id))
        except CommClientException as error:
            self._exit.set()
            raise PRCClientException("Connection problem: " + str(error))

        cmd,prompt = protocol.analyze(frame)

        self._synch.acquire()

        return prompt
예제 #4
0
파일: prcclient.py 프로젝트: 0x1001/PRC
    def _sendConsoleInput(self,data):
        """
            This function sends command.
            Blocking funnction.

            Input:
            data        - Input python command

            Returns:
            Nothing
        """
        from comm import protocol, sendAndReceive, CommClientException

        try:
            frame = sendAndReceive(self._ip,self._port,protocol.frame(prc.PRC_CODE,(self._session_id,data)))
        except CommClientException as error:
            self._exit.set()
            raise PRCClientException("Connection problem: " + str(error))

        self._synch.acquire()

        cmd,data = protocol.analyze(frame)
        if cmd == prc.PRC_EXIT: raise SystemExit
예제 #5
0
파일: client.py 프로젝트: 0x1001/Sandbox
from comm import sendAndReceive

ip = "127.0.0.1"
port = 59899
data = "".join(["a"]*(4096*1000+55))

sendAndReceive(ip,port,data)