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.types import run_once
|
||||||
from kitty.utils import (
|
from kitty.utils import (
|
||||||
SSHConnectionData, expandvars, resolve_abs_or_config_path,
|
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
|
from .completion import complete, ssh_options
|
||||||
@ -152,6 +152,7 @@ def serialize_env(literal_env: Dict[str, str], env: Dict[str, str], base_env: Di
|
|||||||
@run_once
|
@run_once
|
||||||
def kitty_opts() -> Options:
|
def kitty_opts() -> Options:
|
||||||
from kitty.cli import create_default_opts
|
from kitty.cli import create_default_opts
|
||||||
|
with suppress_error_logging():
|
||||||
return create_default_opts()
|
return create_default_opts()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,8 +13,8 @@ from contextlib import contextmanager, suppress
|
|||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, List, Mapping,
|
TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, Iterator, List,
|
||||||
Match, NamedTuple, Optional, Pattern, Tuple, Union, cast
|
Mapping, Match, NamedTuple, Optional, Pattern, Tuple, Union, cast
|
||||||
)
|
)
|
||||||
|
|
||||||
from .constants import (
|
from .constants import (
|
||||||
@ -122,6 +122,19 @@ def log_error(*a: Any, **k: str) -> None:
|
|||||||
output(msg)
|
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:
|
def ceil_int(x: float) -> int:
|
||||||
return int(math.ceil(x))
|
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
|
@contextmanager
|
||||||
def no_echo(fd: int = -1) -> Generator[None, None, None]:
|
def no_echo(fd: int = -1) -> Iterator[None]:
|
||||||
import termios
|
import termios
|
||||||
fd, old = set_echo(fd)
|
fd, old = set_echo(fd)
|
||||||
try:
|
try:
|
||||||
@ -954,7 +967,7 @@ def path_from_osc7_url(url: str) -> str:
|
|||||||
if url.startswith('kitty-shell-cwd://'):
|
if url.startswith('kitty-shell-cwd://'):
|
||||||
return '/' + url.split('/', 3)[-1]
|
return '/' + url.split('/', 3)[-1]
|
||||||
if url.startswith('file://'):
|
if url.startswith('file://'):
|
||||||
from urllib.parse import urlparse, unquote
|
from urllib.parse import unquote, urlparse
|
||||||
return unquote(urlparse(url).path)
|
return unquote(urlparse(url).path)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user