1 #include <boost/filesystem/operations.hpp>
2 #include <boost/python.hpp>
4 using namespace boost::filesystem;
8 #include <QApplication>
10 #include "qui/MussaWindow.hpp"
11 #include "alg/parse_options.hpp"
12 #include "mussa_exceptions.hpp"
14 int main(int argc, char **argv)
18 // if we're under unix and don't have a display, see if we can still run
20 opts.useGUI = getenv("DISPLAY") != 0;
23 QApplication app(argc, argv, opts.useGUI);
24 Q_INIT_RESOURCE(icons);
25 //PyImport_AppendInittab("mussa", initmussa);
28 initialize_mussa(opts, argc, argv);
30 if (opts.analysis == 0) {
35 if (opts.runAsPythonInterpeter) {
36 boost::python::object main_module((boost::python::handle<>(boost::python::borrowed(PyImport_AddModule("__main__")))));
37 boost::python::object main_namespace = main_module.attr("__dict__");
39 boost::python::handle<> ignored((PyRun_String(
40 //"from IPython.Shell import IPShellEmbed\n"
41 //"shell = IPShellEmbed(['mussa'], '')\n",
45 " print 'the square is %d' % (r)\n"
51 boost::python::object square = main_module.attr("square");
52 int result = boost::python::extract<int>(square(3));
53 std::cout << "C++ has " << result << std::endl;
54 PyRun_InteractiveLoop(stdin, "mussa");
55 } else if (opts.useGUI) {
56 MussaWindow win(opts.analysis);
61 } catch (mussa_error e) {
63 } catch (boost::filesystem::filesystem_error e) {
65 } catch (boost::python::error_already_set e) {
67 } catch (std::runtime_error e) {
70 qFatal("unrecognized exception");