This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch v1-10-stable
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v1-10-stable by this push:
new 4c3b31a Fix running "upgrade_check" command in a PTY. (#14977)
4c3b31a is described below
commit 4c3b31a1983e13f1fac8c5292c97b7a2f6518607
Author: Kosteev Eugene <[email protected]>
AuthorDate: Fri Mar 26 14:30:15 2021 +0200
Fix running "upgrade_check" command in a PTY. (#14977)
In case of running in a PTY, the get_terminal_size() call can return (0, 0).
As a consequence "upgrade_check" command fails during formatting of output.
```
File "/usr/local/lib/airflow/airflow/upgrade/formatters.py", line 109, in
on_next_rule_status
print(status_line_fmt.format(rule_status.rule.title, status))
ValueError: Sign not allowed in string format specifier
```
This change is to fallback in case of (0, 0) and prevent command from
failing.
---
airflow/utils/cli.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/airflow/utils/cli.py b/airflow/utils/cli.py
index 578f07c..826dfa4 100644
--- a/airflow/utils/cli.py
+++ b/airflow/utils/cli.py
@@ -158,7 +158,8 @@ def should_use_colors(args):
def get_terminal_size(fallback=(80, 20)):
"""Return a tuple of (terminal height, terminal width)."""
try:
- return struct.unpack('hhhh', ioctl(sys.__stdout__, TIOCGWINSZ, '\000'
* 8))[0:2]
+ width, height = struct.unpack('hhhh', ioctl(sys.__stdout__,
TIOCGWINSZ, '\000' * 8))[0:2]
+ return width or fallback[0], height or fallback[1]
except IOError:
# when the output stream or init descriptor is not a tty, such
# as when when stdout is piped to another program