Commit 0cf7463f authored by Marc R.'s avatar Marc R.

if no pipeline and frontend files are specified on the command line, Met.3D...

if no pipeline and frontend files are specified on the command line, Met.3D now uses the default files
parent 2aceadf4
......@@ -84,48 +84,66 @@ void MFrontendConfiguration::configure()
// initializeDevelopmentFrontend();
// return;
QString filename = "";
// Scan global application command line arguments for pipeline definitions.
MSystemManagerAndControl *sysMC = MSystemManagerAndControl::getInstance();
foreach (QString arg, sysMC->getApplicationCommandLineArguments())
{
if (arg.startsWith("--frontend="))
{
QString filename = arg.remove("--frontend=");
filename = arg.remove("--frontend=");
filename = expandEnvironmentVariables(filename);
// Production builds should use the config-from-file mechanism.
initializeFrontendFromConfigFile(filename);
return;
}
}
QString errMsg = "";
// If Met.3D is called by Metview and no configuration files are given,
// use default configuration files stored at
// $MET3D_HOME/config/metview/default_frontend.cfg .
if (sysMC->isConnectedToMetview())
if (sysMC->isConnectedToMetview() && filename.isEmpty())
{
// If Met.3D is called by Metview and no configuration files are given,
// use default configuration files stored at
// $MET3D_HOME/config/metview/default_frontend.cfg .
QString filename = "$MET3D_HOME/config/metview/default_frontend.cfg";
filename = expandEnvironmentVariables(filename);
QFileInfo fileInfo(filename);
if (fileInfo.isFile())
if (!fileInfo.isFile())
{
// Production builds should use the config-from-file mechanism.
initializeFrontendFromConfigFile(filename);
return;
errMsg = QString(
"ERROR: Default Metview frontend configuration file does"
" not exist. Location: ") + filename;
filename = "";
}
errMsg = QString(
"ERROR: Default Metview frontend configuration file does"
" not exist. Location: ") + filename;
LOG4CPLUS_ERROR(mlog, errMsg.toStdString());
}
else
else if (filename.isEmpty())
{
errMsg = QString(
"ERROR: No frontend configuration file specified."
"Use the '--frontend=<file>' command line argument.");
// No frontend file has been specified. Try to access default
// frontend.
LOG4CPLUS_WARN(mlog, "WARNING: No frontend configuration "
"file has been specified. Using default frontend "
"instead. To specify a custom file, use the "
"'--frontend=<file>' command line argument.");
filename = "$MET3D_HOME/config/default_frontend.cfg.template";
filename = expandEnvironmentVariables(filename);
QFileInfo fileInfo(filename);
if (!fileInfo.isFile())
{
errMsg = QString(
"ERROR: Default frontend configuration file"
" does not exist. Location: ") + filename;
filename = "";
}
LOG4CPLUS_ERROR(mlog, errMsg.toStdString());
}
if (!filename.isEmpty())
{
initializeFrontendFromConfigFile(filename);
return;
}
throw MInitialisationError(errMsg.toStdString(), __FILE__, __LINE__);
}
......
......@@ -103,11 +103,12 @@ void MPipelineConfiguration::configure()
}
QString errMsg = "";
// If Met.3D is called by Metview and no configuration files are given,
// use default configuration files stored at
// $MET3D_HOME/config/metview/default_pipeline.cfg .
if (sysMC->isConnectedToMetview() && filename.isEmpty())
{
// If Met.3D is called by Metview and no configuration files are given,
// use default configuration files stored at
// $MET3D_HOME/config/metview/default_pipeline.cfg .
filename = "$MET3D_HOME/config/metview/default_pipeline.cfg";
filename = expandEnvironmentVariables(filename);
QFileInfo fileInfo(filename);
......@@ -116,6 +117,28 @@ void MPipelineConfiguration::configure()
errMsg = QString(
"ERROR: Default Metview pipeline configuration file"
" does not exist. Location: ") + filename;
filename = "";
}
LOG4CPLUS_ERROR(mlog, errMsg.toStdString());
}
else if (filename.isEmpty())
{
// No pipeline file has been specified. Try to access default
// pipeline.
LOG4CPLUS_WARN(mlog, "WARNING: No data pipeline configuration "
"file has been specified. Using default pipeline "
"instead. To specify a custom file, use the "
"'--pipeline=<file>' command line argument.");
filename = "$MET3D_HOME/config/default_pipeline.cfg.template";
filename = expandEnvironmentVariables(filename);
QFileInfo fileInfo(filename);
if (!fileInfo.isFile())
{
errMsg = QString(
"ERROR: Default pipeline configuration file"
" does not exist. Location: ") + filename;
filename = "";
}
LOG4CPLUS_ERROR(mlog, errMsg.toStdString());
}
......@@ -128,13 +151,7 @@ void MPipelineConfiguration::configure()
initializeDataPipelineFromConfigFile(filename);
return;
}
else
{
errMsg = QString(
"ERROR: No data pipeline configuration file specified. "
"Use the '--pipeline=<file>' command line argument.");
LOG4CPLUS_ERROR(mlog, errMsg.toStdString());
}
throw MInitialisationError(errMsg.toStdString(), __FILE__, __LINE__);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment