Skip to content
Permalink
Browse files

Don't require all parameter values to be specified via qgis_process c…

…ommand line tool
  • Loading branch information
github-actions authored and nyalldawson committed Jul 9, 2020
1 parent 7382248 commit 0253e633ff1aca0b52657ec9ee7b109229f79d8f
Showing with 15 additions and 4 deletions.
  1. +14 −3 src/process/qgsprocess.cpp
  2. +1 −1 tests/src/python/test_qgsprocessexecutable.py
@@ -440,13 +440,17 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap &params )
std::cout << it.key().toLocal8Bit().constData() << ":\t" << it.value().toString().toLocal8Bit().constData() << '\n';
}

QgsProcessingContext context;
const QgsProcessingParameterDefinitions defs = alg->parameterDefinitions();
QList< const QgsProcessingParameterDefinition * > missingParams;
for ( const QgsProcessingParameterDefinition *p : defs )
{
if ( !( p->flags() & QgsProcessingParameterDefinition::FlagOptional ) && !params.contains( p->name() ) )
if ( !p->checkValueIsAcceptable( params.value( p->name() ), &context ) )
{
missingParams << p;
if ( !( p->flags() & QgsProcessingParameterDefinition::FlagOptional ) && !params.contains( p->name() ) )
{
missingParams << p;
}
}
}

@@ -461,7 +465,14 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap &params )
return 1;
}

QgsProcessingContext context;
QString message;
if ( !alg->checkParameterValues( params, context, &message ) )
{
std::cerr << QStringLiteral( "ERROR:\tAn error was encountered while checking parameter values\n" ).toLocal8Bit().constData();
std::cerr << QStringLiteral( "\t%1\n" ).arg( message ).toLocal8Bit().constData();
return 1;
}

ConsoleFeedback feedback;

#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID)
@@ -111,7 +111,7 @@ def testAlgorithmRunNoArgs(self):

def testAlgorithmRun(self):
output_file = self.TMP_DIR + '/polygon_centroid.shp'
rc, output, err = self.run_process(['run', 'native:centroids', '--INPUT={}'.format(TEST_DATA_DIR + '/polys.shp'), '--ALL_PARTS=false', '--OUTPUT={}'.format(output_file)])
rc, output, err = self.run_process(['run', 'native:centroids', '--INPUT={}'.format(TEST_DATA_DIR + '/polys.shp'), '--OUTPUT={}'.format(output_file)])
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)

0 comments on commit 0253e63

Please sign in to comment.
You can’t perform that action at this time.