|
|
@ -2,7 +2,9 @@
|
|
|
|
from __future__ import annotations
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
|
|
import errno
|
|
|
|
import errno
|
|
|
|
|
|
|
|
# noinspection PyCompatibility
|
|
|
|
import fcntl
|
|
|
|
import fcntl
|
|
|
|
|
|
|
|
import importlib.util
|
|
|
|
import inspect
|
|
|
|
import inspect
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import pkgutil
|
|
|
|
import pkgutil
|
|
|
@ -20,6 +22,7 @@ import shlex
|
|
|
|
import typing as t
|
|
|
|
import typing as t
|
|
|
|
|
|
|
|
|
|
|
|
from struct import unpack, pack
|
|
|
|
from struct import unpack, pack
|
|
|
|
|
|
|
|
# noinspection PyCompatibility
|
|
|
|
from termios import TIOCGWINSZ
|
|
|
|
from termios import TIOCGWINSZ
|
|
|
|
|
|
|
|
|
|
|
|
from .encoding import (
|
|
|
|
from .encoding import (
|
|
|
@ -587,9 +590,6 @@ class Display:
|
|
|
|
message = message.replace(self.clear, color)
|
|
|
|
message = message.replace(self.clear, color)
|
|
|
|
message = '%s%s%s' % (color, message, self.clear)
|
|
|
|
message = '%s%s%s' % (color, message, self.clear)
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[0] == 2:
|
|
|
|
|
|
|
|
message = to_bytes(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(message, file=fd)
|
|
|
|
print(message, file=fd)
|
|
|
|
fd.flush()
|
|
|
|
fd.flush()
|
|
|
|
|
|
|
|
|
|
|
@ -768,23 +768,12 @@ def load_module(path, name): # type: (str, str) -> None
|
|
|
|
if name in sys.modules:
|
|
|
|
if name in sys.modules:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info >= (3, 4):
|
|
|
|
|
|
|
|
import importlib.util
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spec = importlib.util.spec_from_file_location(name, path)
|
|
|
|
spec = importlib.util.spec_from_file_location(name, path)
|
|
|
|
module = importlib.util.module_from_spec(spec)
|
|
|
|
module = importlib.util.module_from_spec(spec)
|
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
spec.loader.exec_module(module)
|
|
|
|
spec.loader.exec_module(module)
|
|
|
|
|
|
|
|
|
|
|
|
sys.modules[name] = module
|
|
|
|
sys.modules[name] = module
|
|
|
|
else:
|
|
|
|
|
|
|
|
# noinspection PyDeprecation
|
|
|
|
|
|
|
|
import imp # pylint: disable=deprecated-module
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# load_source (and thus load_module) require a file opened with `open` in text mode
|
|
|
|
|
|
|
|
with open(to_bytes(path)) as module_file:
|
|
|
|
|
|
|
|
# noinspection PyDeprecation
|
|
|
|
|
|
|
|
imp.load_module(name, module_file, path, ('.py', 'r', imp.PY_SOURCE))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sanitize_host_name(name):
|
|
|
|
def sanitize_host_name(name):
|
|
|
|