Best Python code snippet using lemoncheesecake
term.py
Source:term.py  
...33            return sizex, sizey34    except:35        pass36def _size_linux(file=None):37    def ioctl_GWINSZ(fd):38        try:39            import fcntl40            import termios41            cr = struct.unpack(42                'hh',43                fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))44            return cr45        except:46            pass47    if file:48        cr = ioctl_GWINSZ(file.fileno())49    else:50        cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)51        if not cr:52            try:53                fd = os.open(os.ctermid(), os.O_RDONLY)54                cr = ioctl_GWINSZ(fd)55                os.close(fd)56            except:57                pass58    if not cr:59        try:60            cr = (os.environ['LINES'], os.environ['COLUMNS'])61        except:62            return None63    return int(cr[1]), int(cr[0])64def colorize(s, color):65    if s is None:66        return ""67    if type(s) not in (str, unicode):68        s = str(s)...terminal.py
Source:terminal.py  
...23    <http://stackoverflow.com/a/566752>24    """25    import os26    env = os.environ27    def ioctl_GWINSZ(fd):28        try:29            import fcntl, termios, struct, os30            cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,31        '1234'))32        except:33            return34        return cr35    cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)36    if not cr:37        try:38            fd = os.open(os.ctermid(), os.O_RDONLY)39            cr = ioctl_GWINSZ(fd)40            os.close(fd)41        except:42            pass43    if not cr:44        cr = (env.get('LINES', 25), env.get('COLUMNS', 80))45    return int(cr[1]), int(cr[0])46def clear_terminal():47    """ clear_terminal: Clears the terminal's window.48    """49    import sys...console.py
Source:console.py  
...11    BOLD = '\033[1m'12    UNDERLINE = '\033[4m'13def getTerminalSize():14    env = os.environ15    def ioctl_GWINSZ(fd):16        try:17            import fcntl, termios, struct, os18            cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ,19        '1234'))20        except:21            return22        return cr23    cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)24    if not cr:25        try:26            fd = os.open(os.ctermid(), os.O_RDONLY)27            cr = ioctl_GWINSZ(fd)28            os.close(fd)29        except:30            pass31    if not cr:32        cr = (env.get('LINES', 25), env.get('COLUMNS', 80))...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
