Class Avogadro::QtGui::PythonScript

class Avogadro::QtGui::PythonScript : public QObject

The PythonScript class implements a interface for calling short-lived python utility scripts.

Unnamed Group

explicit PythonScript(const QString &scriptFilePath_, QObject *parent_ = nullptr)

Constructors

Parameters

scriptFilePath_ – Absolute path to python script.

explicit PythonScript(QObject *parent_ = nullptr)

Constructors

Parameters

scriptFilePath_ – Absolute path to python script.

Public Functions

~PythonScript() override
inline bool debug() const
Returns

True if debugging of python I/O is enabled.

inline QString scriptFilePath() const
Returns

The path to the generator file.

void setScriptFilePath(const QString &scriptFile)

Set the path to the input generator script file. This will reset any cached data held by this class.

inline bool hasErrors() const
Returns

True if an error is set.

inline void clearErrors()

Reset the error counter.

inline QStringList errorList() const
Returns

A QStringList containing all errors that occurred in the last call to the input generator script.

void setDefaultPythonInterpretor()

Reset the python interpretor path. The following are checked, in order:

  • The AVO_PYTHON_INTERPRETER environment variable

  • The “interpreters/python” QSettings value

  • The path specified in avogadropython.h.

QByteArray execute(const QStringList &args, const QByteArray &scriptStdin = QByteArray())

Start a new process to execute: “<m_pythonInterpreter> <scriptFilePath()> [args …]”, optionally passing scriptStdin to the processes standard input. Returns the standard output of the process when finished.

void asyncExecute(const QStringList &args, const QByteArray &scriptStdin = QByteArray())

Start a new process to execute asynchronously “<m_pythonInterpreter> <scriptFilePath()> [args …]”, optionally passing scriptStdin to the processes standard input.

Will send asyncFinished() signal when finished

QByteArray asyncResponse()

Returns the standard output of the asynchronous process when finished.

Public Slots

inline void setDebug(bool d)

Enable/disable debugging.

void processFinished(int exitCode, QProcess::ExitStatus exitStatus)

Handle a finished process;

Signals

void finished()

The asynchronous execution is finished or timed out

Protected Attributes

bool m_debug
QString m_pythonInterpreter
QString m_scriptFilePath
QStringList m_errors
QProcess *m_process