mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
parent
07da8950c4
commit
2e65d6c02c
2 changed files with 10 additions and 10 deletions
|
@ -346,6 +346,8 @@ class APIClient(threading.Thread):
|
|||
raise APIConnectionError("No socket!")
|
||||
try:
|
||||
val = self._socket.recv(amount - len(ret))
|
||||
except AttributeError:
|
||||
raise APIConnectionError("Socket was closed")
|
||||
except socket.timeout:
|
||||
continue
|
||||
except socket.error as err:
|
||||
|
@ -453,8 +455,8 @@ def run_logs(config, address):
|
|||
time_ = datetime.now().time().strftime(u'[%H:%M:%S]')
|
||||
text = msg.message
|
||||
if msg.send_failed:
|
||||
text = color('white', '(Message not received because it was too big to fit in '
|
||||
'TCP buffer)')
|
||||
text = color('white', '(Message skipped because it was too big to fit in '
|
||||
'TCP buffer - This is only cosmetic)')
|
||||
safe_print(time_ + text)
|
||||
|
||||
has_connects = []
|
||||
|
|
|
@ -88,12 +88,14 @@ def run_external_command(func, *cmd, **kwargs):
|
|||
full_cmd = u' '.join(shlex_quote(x) for x in cmd)
|
||||
_LOGGER.info(u"Running: %s", full_cmd)
|
||||
|
||||
orig_stdout = sys.stdout
|
||||
sys.stdout = RedirectText(sys.stdout)
|
||||
orig_stderr = sys.stderr
|
||||
sys.stderr = RedirectText(sys.stderr)
|
||||
|
||||
capture_stdout = kwargs.get('capture_stdout', False)
|
||||
if capture_stdout:
|
||||
sys.stdout = io.BytesIO()
|
||||
cap_stdout = sys.stdout = io.BytesIO()
|
||||
|
||||
try:
|
||||
sys.argv = list(cmd)
|
||||
|
@ -110,13 +112,9 @@ def run_external_command(func, *cmd, **kwargs):
|
|||
sys.argv = orig_argv
|
||||
sys.exit = orig_exit
|
||||
|
||||
if isinstance(sys.stdout, RedirectText):
|
||||
sys.stdout = sys.__stdout__
|
||||
if isinstance(sys.stderr, RedirectText):
|
||||
sys.stderr = sys.__stderr__
|
||||
sys.stdout = orig_stdout
|
||||
sys.stderr = orig_stderr
|
||||
|
||||
if capture_stdout:
|
||||
# pylint: disable=lost-exception
|
||||
stdout = sys.stdout.getvalue()
|
||||
sys.stdout = sys.__stdout__
|
||||
return stdout
|
||||
return cap_stdout.getvalue()
|
||||
|
|
Loading…
Reference in a new issue