Mercurial > libervia-backend
comparison sat_frontends/jp/base.py @ 3547:1ac5570fa998
jp: fix background guessing when stdin is redirected
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 04 Jun 2021 15:23:24 +0200 |
parents | 509f7a1c67dc |
children | 53fec6309fa3 |
comparison
equal
deleted
inserted
replaced
3546:185601bc0cd3 | 3547:1ac5570fa998 |
---|---|
118 def get_config(self, name, section='cli', default=None): | 118 def get_config(self, name, section='cli', default=None): |
119 """Retrieve a setting value from sat.conf""" | 119 """Retrieve a setting value from sat.conf""" |
120 return config.getConfig(self.sat_conf, section, name, default=default) | 120 return config.getConfig(self.sat_conf, section, name, default=default) |
121 | 121 |
122 def guess_background(self): | 122 def guess_background(self): |
123 if not sys.stdout.isatty(): | 123 if not sys.stdin.isatty() or not sys.stdout.isatty(): |
124 return 'dark' | 124 return 'dark' |
125 stdin_fd = sys.stdin.fileno() | 125 stdin_fd = sys.stdin.fileno() |
126 old_settings = termios.tcgetattr(stdin_fd) | 126 old_settings = termios.tcgetattr(stdin_fd) |
127 try: | 127 try: |
128 tty.setraw(sys.stdin.fileno()) | 128 tty.setraw(sys.stdin.fileno()) |
153 if background == 'auto': | 153 if background == 'auto': |
154 background = self.guess_background() | 154 background = self.guess_background() |
155 if background not in ('dark', 'light'): | 155 if background not in ('dark', 'light'): |
156 raise exceptions.ConfigError(_( | 156 raise exceptions.ConfigError(_( |
157 f'Invalid value set for "background" ({background!r}), please check ' | 157 f'Invalid value set for "background" ({background!r}), please check ' |
158 f'your settings in sat.conf')) | 158 f'your settings in libervia.conf')) |
159 if background == 'light': | 159 if background == 'light': |
160 C.A_HEADER = A.FG_MAGENTA | 160 C.A_HEADER = A.FG_MAGENTA |
161 C.A_SUBHEADER = A.BOLD + A.FG_RED | 161 C.A_SUBHEADER = A.BOLD + A.FG_RED |
162 C.A_LEVEL_COLORS = (C.A_HEADER, A.BOLD + A.FG_BLUE, A.FG_MAGENTA, A.FG_CYAN) | 162 C.A_LEVEL_COLORS = (C.A_HEADER, A.BOLD + A.FG_BLUE, A.FG_MAGENTA, A.FG_CYAN) |
163 C.A_SUCCESS = A.FG_GREEN | 163 C.A_SUCCESS = A.FG_GREEN |