Commit d07875d8 authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

console.py: pylint clean

parent d463d100
Loading
Loading
Loading
Loading
+16 −9
Original line number Original line Diff line number Diff line
@@ -7,26 +7,24 @@ CloudControl Console related commands


from cccli.command import TqlCommand
from cccli.command import TqlCommand
from cccli.exception import *
from cccli.exception import *
from cccli.printer import Printer, color
from sjrpc.core.exceptions import *
from sjrpc.core.exceptions import *
from sjrpc.core.protocols import TunnelProtocol
import fcntl
import fcntl
import os
import os
import signal
import signal
import struct
import struct
import sys
import sys
import termios
import termios
import time
import tty
import tty


class FakeTtySocket(object):
class FakeTtySocket(object):

    '''
    '''Give a tty a socket interface
    Give a tty a socket interface


    This object cannot handle sigwinch directly because close
    This object cannot handle sigwinch directly because close
    can be called by remote RPC and by the way, called outside the main
    can be called by remote RPC and by the way, called outside the main
    thread and fail.
    thread and fail.
    '''
    '''

    def __init__(self):
    def __init__(self):
        if not os.isatty(0):
        if not os.isatty(0):
            raise cmdError("stdin is not tty")
            raise cmdError("stdin is not tty")
@@ -37,7 +35,9 @@ class FakeTtySocket(object):
        # set tty in raw mode
        # set tty in raw mode
        tty.setraw(0)
        tty.setraw(0)


    def recv(self, size):
    @staticmethod
    def recv(size):
        '''Emulate socket recv'''
        data =  os.read(0, size)
        data =  os.read(0, size)
        if "\x1d" in data:
        if "\x1d" in data:
            # return empty sting to simulate an EOF instead of raise
            # return empty sting to simulate an EOF instead of raise
@@ -45,19 +45,26 @@ class FakeTtySocket(object):
            return ""
            return ""
        return data
        return data


    def send(self, data):
    @staticmethod
    def send(data):
        '''Emulate socket send'''
        return os.write(0, data)
        return os.write(0, data)


    def fileno(self):
    @staticmethod
    def fileno():
        '''Emulate socket fileno'''
        return 0
        return 0


    def setblocking(self, blocking):
    @staticmethod
    def setblocking(*args):
        '''Emulate socket send'''
        # Do NOT be in non-blocking mode : non-blocking mode
        # Do NOT be in non-blocking mode : non-blocking mode
        # causes rshell to get EAGAIN errors when having to
        # causes rshell to get EAGAIN errors when having to
        # output loads of data, causing the TTY to break.
        # output loads of data, causing the TTY to break.
        return
        return


    def close(self):
    def close(self):
        '''Emulate socket close'''
        # reset tty original state
        # reset tty original state
        termios.tcsetattr(0, termios.TCSADRAIN, self._tc_attr)
        termios.tcsetattr(0, termios.TCSADRAIN, self._tc_attr)