Skip to content
Snippets Groups Projects
Commit 2b52357b authored by Valerio Mariani's avatar Valerio Mariani
Browse files

Added stop script command

For debugging purposes
parent f4caabf1
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ void export_Gosty() ...@@ -79,6 +79,7 @@ void export_Gosty()
.def("Instance", &GostyApp::Instance, .def("Instance", &GostyApp::Instance,
return_value_policy<reference_existing_object>()).staticmethod("Instance") return_value_policy<reference_existing_object>()).staticmethod("Instance")
.def("SetAppTitle", &GostyApp::SetAppTitle) .def("SetAppTitle", &GostyApp::SetAppTitle)
.def("StopScript",&GostyApp::StopScript)
.def("GetPyShell", &GostyApp::GetPyShell, .def("GetPyShell", &GostyApp::GetPyShell,
return_value_policy<reference_existing_object>()) return_value_policy<reference_existing_object>())
.add_property("py_shell", make_function(&GostyApp::GetPyShell, .add_property("py_shell", make_function(&GostyApp::GetPyShell,
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <ost/gui/tools/tool_options_win.hh> #include <ost/gui/tools/tool_options_win.hh>
#include <ost/gui/perspective.hh> #include <ost/gui/perspective.hh>
#include <ost/gui/main_area.hh> #include <ost/gui/main_area.hh>
#include <ost/gui/python_shell/python_interpreter.hh>
#include <QApplication> #include <QApplication>
...@@ -118,6 +119,13 @@ PythonShell* GostyApp::GetPyShell() ...@@ -118,6 +119,13 @@ PythonShell* GostyApp::GetPyShell()
return py_shell_; return py_shell_;
} }
void GostyApp::StopScript()
{
PythonInterpreter::Instance().StopScript();
}
GLWin* GostyApp::GetGLWin() GLWin* GostyApp::GetGLWin()
{ {
if (gl_win_==NULL) { if (gl_win_==NULL) {
......
...@@ -105,6 +105,11 @@ public: ...@@ -105,6 +105,11 @@ public:
/// All subsequent calls will return the same MessageWidget instance. /// All subsequent calls will return the same MessageWidget instance.
MessageWidget* GetMessageWidget(); MessageWidget* GetMessageWidget();
/// \brief stop script execution
///
/// Stops the execution of the script.
void StopScript();
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
/// \brief create new DataViewer /// \brief create new DataViewer
/// ///
......
...@@ -83,6 +83,10 @@ void PythonInterpreter::Start() ...@@ -83,6 +83,10 @@ void PythonInterpreter::Start()
emit WakeWorker(); emit WakeWorker();
} }
void PythonInterpreter::StopScript()
{
PyErr_SetInterrupt();
}
unsigned int PythonInterpreter::RunScript(const QString& fname) unsigned int PythonInterpreter::RunScript(const QString& fname)
......
...@@ -82,6 +82,9 @@ public: ...@@ -82,6 +82,9 @@ public:
/// ///
/// \sa Stop /// \sa Stop
void Start(); void Start();
/// \brief stop script execution
void StopScript();
public slots: public slots:
......
...@@ -138,6 +138,10 @@ def _SplitIDSel(name): ...@@ -138,6 +138,10 @@ def _SplitIDSel(name):
return name[:pos], name[pos+1:-1] return name[:pos], name[pos+1:-1]
return name, '' return name, ''
def stop():
gui.GostyApp.Instance().StopScript()
loading_list=[] loading_list=[]
script_argv=[] script_argv=[]
images=[] images=[]
......
...@@ -10,6 +10,9 @@ def show_help(option, opt, value, parser): ...@@ -10,6 +10,9 @@ def show_help(option, opt, value, parser):
def interactive_flag(option, opt, value, parser): def interactive_flag(option, opt, value, parser):
pass pass
def stop():
sys.exit(0)
usage = 'usage: ost [ost options] [script to execute] [script parameters]' usage = 'usage: ost [ost options] [script to execute] [script parameters]'
class OstOptionParser(optparse.OptionParser): class OstOptionParser(optparse.OptionParser):
def __init__(self, **kwargs): def __init__(self, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment