cleaning up interpolation

master
phanes 2024-02-09 01:20:17 -05:00
parent d13793954d
commit 698ba9373c
3 changed files with 15 additions and 14 deletions

View File

@ -72,7 +72,7 @@ void Conf::set_object_s(std::string keyname, std::string & object_member, std::s
if ( this->get_string(jval_s, keyname) != 0) { if ( this->get_string(jval_s, keyname) != 0) {
throw ConfigLoadException( "'" + keyname + "' string is not set in the config file supplied: " + filename ); throw ConfigLoadException( "'" + keyname + "' string is not set in the config file supplied: " + filename );
} else { } else {
interpolate(jval_s); //interpolate(jval_s);
object_member = jval_s; object_member = jval_s;
} }
this->slog.log_task( E_DEBUG, "SET_PROPERTY", "'" + keyname + "': " + object_member ); this->slog.log_task( E_DEBUG, "SET_PROPERTY", "'" + keyname + "': " + object_member );
@ -101,7 +101,7 @@ void Conf::set_object_s_derivedpath(std::string keyname, std::string & object_me
if ( this->get_string(jval_s, keyname) != 0) { if ( this->get_string(jval_s, keyname) != 0) {
throw ConfigLoadException( "'" + keyname + "' string is not set in the config file supplied: " + filename ); throw ConfigLoadException( "'" + keyname + "' string is not set in the config file supplied: " + filename );
} else { } else {
interpolate(jval_s); //interpolate(jval_s);
object_member = prepend_project_root( jval_s ); object_member = prepend_project_root( jval_s );
} }
this->slog.log_task( E_DEBUG, "SET_PROPERTY", "'" + keyname + "': " + object_member ); this->slog.log_task( E_DEBUG, "SET_PROPERTY", "'" + keyname + "': " + object_member );
@ -243,8 +243,6 @@ Shell Conf::get_shell_by_name( std::string name ) {
throw ConfigLoadException("The shell specified ('" + name + "') is not defined in the shell definitions file."); throw ConfigLoadException("The shell specified ('" + name + "') is not defined in the shell definitions file.");
} }
/** /**
* @class Conf * @class Conf
* @brief Loads the configuration for the application * @brief Loads the configuration for the application
@ -262,9 +260,9 @@ Shell Conf::get_shell_by_name( std::string name ) {
Conf::Conf(std::string filename, int LOG_LEVEL ): JSON_Loader(LOG_LEVEL ), slog(LOG_LEVEL, "_conf_" ) Conf::Conf(std::string filename, int LOG_LEVEL ): JSON_Loader(LOG_LEVEL ), slog(LOG_LEVEL, "_conf_" )
{ {
this->LOG_LEVEL = LOG_LEVEL; this->LOG_LEVEL = LOG_LEVEL;
this->slog.log_task( E_DEBUG, "LOAD", "Loading configuration file: " + filename );
interpolate( filename ); interpolate( filename );
this->slog.log_task( E_DEBUG, "LOAD", "Loading configuration file: " + filename );
try { try {
// load the test file. // load the test file.
@ -273,6 +271,7 @@ Conf::Conf(std::string filename, int LOG_LEVEL ): JSON_Loader(LOG_LEVEL ), slog(
this->slog.log( E_FATAL, "Unable to load configuration file: '" + filename + "'. Error: " + e.what()); this->slog.log( E_FATAL, "Unable to load configuration file: '" + filename + "'. Error: " + e.what());
throw ConfigLoadException("Parsing error in configuration file."); throw ConfigLoadException("Parsing error in configuration file.");
} }
Json::Value jbuff; Json::Value jbuff;
if ( this->get_serialized( jbuff, "config" ) != 0) { if ( this->get_serialized( jbuff, "config" ) != 0) {
@ -284,7 +283,8 @@ Conf::Conf(std::string filename, int LOG_LEVEL ): JSON_Loader(LOG_LEVEL ), slog(
} }
set_object_s( "project_root", this->project_root, filename ); set_object_s( "project_root", this->project_root, filename );
interpolate( project_root ); interpolate( this->project_root );
// convert to an absolute path after all the interpolation is done. // convert to an absolute path after all the interpolation is done.
this->project_root = get_absolute_path( this->project_root ); this->project_root = get_absolute_path( this->project_root );

View File

@ -247,6 +247,7 @@ int exec_pty(
} else { } else {
// byte count was sane // byte count was sane
// write to stdout,stderr // write to stdout,stderr
if (this_fd == 0) { if (this_fd == 0) {
// parent stdin received, write to child pty (stdin) // parent stdin received, write to child pty (stdin)
write_all(masterFd, buf, byte_count); write_all(masterFd, buf, byte_count);

View File

@ -354,9 +354,9 @@ void Task::execute( Conf * configuration )
std::string environment_file = this->definition.get_environment_file(); std::string environment_file = this->definition.get_environment_file();
std::string logs_root = configuration->get_logs_path(); std::string logs_root = configuration->get_logs_path();
interpolate(task_name);
this->slog.log_task( E_DEBUG, task_name, "Using unit definition: \"" + task_name + "\"." ); this->slog.log_task( E_DEBUG, task_name, "Using unit definition: \"" + task_name + "\"." );
interpolate(task_name);
interpolate(command); interpolate(command);
interpolate(shell_name); interpolate(shell_name);
interpolate(user); interpolate(user);