mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +02:00
fix config parsing from command line and json
This commit is contained in:
parent
55049eeb6b
commit
984fb1a5df
2 changed files with 18 additions and 13 deletions
|
@ -82,11 +82,10 @@ void DomainServer::parseCommandLineTypeConfigs(const QStringList& argumentList,
|
||||||
Assignment::Type assignmentType = (Assignment::Type) clConfigType;
|
Assignment::Type assignmentType = (Assignment::Type) clConfigType;
|
||||||
createStaticAssignmentsForTypeGivenConfigString((Assignment::Type) assignmentType,
|
createStaticAssignmentsForTypeGivenConfigString((Assignment::Type) assignmentType,
|
||||||
argumentList.value(clConfigIndex + 2));
|
argumentList.value(clConfigIndex + 2));
|
||||||
|
|
||||||
excludedTypes.insert(assignmentType);
|
excludedTypes.insert(assignmentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
clConfigIndex = argumentList.indexOf(CONFIG_TYPE_OPTION, clConfigIndex);
|
clConfigIndex = argumentList.indexOf(CONFIG_TYPE_OPTION, clConfigIndex + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,28 +166,29 @@ void DomainServer::createStaticAssignmentsForTypeGivenConfigString(Assignment::T
|
||||||
// we have a string for config for this type
|
// we have a string for config for this type
|
||||||
qDebug() << "Parsing command line config for assignment type" << type;
|
qDebug() << "Parsing command line config for assignment type" << type;
|
||||||
|
|
||||||
QString multiConfig(configString);
|
QStringList multiConfigList = configString.split(";", QString::SkipEmptyParts);
|
||||||
QStringList multiConfigList = multiConfig.split(";");
|
|
||||||
|
const QString ASSIGNMENT_CONFIG_POOL_REGEX = "--pool\\s*(\\w+)";
|
||||||
|
QRegExp poolRegex(ASSIGNMENT_CONFIG_POOL_REGEX);
|
||||||
|
|
||||||
// read each config to a payload for this type of assignment
|
// read each config to a payload for this type of assignment
|
||||||
for (int i = 0; i < multiConfigList.size(); i++) {
|
for (int i = 0; i < multiConfigList.size(); i++) {
|
||||||
QString config = multiConfigList.at(i);
|
QString config = multiConfigList.at(i);
|
||||||
|
|
||||||
qDebug("type %d config[%d] = %s", type, i, config.toLocal8Bit().constData());
|
// check the config string for a pool
|
||||||
|
|
||||||
// Now, parse the config to check for a pool
|
|
||||||
const QString ASSIGNMENT_CONFIG_POOL_OPTION = "--pool";
|
|
||||||
QString assignmentPool;
|
QString assignmentPool;
|
||||||
|
|
||||||
int poolIndex = config.indexOf(ASSIGNMENT_CONFIG_POOL_OPTION);
|
int poolIndex = poolRegex.indexIn(config);
|
||||||
|
|
||||||
if (poolIndex >= 0) {
|
if (poolIndex != -1) {
|
||||||
int spaceBeforePoolIndex = config.indexOf(' ', poolIndex);
|
assignmentPool = poolRegex.cap(1);
|
||||||
int spaceAfterPoolIndex = config.indexOf(' ', spaceBeforePoolIndex);
|
|
||||||
|
|
||||||
assignmentPool = config.mid(spaceBeforePoolIndex + 1, spaceAfterPoolIndex);
|
// remove the pool from the config string, the assigned node doesn't need it
|
||||||
|
config.remove(poolIndex, poolRegex.matchedLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug("Type %d config[%d] = %s", type, i, config.toLocal8Bit().constData());
|
||||||
|
|
||||||
Assignment* configAssignment = new Assignment(Assignment::CreateCommand, type, assignmentPool);
|
Assignment* configAssignment = new Assignment(Assignment::CreateCommand, type, assignmentPool);
|
||||||
|
|
||||||
configAssignment->setPayload(config.toUtf8());
|
configAssignment->setPayload(config.toUtf8());
|
||||||
|
|
|
@ -144,6 +144,11 @@ const char* Assignment::getTypeName() const {
|
||||||
QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
||||||
debug.nospace() << "UUID: " << qPrintable(assignment.getUUID().toString()) <<
|
debug.nospace() << "UUID: " << qPrintable(assignment.getUUID().toString()) <<
|
||||||
", Type: " << assignment.getType();
|
", Type: " << assignment.getType();
|
||||||
|
|
||||||
|
if (!assignment.getPool().isEmpty()) {
|
||||||
|
debug << ", Pool: " << assignment.getPool();
|
||||||
|
}
|
||||||
|
|
||||||
return debug.space();
|
return debug.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue