1 #include <boost/filesystem/operations.hpp>
3 #include <boost/python.hpp>
4 namespace py = boost::python;
7 using namespace boost::filesystem;
11 #include <QApplication>
13 #include "qui/MussaWindow.hpp"
14 #include "alg/parse_options.hpp"
15 #include "mussa_exceptions.hpp"
17 int main(int argc, char **argv)
21 // if we're under unix and don't have a display, see if we can still run
23 opts.useGUI = getenv("DISPLAY") != 0;
24 if (opts.useGUI == false) {
25 std::clog << "DISPLAY not set, running in console mode only" << std::endl;
29 QApplication app(argc, argv, opts.useGUI);
30 Q_INIT_RESOURCE(icons);
32 initialize_mussa(opts, argc, argv);
34 if (opts.analysis == 0) {
40 if (opts.runAsPythonInterpeter) {
42 py::object main_module((py::handle<>(py::borrowed(PyImport_AddModule("__main__")))));
43 py::object main_namespace = main_module.attr("__dict__");
45 py::handle<> ignored((PyRun_String(
46 //"from IPython.Shell import IPShellEmbed\n"
47 //"shell = IPShellEmbed(['mussa'], '')\n",
51 " print 'the square is %d' % (r)\n"
57 py::object square = main_module.attr("square");
58 int result = py::extract<int>(square(3));
59 std::cout << "C++ has " << result << std::endl;
60 PyRun_InteractiveLoop(stdin, "mussa");
62 #endif /* USE_PYTHON */
64 MussaWindow win(opts.analysis);
69 } catch (mussa_error e) {
71 } catch (boost::filesystem::filesystem_error e) {
75 catch (py::error_already_set e) {
78 #endif /* USE_PYTHON */
79 catch (std::runtime_error e) {
82 qFatal("unrecognized exception");