DRYer: Get hostname

This commit is contained in:
pagedown
2022-11-26 15:28:32 +08:00
parent 63a08dc6cc
commit 6a1b456bac
4 changed files with 20 additions and 15 deletions

View File

@@ -4,12 +4,13 @@
import os
import re
import signal
import socket
import subprocess
import sys
from typing import Callable, cast
from urllib.parse import quote_from_bytes
from kitty.utils import get_hostname
def write_hyperlink(write: Callable[[bytes], None], url: bytes, line: bytes, frag: bytes = b'') -> None:
text = b'\033]8;;' + url
@@ -76,7 +77,7 @@ def main() -> None:
num_pat = re.compile(br'^(\d+)([:-])')
in_result: bytes = b''
hostname = socket.gethostname().encode('utf-8')
hostname = get_hostname().encode('utf-8')
try:
for line in p.stdout: