From 0c861201b3aaa073e4e42b036ab41d1f5f5817d1 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Thu, 9 Apr 2015 21:44:54 +0530 Subject: [PATCH] Save streams as Python Script: The generated script now checks for Ctrl-C while waiting for transmit to stop, so that cleanup can be done --- common/pythonfileformat.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/pythonfileformat.cpp b/common/pythonfileformat.cpp index 73f847f..a4aacfb 100644 --- a/common/pythonfileformat.cpp +++ b/common/pythonfileformat.cpp @@ -302,9 +302,14 @@ void PythonFileFormat::writeEpilogue(QTextStream &out) out << " # wait for transmit to finish\n"; out << " log.info('waiting for transmit to finish ...')\n"; out << " while True:\n"; - out << " time.sleep(5)\n"; - out << " tx_stats = drone.getStats(tx_port)\n"; - out << " if tx_stats.port_stats[0].state.is_transmit_on == False:\n"; + out << " try:\n"; + out << " time.sleep(5)\n"; + out << " tx_stats = drone.getStats(tx_port)\n"; + out << " if tx_stats.port_stats[0].state.is_transmit_on" + " == False:\n"; + out << " break\n"; + out << " except KeyboardInterrupt:\n"; + out << " log.info('transmit interrupted by user')\n"; out << " break\n"; out << "\n"; out << " # stop transmit and capture\n";