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()
|
||||
|
||||
class NotebookThread(threading.Thread):
|
||||
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 = threading.Thread(target=self.run)
|
||||
self.thread.start()
|
||||
|
||||
def run(self):
|
||||
|
@ -60,5 +60,7 @@
|
||||
<file>img/cutter_plain.svg</file>
|
||||
<file>img/cutter_white_plain.svg</file>
|
||||
<file>img/cutter.svg</file>
|
||||
|
||||
<file>python/cutter_jupyter.py</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QFile>
|
||||
|
||||
#include "JupyterConnection.h"
|
||||
|
||||
@ -32,12 +33,25 @@ void JupyterConnection::start()
|
||||
Py_Initialize();
|
||||
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)
|
||||
{
|
||||
qWarning() << "Could not import cutter_jupyter.";
|
||||
return;
|
||||
}
|
||||
|
||||
auto startFunc = PyObject_GetAttrString(cutterJupyterModule, "start_jupyter");
|
||||
cutterNotebookAppInstance = PyObject_CallObject(startFunc, nullptr);
|
||||
auto urlWithToken = PyObject_GetAttrString(cutterNotebookAppInstance, "url_with_token");
|
||||
|
Loading…
Reference in New Issue
Block a user