mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Restore original standard streams for device monitor // Issue #3939
This commit is contained in:
@ -130,7 +130,6 @@ def device_monitor_cmd(**options):
|
||||
"--exit-char can not be the same as --menu-char"
|
||||
)
|
||||
|
||||
print(options)
|
||||
start_terminal(options)
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
|
||||
import click
|
||||
@ -60,8 +61,17 @@ def start_terminal(options):
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
term.join()
|
||||
|
||||
# cleanup
|
||||
term.console.cleanup()
|
||||
|
||||
# restore original standard streams
|
||||
sys.stdin = sys.__stdin__
|
||||
sys.stdout = sys.__stdout__
|
||||
sys.stderr = sys.__stderr__
|
||||
|
||||
term.close()
|
||||
|
||||
if term.pio_unexpected_exception:
|
||||
click.secho(
|
||||
"Disconnected (%s)" % term.pio_unexpected_exception,
|
||||
@ -70,6 +80,7 @@ def start_terminal(options):
|
||||
)
|
||||
if not options["no_reconnect"]:
|
||||
raise UserSideException(term.pio_unexpected_exception)
|
||||
|
||||
return
|
||||
except UserSideException as exc:
|
||||
if not is_port_valid:
|
||||
|
Reference in New Issue
Block a user