Commit 432285db authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

BF: os.get_terminal_width might error in non-interactive envs, use raw string

for regexp
parent 967aae3c
...@@ -701,8 +701,10 @@ class Progress(object): ...@@ -701,8 +701,10 @@ class Progress(object):
""" """
# os.get_terminal_size added in python # os.get_terminal_size added in python
# 3.3, so we try it but fall back to tput # 3.3, so we try it but fall back to tput
if hasattr(os, 'get_terminal_size'): try:
return os.get_terminal_size()[0] return os.get_terminal_size()[0]
except Exception:
pass
try: try:
result = sp.check_output(('tput', 'cols')) result = sp.check_output(('tput', 'cols'))
......
...@@ -156,4 +156,4 @@ def mock_input(*responses): ...@@ -156,4 +156,4 @@ def mock_input(*responses):
def strip_ansi_escape_sequences(text): def strip_ansi_escape_sequences(text):
"""Does what function name says it does. """ """Does what function name says it does. """
return re.sub('\x1b\[[0-9;]*m', '', text) return re.sub(r'\x1b\[[0-9;]*m', '', text)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment