mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Merge pull request #261 from pre-commit/no_tput_stderr
Supress stderr when TERM is unset
This commit is contained in:
commit
3d90b094fc
1 changed files with 4 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -9,9 +10,11 @@ from pre_commit import five
|
||||||
|
|
||||||
# TODO: smell: import side-effects
|
# TODO: smell: import side-effects
|
||||||
try:
|
try:
|
||||||
|
if not os.environ.get('TERM'):
|
||||||
|
raise OSError('Cannot determine width without TERM')
|
||||||
COLS = int(
|
COLS = int(
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
['tput', 'cols'], stdout=subprocess.PIPE,
|
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||||
).communicate()[0] or
|
).communicate()[0] or
|
||||||
# Default in the case of no terminal
|
# Default in the case of no terminal
|
||||||
80
|
80
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue