cutter/src/utils/JupyterConnection.h

67 lines
1.2 KiB
C
Raw Normal View History

2017-12-13 17:36:00 +00:00
#ifndef JUPYTERCONNECTION_H
#define JUPYTERCONNECTION_H
2018-03-02 13:15:53 +00:00
#ifdef CUTTER_ENABLE_JUPYTER
2017-12-13 17:36:00 +00:00
#include <QProcess>
2018-02-24 19:18:34 +00:00
#include <QMap>
#include <cwchar>
2017-12-13 17:36:00 +00:00
2018-02-22 21:08:06 +00:00
class NestedIPyKernel;
2018-02-09 15:48:02 +00:00
struct _object;
typedef _object PyObject;
struct _ts;
typedef _ts PyThreadState;
2017-12-13 17:36:00 +00:00
class JupyterConnection : public QObject
{
Q_OBJECT
public:
2018-03-21 20:32:32 +00:00
static JupyterConnection *getInstance();
2018-02-22 19:56:15 +00:00
2017-12-13 17:36:00 +00:00
JupyterConnection(QObject *parent = nullptr);
~JupyterConnection();
2018-03-21 20:32:32 +00:00
void setPythonHome(const QString pythonHome)
{
customPythonHome = pythonHome;
}
2018-03-06 17:21:42 +00:00
2017-12-13 17:36:00 +00:00
void start();
2018-02-22 19:56:15 +00:00
QString getUrl();
2017-12-13 17:36:00 +00:00
2018-02-22 21:08:06 +00:00
long startNestedIPyKernel(const QStringList &argv);
NestedIPyKernel *getNestedIPyKernel(long id);
2018-02-23 16:42:54 +00:00
QVariant pollNestedIPyKernel(long id);
2018-02-22 21:08:06 +00:00
2017-12-13 17:36:00 +00:00
signals:
void urlReceived(const QString &url);
2018-02-22 18:39:20 +00:00
void creationFailed();
2017-12-13 17:36:00 +00:00
private:
2018-02-09 15:48:02 +00:00
PyObject *cutterJupyterModule = nullptr;
PyObject *cutterNotebookAppInstance = nullptr;
2017-12-13 17:36:00 +00:00
2018-02-09 15:48:02 +00:00
PyThreadState *pyThreadState = nullptr;
2018-02-22 19:56:15 +00:00
2018-02-22 21:08:06 +00:00
QMap<long, NestedIPyKernel *> kernels;
long nextKernelId = 1;
2018-03-06 17:21:42 +00:00
QString customPythonHome;
wchar_t *pythonHome = nullptr;
2018-02-22 19:56:15 +00:00
void initPython();
void createCutterJupyterModule();
2017-12-13 17:36:00 +00:00
};
2018-02-22 19:56:15 +00:00
#define Jupyter() (JupyterConnection::getInstance())
2018-03-02 13:15:53 +00:00
#endif
2018-02-22 19:56:15 +00:00
2017-12-13 17:36:00 +00:00
#endif //JUPYTERCONNECTION_H