mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
Use hostname normalizer in Python CLI
Summary: Apply hostname normalization to Python CLI Reviewed By: xavierd Differential Revision: D46539537 fbshipit-source-id: 9675eb9ad3769ba75764b5853712c4c27c90884f
This commit is contained in:
parent
f388db1255
commit
34b6dbfce6
@ -12,7 +12,6 @@ import platform
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
@ -23,6 +22,7 @@ from typing import Callable, cast, Dict, Generator, IO, List, Optional, Tuple
|
||||
from . import (
|
||||
debug as debug_mod,
|
||||
doctor as doctor_mod,
|
||||
hostname as hostname_mod,
|
||||
redirect as redirect_mod,
|
||||
stats as stats_mod,
|
||||
top as top_mod,
|
||||
@ -114,7 +114,7 @@ def print_diagnostic_info(
|
||||
) -> None:
|
||||
section_title("System info:", out)
|
||||
user = getpass.getuser()
|
||||
host = socket.gethostname()
|
||||
host = hostname_mod.get_normalized_hostname()
|
||||
header = (
|
||||
f"User : {user}\n"
|
||||
f"Hostname : {host}\n"
|
||||
|
@ -12,14 +12,13 @@ import json
|
||||
import logging
|
||||
import platform
|
||||
import random
|
||||
import socket
|
||||
import subprocess
|
||||
import time
|
||||
import types
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Set, Tuple, Type, Union
|
||||
|
||||
from . import version
|
||||
from . import hostname, version
|
||||
|
||||
|
||||
log: logging.Logger = logging.getLogger(__name__)
|
||||
@ -141,7 +140,7 @@ class TelemetryLogger(abc.ABC):
|
||||
log.warning(f"error determining username for telemetry logging: {ex}")
|
||||
self.user = ""
|
||||
try:
|
||||
self.hostname = socket.gethostname()
|
||||
self.hostname = hostname.get_normalized_hostname()
|
||||
except Exception as ex:
|
||||
log.warning(f"error determining hostname for telemetry logging: {ex}")
|
||||
self.hostname = ""
|
||||
|
@ -11,7 +11,6 @@ import collections
|
||||
import copy
|
||||
import datetime
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
from enum import Enum
|
||||
from textwrap import wrap
|
||||
@ -20,6 +19,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
||||
from facebook.eden.ttypes import AccessCounts
|
||||
|
||||
from . import cmd_util
|
||||
from .hostname import get_normalized_hostname
|
||||
from .util import format_cmd, format_mount
|
||||
|
||||
|
||||
@ -617,7 +617,7 @@ class Top:
|
||||
def render_top_bar(self, window: Window) -> None:
|
||||
width = window.get_width()
|
||||
TITLE = "eden top"
|
||||
hostname = socket.gethostname()[:width]
|
||||
hostname = get_normalized_hostname()[:width]
|
||||
date = datetime.datetime.now().strftime("%x %X")[:width]
|
||||
extra_space = width - len(TITLE + hostname + date)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user