| 84 | } |
| 85 | |
| 86 | void CraftRuntime::refreshEnvCache() |
| 87 | { |
| 88 | QProcess python; |
| 89 | python.start(m_pythonExecutable, |
| 90 | QStringList{m_craftRoot + craftSetupHelperRelativePath(), QStringLiteral("--getenv")}); |
| 91 | python.waitForFinished(5000); |
| 92 | |
| 93 | if (python.error() != QProcess::UnknownError) { |
| 94 | if (python.error() == QProcess::Timedout) |
| 95 | qCWarning(CRAFT) << "CraftSetupHelper.py execution timed out"; |
| 96 | else |
| 97 | qCWarning(CRAFT) << "CraftSetupHelper.py execution failed:" << python.error() << python.errorString(); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | if (python.exitCode()) { |
| 102 | qCWarning(CRAFT) << "CraftSetupHelper.py execution failed with code" << python.exitCode(); |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | m_envCache.clear(); |
| 107 | |
| 108 | const QList<QByteArray> output = python.readAllStandardOutput().split('\n'); |
| 109 | for (const auto& line : output) { |
| 110 | // line contains things like "VAR=VALUE" |
| 111 | int equalsSignIndex = line.indexOf('='); |
| 112 | if (equalsSignIndex == -1) |
| 113 | continue; |
| 114 | |
| 115 | QByteArray varName = line.left(equalsSignIndex); |
| 116 | QByteArray value = line.mid(equalsSignIndex + 1); |
| 117 | m_envCache.emplace_back(varName, value); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | QByteArray CraftRuntime::getenv(const QByteArray& varname) const |
| 122 | { |
nothing calls this directly
no test coverage detected