Commit 9f0bf5d2 authored by Pavel Vainerman's avatar Pavel Vainerman

(Admin): подправил обработку ошибок

parent 412646b0
...@@ -41,8 +41,8 @@ static struct option longopts[] = ...@@ -41,8 +41,8 @@ static struct option longopts[] =
{ "start", no_argument, 0, 's' }, { "start", no_argument, 0, 's' },
{ "finish", no_argument, 0, 'f' }, { "finish", no_argument, 0, 'f' },
{ "foldUp", no_argument, 0, 'u' }, { "foldUp", no_argument, 0, 'u' },
{ "configure", required_argument, 0, 'r' }, { "configure", optional_argument, 0, 'r' },
{ "logrotate", required_argument, 0, 'l' }, { "logrotate", optional_argument, 0, 'l' },
{ "info", required_argument, 0, 'i' }, { "info", required_argument, 0, 'i' },
{ "setValue", required_argument, 0, 'x' }, { "setValue", required_argument, 0, 'x' },
{ "getValue", required_argument, 0, 'g' }, { "getValue", required_argument, 0, 'g' },
...@@ -184,7 +184,8 @@ int main(int argc, char** argv) ...@@ -184,7 +184,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return setValue(optarg, ui); string name = ( optarg ) ? optarg : "";
return setValue(name, ui);
} }
break; break;
...@@ -194,7 +195,8 @@ int main(int argc, char** argv) ...@@ -194,7 +195,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return getValue(optarg, ui); string name = ( optarg ) ? optarg : "";
return getValue(name, ui);
} }
break; break;
...@@ -204,7 +206,8 @@ int main(int argc, char** argv) ...@@ -204,7 +206,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return getRawValue(optarg, ui); string name = ( optarg ) ? optarg : "";
return getRawValue(name, ui);
} }
break; break;
...@@ -213,7 +216,8 @@ int main(int argc, char** argv) ...@@ -213,7 +216,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return getChangedTime(optarg, ui); string name = ( optarg ) ? optarg : "";
return getChangedTime(name, ui);
} }
break; break;
...@@ -271,7 +275,8 @@ int main(int argc, char** argv) ...@@ -271,7 +275,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return configure(optarg, ui); string name = ( optarg ) ? optarg : "";
return configure(name, ui);
} }
break; break;
...@@ -299,7 +304,8 @@ int main(int argc, char** argv) ...@@ -299,7 +304,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return logRotate(optarg, ui); string name = ( optarg ) ? optarg : "";
return logRotate(name, ui);
} }
break; break;
...@@ -309,7 +315,8 @@ int main(int argc, char** argv) ...@@ -309,7 +315,8 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(UniSetTypes::AdminID); ui.initBackId(UniSetTypes::AdminID);
return getCalibrate(optarg, ui); string name = ( optarg ) ? optarg : "";
return getCalibrate(name, ui);
} }
break; break;
...@@ -366,6 +373,11 @@ int main(int argc, char** argv) ...@@ -366,6 +373,11 @@ int main(int argc, char** argv)
cerr << " mesg: " << fe.errmsg() << endl; cerr << " mesg: " << fe.errmsg() << endl;
} }
} }
catch( std::exception& ex )
{
if( !quiet )
cerr << "exception: " << ex.what() << endl;
}
catch(...) catch(...)
{ {
if( !quiet ) if( !quiet )
...@@ -891,7 +903,7 @@ int logRotate( const string& arg, UInterface& ui ) ...@@ -891,7 +903,7 @@ int logRotate( const string& arg, UInterface& ui )
auto conf = ui.getConf(); auto conf = ui.getConf();
// посылка всем // посылка всем
if( arg.empty() || (arg.c_str())[0] != '-' ) if( arg.empty() || arg[0] == '-' )
{ {
auto rep = make_shared<ObjectRepository>(conf); auto rep = make_shared<ObjectRepository>(conf);
commandToAll(conf->getServicesSection(), rep, (Command)LogRotate); commandToAll(conf->getServicesSection(), rep, (Command)LogRotate);
...@@ -900,12 +912,16 @@ int logRotate( const string& arg, UInterface& ui ) ...@@ -900,12 +912,16 @@ int logRotate( const string& arg, UInterface& ui )
} }
else // посылка определённому объекту else // посылка определённому объекту
{ {
UniSetTypes::ObjectId id = conf->oind->getIdByName(arg); UniSetTypes::ObjectId id = conf->getObjectID(arg);
if( id == DefaultObjectId )
id = conf->getControllerID(arg);
else if( id == DefaultObjectId )
id = conf->getServiceID(arg);
if( id == DefaultObjectId ) if( id == DefaultObjectId )
{ {
if( !quiet ) if( !quiet )
cout << "(logrotate): name='" << arg << "' не найдено!!!\n"; cout << "(logrotate): not found ID for name='" << arg << "'" << endl;
return 1; return 1;
} }
...@@ -927,7 +943,7 @@ int configure( const string& arg, UInterface& ui ) ...@@ -927,7 +943,7 @@ int configure( const string& arg, UInterface& ui )
auto conf = ui.getConf(); auto conf = ui.getConf();
// посылка всем // посылка всем
if( arg.empty() || (arg.c_str())[0] != '-' ) if( arg.empty() || arg[0] == '-' )
{ {
auto rep = make_shared<ObjectRepository>(conf); auto rep = make_shared<ObjectRepository>(conf);
commandToAll(conf->getServicesSection(), rep, (Command)Configure); commandToAll(conf->getServicesSection(), rep, (Command)Configure);
...@@ -936,7 +952,11 @@ int configure( const string& arg, UInterface& ui ) ...@@ -936,7 +952,11 @@ int configure( const string& arg, UInterface& ui )
} }
else // посылка определённому объекту else // посылка определённому объекту
{ {
UniSetTypes::ObjectId id = conf->oind->getIdByName(arg); UniSetTypes::ObjectId id = conf->getObjectID(arg);
if( id == DefaultObjectId )
id = conf->getControllerID(arg);
else if( id == DefaultObjectId )
id = conf->getServiceID(arg);
if( id == DefaultObjectId ) if( id == DefaultObjectId )
{ {
...@@ -1031,3 +1051,4 @@ void errDoNotReolve( const std::string& oname ) ...@@ -1031,3 +1051,4 @@ void errDoNotReolve( const std::string& oname )
if( verb ) if( verb )
cerr << oname << ": resolve failed.." << endl; cerr << oname << ": resolve failed.." << endl;
} }
// --------------------------------------------------------------------------------------
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