From bee666b522d21d8be260c8ab71f22a9fb7077c1e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 5 Dec 2017 09:10:08 -0800 Subject: [PATCH] Add error text reading to asset server baking --- assignment-client/src/assets/BakeAssetTask.cpp | 14 +++++++++++--- tools/oven/src/BakerCLI.cpp | 12 ++++++++++-- tools/oven/src/BakerCLI.h | 2 ++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/assets/BakeAssetTask.cpp b/assignment-client/src/assets/BakeAssetTask.cpp index bb0c344a1f..9a22b065fa 100644 --- a/assignment-client/src/assets/BakeAssetTask.cpp +++ b/assignment-client/src/assets/BakeAssetTask.cpp @@ -77,12 +77,23 @@ void BakeAssetTask::run() { } if (exitCode == OVEN_STATUS_CODE_SUCCESS) { + _didFinish.store(true); emit bakeComplete(_assetHash, _assetPath, tempOutputDir, outputFiles); } else if (exitCode == OVEN_STATUS_CODE_ABORT) { + _wasAborted.store(true); emit bakeAborted(_assetHash, _assetPath); } else { QString errors; if (exitCode == OVEN_STATUS_CODE_FAIL) { + _didFinish.store(true); + auto errorFilePath = _outputDir.absoluteFilePath("errors.txt"); + QFile errorFile { errorFilePath }; + if (errorFile.open(QIODevice::ReadOnly)) { + errors = errorFile.readAll(); + errorFile.close(); + } else { + errors = "Unknown error occurred"; + } } emit bakeFailed(_assetHash, _assetPath, errors); } @@ -95,12 +106,9 @@ void BakeAssetTask::run() { qDebug() << "Process started"; }); - qDebug() << "Starting process!"; proc->start(path, args, QIODevice::ReadOnly); proc->waitForStarted(); - qDebug() << "Started"; proc->waitForFinished(); - qDebug() << "Finished"; return; diff --git a/tools/oven/src/BakerCLI.cpp b/tools/oven/src/BakerCLI.cpp index 01276c34c8..e28d914e47 100644 --- a/tools/oven/src/BakerCLI.cpp +++ b/tools/oven/src/BakerCLI.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "ModelBakingLoggingCategory.h" #include "Oven.h" @@ -45,6 +46,8 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString& outputPath, const QString& bool isSupportedImage = QImageReader::supportedImageFormats().contains(extension.toLatin1()); + _outputPath = outputPath; + // create our appropiate baker if (isFBX) { _baker = std::unique_ptr { new FBXBaker(inputUrl, []() -> QThread* { return qApp->getNextWorkerThread(); }, outputPath) }; @@ -68,10 +71,15 @@ void BakerCLI::handleFinishedBaker() { qCDebug(model_baking) << "Finished baking file."; int exitCode = OVEN_STATUS_CODE_SUCCESS; // Do we need this? - if (_baker.get()->wasAborted()) { + if (_baker->wasAborted()) { exitCode = OVEN_STATUS_CODE_ABORT; - } else if (_baker.get()->hasErrors()) { + } else if (_baker->hasErrors()) { exitCode = OVEN_STATUS_CODE_FAIL; + QFile errorFile { _outputPath.absoluteFilePath("errors.txt") }; + if (errorFile.open(QFile::WriteOnly)) { + errorFile.write(_baker->getErrors().join('\n').toUtf8()); + errorFile.close(); + } } QApplication::exit(exitCode); } diff --git a/tools/oven/src/BakerCLI.h b/tools/oven/src/BakerCLI.h index a6d96cab9b..7d362eb898 100644 --- a/tools/oven/src/BakerCLI.h +++ b/tools/oven/src/BakerCLI.h @@ -13,6 +13,7 @@ #define hifi_BakerCLI_h #include +#include #include @@ -36,6 +37,7 @@ private slots: void handleFinishedBaker(); private: + QDir _outputPath; std::unique_ptr _baker; };