mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Load cutter_jupyter.py from Qt resources
This commit is contained in:
parent
a5e77c5095
commit
0a9fba0677
@ -16,15 +16,7 @@ class CutterNotebookApp(NotebookApp):
|
|||||||
|
|
||||||
self.write_server_info_file()
|
self.write_server_info_file()
|
||||||
|
|
||||||
class NotebookThread(threading.Thread):
|
self.thread = threading.Thread(target=self.run)
|
||||||
def __init__(self, notebook_app):
|
|
||||||
super().__init__()
|
|
||||||
self.notebook_app = notebook_app
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
self.notebook_app.run()
|
|
||||||
|
|
||||||
self.thread = NotebookThread(self)
|
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -60,5 +60,7 @@
|
|||||||
<file>img/cutter_plain.svg</file>
|
<file>img/cutter_plain.svg</file>
|
||||||
<file>img/cutter_white_plain.svg</file>
|
<file>img/cutter_white_plain.svg</file>
|
||||||
<file>img/cutter.svg</file>
|
<file>img/cutter.svg</file>
|
||||||
|
|
||||||
|
<file>python/cutter_jupyter.py</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
#include "JupyterConnection.h"
|
#include "JupyterConnection.h"
|
||||||
|
|
||||||
@ -32,12 +33,25 @@ void JupyterConnection::start()
|
|||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
|
|
||||||
cutterJupyterModule = PyImport_ImportModule("cutter_jupyter");
|
QFile moduleFile(":/python/cutter_jupyter.py");
|
||||||
|
moduleFile.open(QIODevice::ReadOnly);
|
||||||
|
QByteArray moduleCode = moduleFile.readAll();
|
||||||
|
moduleFile.close();
|
||||||
|
|
||||||
|
auto moduleCodeObject = Py_CompileString(moduleCode.constData(), "cutter_jupyter.py", Py_file_input);
|
||||||
|
if (!moduleCodeObject)
|
||||||
|
{
|
||||||
|
qWarning() << "Could not compile cutter_jupyter.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
||||||
|
Py_DECREF(moduleCodeObject);
|
||||||
if (!cutterJupyterModule)
|
if (!cutterJupyterModule)
|
||||||
{
|
{
|
||||||
qWarning() << "Could not import cutter_jupyter.";
|
qWarning() << "Could not import cutter_jupyter.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto startFunc = PyObject_GetAttrString(cutterJupyterModule, "start_jupyter");
|
auto startFunc = PyObject_GetAttrString(cutterJupyterModule, "start_jupyter");
|
||||||
cutterNotebookAppInstance = PyObject_CallObject(startFunc, nullptr);
|
cutterNotebookAppInstance = PyObject_CallObject(startFunc, nullptr);
|
||||||
auto urlWithToken = PyObject_GetAttrString(cutterNotebookAppInstance, "url_with_token");
|
auto urlWithToken = PyObject_GetAttrString(cutterNotebookAppInstance, "url_with_token");
|
||||||
|
Loading…
Reference in New Issue
Block a user