ssh kitten: Suppress error prints about invalid items in kitty.conf
Fixes #4985
This commit is contained in:
parent
92c3af6a92
commit
4a7125ec92
@ -39,7 +39,7 @@ from kitty.shm import SharedMemory
|
||||
from kitty.types import run_once
|
||||
from kitty.utils import (
|
||||
SSHConnectionData, expandvars, resolve_abs_or_config_path,
|
||||
set_echo as turn_off_echo
|
||||
set_echo as turn_off_echo, suppress_error_logging
|
||||
)
|
||||
|
||||
from .completion import complete, ssh_options
|
||||
@ -152,7 +152,8 @@ def serialize_env(literal_env: Dict[str, str], env: Dict[str, str], base_env: Di
|
||||
@run_once
|
||||
def kitty_opts() -> Options:
|
||||
from kitty.cli import create_default_opts
|
||||
return create_default_opts()
|
||||
with suppress_error_logging():
|
||||
return create_default_opts()
|
||||
|
||||
|
||||
def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: str = 'gz', literal_env: Dict[str, str] = {}) -> bytes:
|
||||
|
||||
@ -13,8 +13,8 @@ from contextlib import contextmanager, suppress
|
||||
from functools import lru_cache
|
||||
from time import monotonic
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, List, Mapping,
|
||||
Match, NamedTuple, Optional, Pattern, Tuple, Union, cast
|
||||
TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, Iterator, List,
|
||||
Mapping, Match, NamedTuple, Optional, Pattern, Tuple, Union, cast
|
||||
)
|
||||
|
||||
from .constants import (
|
||||
@ -122,6 +122,19 @@ def log_error(*a: Any, **k: str) -> None:
|
||||
output(msg)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def suppress_error_logging() -> Iterator[None]:
|
||||
before = getattr(log_error, 'redirect', suppress_error_logging)
|
||||
setattr(log_error, 'redirect', lambda *a: None)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if before is suppress_error_logging:
|
||||
delattr(log_error, 'redirect')
|
||||
else:
|
||||
setattr(log_error, 'redirect', before)
|
||||
|
||||
|
||||
def ceil_int(x: float) -> int:
|
||||
return int(math.ceil(x))
|
||||
|
||||
@ -536,7 +549,7 @@ def set_echo(fd: int = -1, on: bool = False) -> Tuple[int, List[Union[int, List[
|
||||
|
||||
|
||||
@contextmanager
|
||||
def no_echo(fd: int = -1) -> Generator[None, None, None]:
|
||||
def no_echo(fd: int = -1) -> Iterator[None]:
|
||||
import termios
|
||||
fd, old = set_echo(fd)
|
||||
try:
|
||||
@ -954,7 +967,7 @@ def path_from_osc7_url(url: str) -> str:
|
||||
if url.startswith('kitty-shell-cwd://'):
|
||||
return '/' + url.split('/', 3)[-1]
|
||||
if url.startswith('file://'):
|
||||
from urllib.parse import urlparse, unquote
|
||||
from urllib.parse import unquote, urlparse
|
||||
return unquote(urlparse(url).path)
|
||||
return ''
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user