[simspark-cvs] simspark/spark/zeitgeist/scriptserver scriptserver.h,1.1,1.2 scriptserver.cpp,1.1,1.2
From: Jan M. <ja...@us...> - 2006-05-16 10:17:48
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31198 Modified Files: scriptserver.h scriptserver.cpp Log Message: - added enum returntype for running init scripts - RunInitScript distinguishes between faulty and missing scripts now. user local scripts are NOT overwritten if they contain errors. If they are missing, the global scripts are still installed. - Error/Debug messages make more sense now - RunInitScriptInternal returns error type instead of boolean value now Index: scriptserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver/scriptserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scriptserver.cpp 5 Dec 2005 21:05:01 -0000 1.1 --- scriptserver.cpp 16 May 2006 10:17:32 -0000 1.2 *************** *** 466,470 **** } ! bool ScriptServer::RunInitScriptInternal(const string &sourceDir, const string &name, bool copy, const string& destDir) --- 466,470 ---- } ! ScriptServer::ERunScriptErrorType ScriptServer::RunInitScriptInternal(const string &sourceDir, const string &name, bool copy, const string& destDir) *************** *** 475,485 **** shared_ptr<salt::StdFile> file(new(salt::StdFile)); ! if ( ! (! file->Open(sourcePath.c_str())) || ! (! Run(file)) ! ) { ! GetLog()->Debug() << "failed" << endl; ! return false; } else { --- 475,486 ---- shared_ptr<salt::StdFile> file(new(salt::StdFile)); ! if (! file->Open(sourcePath.c_str())) { ! GetLog()->Debug() << "failed (script not found)" << endl; ! return eNotFound; ! } else if (! Run(file)) ! { ! GetLog()->Debug() << "failed (error in script" << endl; ! return eError; } else { *************** *** 490,494 **** if (! copy) { ! return true; } --- 491,495 ---- if (! copy) { ! return eOK; } *************** *** 502,506 **** system(s.str().c_str()); ! return true; } --- 503,507 ---- system(s.str().c_str()); ! return eOK; } *************** *** 571,590 **** string pkgdatadir = PREFIX "/share/" PACKAGE_NAME; ! bool ok = ! ( ! ( ! (validDotDir) && (RunInitScriptInternal(dotDir, fileName, false)) ! ) ! || (RunInitScriptInternal(pkgdatadir, fileName, validDotDir, dotDir)) ! || (RunInitScriptInternal(mRelPathPrefix+relPath, fileName, validDotDir, dotDir)) ! ); ! if (! ok) { GetLog()->Error() << "(ScriptServer) ERROR: Cannot locate init script '" << fileName << "'\n"; } ! ! return ok; } --- 572,642 ---- string pkgdatadir = PREFIX "/share/" PACKAGE_NAME; ! //std::cout << "dotDir = " << dotDir << std::endl; ! //std::cout << "pkgdatadir = " << pkgdatadir << std::endl; ! //std::cout << "filename = " << fileName << std::endl; ! ERunScriptErrorType result; ! ! if (validDotDir) ! { ! result = RunInitScriptInternal(dotDir, fileName, false); ! } ! ! if (result == eOK) ! { ! GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << dotDir << "/" << fileName << "'\n"; ! return true; ! } ! ! if (result == eNotFound) ! { ! GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << dotDir << "/" << fileName << "'\n"; ! } ! else if (result == eError) ! { ! GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << dotDir << "/" << fileName << "'\n"; ! return false; ! } ! ! ! // ! result = RunInitScriptInternal(pkgdatadir, fileName, validDotDir, dotDir); ! ! if (result == eOK) ! { ! GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << pkgdatadir << "/" << fileName << "'\n"; ! return true; ! } ! ! if (result == eNotFound) ! { ! GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << pkgdatadir << "/" << fileName << "'\n"; ! } ! else if (result == eError) ! { ! GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << pkgdatadir << "/" << fileName << "'\n"; ! } ! ! ! result = RunInitScriptInternal(mRelPathPrefix+relPath, fileName, validDotDir, dotDir); ! ! if (result == eNotFound) { GetLog()->Error() << "(ScriptServer) ERROR: Cannot locate init script '" << fileName << "'\n"; } ! else if (result == eError) ! { ! GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << mRelPathPrefix+relPath << "/" << fileName << "'\n"; ! } ! ! return (result == eOK); } Index: scriptserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver/scriptserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scriptserver.h 5 Dec 2005 21:05:01 -0000 1.1 --- scriptserver.h 16 May 2006 10:17:32 -0000 1.2 *************** *** 62,65 **** --- 62,73 ---- }; + enum ERunScriptErrorType + { + eOK, // no errors + eNotFound, // could not find script + eError // some error occured while executing the script + }; + + protected: private: *************** *** 162,167 **** /** private helper function */ ! bool RunInitScriptInternal(const std::string &dir, const std::string &name, ! bool copy, const std::string& destDir = ""); /** construct the path of the local dot directory that contains --- 170,175 ---- /** private helper function */ ! ERunScriptErrorType RunInitScriptInternal(const std::string &dir, const std::string &name, ! bool copy, const std::string& destDir = ""); /** construct the path of the local dot directory that contains |