MCPcopy Create free account
hub / github.com/KDE/kdevelop / refreshEnvCache

Method refreshEnvCache

plugins/craft/craftruntime.cpp:86–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86void 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
121QByteArray CraftRuntime::getenv(const QByteArray& varname) const
122{

Callers

nothing calls this directly

Calls 8

midMethod · 0.80
startMethod · 0.45
errorMethod · 0.45
errorStringMethod · 0.45
clearMethod · 0.45
splitMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected