#include "backend.h" Backend::Backend(QObject *parent) : QObject(parent) { process.setProgram("python"); } bool Backend::movePanTilt(QString basePath, int pan, int tilt) { //qDebug() << "pan:" << pan << " | tilt:" << tilt; QString errorMsg = QString(); if (process.state() != 0) { errorMsg = "waiting till previously started process ends..."; qDebug() << errorMsg; emit someError(errorMsg); return false; } process.setArguments(QStringList() << QString("%1/scripts/move.py").arg(basePath) << QString::number(pan) << QString::number(tilt) ); process.start(); process.waitForFinished(500); if (process.exitCode() != 0) { errorMsg = process.readAllStandardError(); qDebug() << "error:" << errorMsg; emit someError(errorMsg); return false; } else { //qDebug() << "output:" << process.readAllStandardOutput(); return true; } } QString Backend::getBasePath(QString applicationDirPath) { QString baseFolder = QString(); QString pathLastMile = baseFolder.prepend("/"); #if defined(Q_OS_MAC) pathLastMile = baseFolder.prepend("/../../.."); #elif defined(Q_OS_WIN) pathLastMile = baseFolder.prepend("/.."); #endif return QString("%1%2").arg(applicationDirPath).arg(pathLastMile); }