Commit 0e108c8b authored by Nikita Sirgienko's avatar Nikita Sirgienko
Browse files

Add posibility to set path to Cantor Python Server in Settings.

parent c9fed55e
......@@ -47,10 +47,10 @@ const QChar recordSep(30);
const QChar unitSep(31);
const QChar messageEnd = 29;
PythonSession::PythonSession(Cantor::Backend* backend, int pythonVersion, const QString serverName)
PythonSession::PythonSession(Cantor::Backend* backend, int pythonVersion, const QUrl serverExecutableUrl)
: Session(backend)
, m_process(nullptr)
, serverName(serverName)
, m_serverExecutableUrl(serverExecutableUrl)
, m_pythonVersion(pythonVersion)
{
setVariableModel(new PythonVariableModel(this));
......@@ -77,7 +77,7 @@ void PythonSession::login()
m_process = new QProcess(this);
m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel);
m_process->start(QStandardPaths::findExecutable(serverName));
m_process->start(m_serverExecutableUrl.toLocalFile());
m_process->waitForStarted();
m_process->waitForReadyRead();
......@@ -96,9 +96,9 @@ void PythonSession::login()
sendCommand(QLatin1String("login"));
QString dir;
if (!worksheetPath.isEmpty())
dir = QFileInfo(worksheetPath).absoluteDir().absolutePath();
sendCommand(QLatin1String("setFilePath"), QStringList() << worksheetPath << dir);
if (!m_worksheetPath.isEmpty())
dir = QFileInfo(m_worksheetPath).absoluteDir().absolutePath();
sendCommand(QLatin1String("setFilePath"), QStringList() << m_worksheetPath << dir);
const QStringList& scripts = autorunScripts();
if(!scripts.isEmpty()){
......@@ -257,7 +257,7 @@ void PythonSession::readOutput()
void PythonSession::setWorksheetPath(const QString& path)
{
worksheetPath = path;
m_worksheetPath = path;
}
void PythonSession::reportServerProcessError(QProcess::ProcessError serverError)
......
......@@ -25,13 +25,14 @@
#include "session.h"
#include <cantor_pythonbackend_export.h>
#include <QStringList>
#include <QUrl>
#include <QProcess>
class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session
{
Q_OBJECT
public:
PythonSession(Cantor::Backend* backend, int pythonVersion, const QString serverName);
PythonSession(Cantor::Backend* backend, int pythonVersion, const QUrl serverExecutableUrl);
~PythonSession() override;
void login() override;
......@@ -50,9 +51,9 @@ class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session
private:
QProcess* m_process;
QString serverName;
QUrl m_serverExecutableUrl;
QString worksheetPath;
QString m_worksheetPath;
int m_pythonVersion;
QString m_output;
......
......@@ -11,6 +11,20 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout2">
<item>
<widget class="QLabel" name="label3">
<property name="text">
<string>Path to Cantor Python Server:</string>
</property>
</widget>
</item>
<item>
<widget class="KUrlRequester" name="kcfg_pythonServerPath"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......
......@@ -88,7 +88,7 @@ KConfigSkeleton* Python2Backend::config() const
bool Python2Backend::requirementsFullfilled(QString* const reason) const
{
const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_python2server"));
const QString& path = PythonSettings::pythonServerPath().toLocalFile();
return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python2 Server"), path, reason);
}
......
......@@ -5,6 +5,10 @@
https://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="cantorrc"/>
<group name="Python2Backend">
<entry name="pythonServerPath" type="Url">
<label>Path to Cantor python3 server executable</label>
<default code="true">QUrl::fromLocalFile(QStandardPaths::findExecutable(QLatin1String("cantor_python2server")))</default>
</entry>
<entry name="localDoc" type="Url">
<label>Url to the local Python documentation</label>
</entry>
......
......@@ -31,7 +31,7 @@
#include <KProcess>
Python2Session::Python2Session(Cantor::Backend* backend)
: PythonSession(backend, 2, QLatin1String("cantor_python2server"))
: PythonSession(backend, 2, PythonSettings::pythonServerPath())
{
}
......
......@@ -84,7 +84,7 @@ KConfigSkeleton* Python3Backend::config() const
bool Python3Backend::requirementsFullfilled(QString* const reason) const
{
const QString& path = QStandardPaths::findExecutable(QLatin1String("cantor_python3server"));
const QString& path = PythonSettings::pythonServerPath().toLocalFile();
return Cantor::Backend::checkExecutable(QLatin1String("Cantor Python3 Server"), path, reason);
}
......
......@@ -3,8 +3,13 @@
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.kde.org/standards/kcfg/1.0
https://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<include>QStandardPaths</include>
<kcfgfile name="cantorrc"/>
<group name="Python3Backend">
<entry name="pythonServerPath" type="Url">
<label>Path to Cantor python3 server executable</label>
<default code="true">QUrl::fromLocalFile(QStandardPaths::findExecutable(QLatin1String("cantor_python3server")))</default>
</entry>
<entry name="localDoc" type="Url">
<label>Url to the local Python documentation</label>
</entry>
......
......@@ -22,7 +22,7 @@
#include "settings.h"
Python3Session::Python3Session(Cantor::Backend* backend)
: PythonSession(backend, 3, QLatin1String("cantor_python3server"))
: PythonSession(backend, 3, PythonSettings::pythonServerPath())
{
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment