Remove DBus from Python backend
ClosedPublic

Authored by sirgienko on May 14 2019, 12:04 PM.

Details

Summary

[Python] Massive refactoring

  • Remove communication via DBus, replaced by KProcess
  • Supports text result for a python expression with plot image result
  • Show numpy arrays in full form (because we had solved problem with showing big strings in the variable model)
  • Use Session::setVariableModel instead of handling variable model by self
  • Better interrupt
  • Use expression queue, model updating and expression finishing from Session
  • Remove unused PythonSession members
  • Some tests improvments

    Closes T6113, T6114

Diff Detail

Repository
R55 Cantor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sirgienko created this revision.May 14 2019, 12:04 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptMay 14 2019, 12:04 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
sirgienko requested review of this revision.May 14 2019, 12:04 PM
asemke added inline comments.May 18 2019, 3:14 PM
src/backends/python/pythonexpression.cpp
128–145

MaximaExpression::imageChanged() has a different logic and implementation. Can we try to unify the handling here?

133

what happens if we have two images from two expressions and they arrive at the wrong order (second image is faster than the first one)?

src/backends/python/pythonservermain.cpp
25

Are QTextStream and QChar really required in this file?

src/backends/python/pythonsession.cpp
139

use c++11 range based loop instead of the foreach macro.

src/backends/python/pythonvariablemodel.cpp
48–52

is this int variable still required in the new code?

sirgienko added inline comments.May 18 2019, 4:26 PM
src/backends/python/pythonexpression.cpp
133

All will worked, because each expressions have own m_tempFile.

src/backends/python/pythonservermain.cpp
25

QTextStream no needed, but QChar used in recordSep, unitSep. Though, maybe i could change it to char.

src/backends/python/pythonsession.cpp
139

OK.

src/backends/python/pythonvariablemodel.cpp
48–52

You right, the variable not needed, I just had forggoten to remove it.

sirgienko updated this revision to Diff 58335.May 20 2019, 9:15 AM
sirgienko marked 4 inline comments as done.

Some minor improvments

sirgienko added inline comments.May 20 2019, 9:16 AM
src/backends/python/pythonexpression.cpp
128–145

Not sure. MaximaExpression knows, where image placed, and imageChanged() handle this. Also, in maxima output there is placeholder for image.
PythonExpression has another conditions, so the code different from MaximaExpression code.
So, in this moment, I don't see general logic for both classes.

src/backends/python/pythonvariablemodel.cpp
48–52

I had mistaken, this variable contains value about variableManagement (enabled or not) from python settings. PythonSession haven't own settings, so we need use session method.

asemke added inline comments.Jun 2 2019, 5:02 PM
src/backends/python/pythonservermain.cpp
103

QString() is obsolete here.

105

QString() is obsolete here.

118

Qt has already qApp.

src/backends/python/pythonsession.cpp
220–223

const QString&?

src/backends/python/pythonsession.h
53

KProcess or QProcess?

src/backends/python/pythonvariablemodel.cpp
69

Please add some comments for the number 17 here.

src/backends/python/pythonvariablemodel.h
38–41

c++11 support the initialization in the header. Let's start using it for every new code:

Cantor::Expression* m_expression{nullptr};
sirgienko marked 4 inline comments as done.Jun 2 2019, 5:41 PM
sirgienko added inline comments.
src/backends/python/pythonservermain.cpp
118

qApp does not fit, but I will just use QCoreApplication::instance() and remove appRef var.

src/backends/python/pythonsession.h
53

QProcess

sirgienko updated this revision to Diff 59026.Jun 2 2019, 6:00 PM

Minor improvments

sirgienko marked 12 inline comments as done.Jun 2 2019, 6:02 PM
asemke accepted this revision.Jun 2 2019, 7:18 PM
This revision is now accepted and ready to land.Jun 2 2019, 7:18 PM
This revision was automatically updated to reflect the committed changes.