rows: Union[Optional[str], int] = os.environ.get('LINES', None)
cols: Union[Optional[str], int] = os.environ.get('COLUMNS', None)
+ if not rows or not cols:
+ try:
+ size = os.get_terminal_size()
+ rows = size.lines
+ cols = size.columns
+ except Exception:
+ rows = None
+ cols = None
+
if not rows or not cols:
logger.debug('Rows: %s, cols: %s, trying stty.', rows, cols)
try:
rows = None
cols = None
- if not rows or not cols:
- size = os.get_terminal_size()
- rows = size.lines
- cols = size.columns
-
if not rows or not cols:
raise Exception('Can\'t determine console size?!')
return RowsColumns(int(rows), int(cols))