mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 23:26:25 +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;
|
||||
createStaticAssignmentsForTypeGivenConfigString((Assignment::Type) assignmentType,
|
||||
argumentList.value(clConfigIndex + 2));
|
||||
|
||||
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
|
||||
qDebug() << "Parsing command line config for assignment type" << type;
|
||||
|
||||
QString multiConfig(configString);
|
||||
QStringList multiConfigList = multiConfig.split(";");
|
||||
QStringList multiConfigList = configString.split(";", QString::SkipEmptyParts);
|
||||
|
||||
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
|
||||
for (int i = 0; i < multiConfigList.size(); i++) {
|
||||
QString config = multiConfigList.at(i);
|
||||
|
||||
qDebug("type %d config[%d] = %s", type, i, config.toLocal8Bit().constData());
|
||||
|
||||
// Now, parse the config to check for a pool
|
||||
const QString ASSIGNMENT_CONFIG_POOL_OPTION = "--pool";
|
||||
// check the config string for a pool
|
||||
QString assignmentPool;
|
||||
|
||||
int poolIndex = config.indexOf(ASSIGNMENT_CONFIG_POOL_OPTION);
|
||||
int poolIndex = poolRegex.indexIn(config);
|
||||
|
||||
if (poolIndex >= 0) {
|
||||
int spaceBeforePoolIndex = config.indexOf(' ', poolIndex);
|
||||
int spaceAfterPoolIndex = config.indexOf(' ', spaceBeforePoolIndex);
|
||||
if (poolIndex != -1) {
|
||||
assignmentPool = poolRegex.cap(1);
|
||||
|
||||
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);
|
||||
|
||||
configAssignment->setPayload(config.toUtf8());
|
||||
|
|
|
@ -144,6 +144,11 @@ const char* Assignment::getTypeName() const {
|
|||
QDebug operator<<(QDebug debug, const Assignment &assignment) {
|
||||
debug.nospace() << "UUID: " << qPrintable(assignment.getUUID().toString()) <<
|
||||
", Type: " << assignment.getType();
|
||||
|
||||
if (!assignment.getPool().isEmpty()) {
|
||||
debug << ", Pool: " << assignment.getPool();
|
||||
}
|
||||
|
||||
return debug.space();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue