forked from platformio/platformio-core
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"
|
"--exit-char can not be the same as --menu-char"
|
||||||
)
|
)
|
||||||
|
|
||||||
print(options)
|
|
||||||
start_terminal(options)
|
start_terminal(options)
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import signal
|
import signal
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@ -60,8 +61,17 @@ def start_terminal(options):
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
term.join()
|
term.join()
|
||||||
|
|
||||||
|
# cleanup
|
||||||
term.console.cleanup()
|
term.console.cleanup()
|
||||||
|
|
||||||
|
# restore original standard streams
|
||||||
|
sys.stdin = sys.__stdin__
|
||||||
|
sys.stdout = sys.__stdout__
|
||||||
|
sys.stderr = sys.__stderr__
|
||||||
|
|
||||||
term.close()
|
term.close()
|
||||||
|
|
||||||
if term.pio_unexpected_exception:
|
if term.pio_unexpected_exception:
|
||||||
click.secho(
|
click.secho(
|
||||||
"Disconnected (%s)" % term.pio_unexpected_exception,
|
"Disconnected (%s)" % term.pio_unexpected_exception,
|
||||||
@ -70,6 +80,7 @@ def start_terminal(options):
|
|||||||
)
|
)
|
||||||
if not options["no_reconnect"]:
|
if not options["no_reconnect"]:
|
||||||
raise UserSideException(term.pio_unexpected_exception)
|
raise UserSideException(term.pio_unexpected_exception)
|
||||||
|
|
||||||
return
|
return
|
||||||
except UserSideException as exc:
|
except UserSideException as exc:
|
||||||
if not is_port_valid:
|
if not is_port_valid:
|
||||||
|
Reference in New Issue
Block a user