32 #include <QMessageBox>
33 #include <QTextStream>
34 #include <QApplication>
48 CharonRun::~CharonRun() {
63 const bool debug =
true;
64 const QString privPathTag =
"privatePluginPathD";
66 const bool debug =
false;
67 const QString privPathTag =
"privatePluginPath";
71 const bool debug = settings.value(
"suffixedPlugins",
false).toBool();
72 const QString privPathTag = debug?
"privatePluginPathD":
"privatePluginPath";
75 QTextStream qout(stdout,QIODevice::WriteOnly);
77 << tr(
"%1 plugins with debug suffix")
78 .arg((debug?tr(
"prefering"):tr(
"ignoring"))) << endl;
81 QStringList libFilter;
82 libFilter <<
"*.dll" <<
"*.so" <<
"*.dylib";
83 QStringList excludeList = settings.value(
"excludeList").toStringList();
85 paths << settings.value(privPathTag).toStringList();
86 paths << settings.value(
"globalPluginPath").toStringList();
87 paths.removeDuplicates();
90 qout <<
"(II) " << tr(
"Paths:") << endl;
91 std::vector<std::string> pathsS, exclS;
92 QStringListIterator pathsIter(paths);
93 while (pathsIter.hasNext()) {
94 QDir curD(pathsIter.next());
95 QString cur = curD.canonicalPath();
98 qout <<
"(II) \t" << cur << endl;
99 pathsS.push_back(cur.toStdString());
101 QStringList libs = curD.entryList(libFilter);
102 QStringListIterator libsIter(libs);
103 while (libsIter.hasNext()) {
104 QFileInfo lin(libsIter.next());
105 QString lib = lin.completeBaseName();
106 lib.remove(QRegExp(
"_d$",Qt::CaseInsensitive));
108 lib.remove(QRegExp(
"^lib",Qt::CaseInsensitive));
110 QStringListIterator excludeListIter(excludeList);
111 while (excludeListIter.hasNext()) {
112 const QString ex = excludeListIter.next();
113 QRegExp rex(ex,Qt::CaseInsensitive,QRegExp::WildcardUnix);
114 if (rex.exactMatch(lib)) {
122 << tr(
"skipping non-existing path: %1").arg(cur) << endl;
126 exclExp.removeDuplicates();
127 qout <<
"(DD) " << tr(
"found excludes:") << endl;
128 foreach (QString exc, exclExp) {
129 qout <<
"(DD) \t" << exc << endl;
130 exclS.push_back(exc.toStdString());
132 qout <<
"(DD) " << endl;
134 PluginManagerInterface::PluginVersionCheckLevel versionCheck =
135 static_cast<PluginManagerInterface::PluginVersionCheckLevel
>(
136 settings.value(
"versionCheckLevel",2).toInt());
152 QTextStream qout(stdout);
156 QDir metaPath = fm.
configDir().absoluteFilePath(
"metadata");
157 QStringList wrpFiles = metaPath.entryList(
158 QStringList(
"*.wrp"), QDir::Files);
159 for (
int i=0; i < wrpFiles.size(); i++) {
160 Q_ASSERT(QFileInfo(metaPath.absoluteFilePath(wrpFiles[i])).
exists());
161 Q_ASSERT(QFileInfo(metaPath.absoluteFilePath(wrpFiles[i])).isFile());
162 Q_ASSERT(wrpFiles[i].contains(QRegExp(
".*\\.wrp$")));
166 metaPath.remove(wrpFiles[i]);
172 catch(std::exception& err)
174 qout <<
"(EE) Could not set up PluginManager: " << err.what() <<
"\n"
175 <<
"(EE) Please check that your local and global plugin paths "
176 <<
"are set correctly in the options menu." << endl ;
183 wrpFiles = metaPath.entryList(QStringList(
"*.wrp"), QDir::Files);
185 if (wrpFiles.isEmpty()) {
189 qout <<
"(EE) No Plugins found!\n"
190 <<
"(EE) Please check that your local and global plugin paths "
191 <<
"are set correctly in the options menu." << endl ;
196 if (!cFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
197 QMessageBox::warning(
199 tr(
"could not open classes file for writing"));
202 QTextStream cStream(&cFile);
203 Q_ASSERT(cStream.status() == QTextStream::Ok);
204 cStream <<
"# Tuchulcha class information file\n";
205 cStream <<
"# Content is copied from files in metadata directory\n";
206 cStream <<
"# This is generated during update plugins,\n";
207 cStream <<
"# do not edit by hand!" << endl;
209 for(
int i=0; i<wrpFiles.size(); i++) {
210 QFile cur(metaPath.absoluteFilePath(wrpFiles[i]));
211 cur.open(QIODevice::ReadOnly | QIODevice::Text);
212 QString content = cur.readAll();
214 cStream << tr(
"\n# from file \"%1\":\n").arg(wrpFiles[i]);
215 cStream << content << endl;
223 QTextStream qout(stdout);
227 fName = QFileInfo(fName).absoluteFilePath();
228 QDir::setCurrent(QFileInfo(fName).path());
231 qout << tr(
"Loading parameter file \"%1\"").arg(fName) << endl;
234 qout << tr(
"== Executing Workflow ==") << endl;
235 const QDateTime& startTime = QDateTime::currentDateTime();
236 qout << tr(
"start time: %1").arg(startTime.toString(Qt::ISODate))
239 const QDateTime& endTime = QDateTime::currentDateTime();
240 QTime runTime = QTime().addSecs(startTime.secsTo(endTime));
242 qout << tr(
"Execution finished.") <<
"\n";
243 qout << tr(
"end time : %1").arg(endTime.toString(Qt::ISODate)) << endl;
244 qout << tr(
"runtime : %1").arg(
245 runTime.toString(
"hh:mm:ss.zzz")) << endl;
247 catch (
const std::string& msg) {
249 tr(
"Caught exception of type \"std::string\".")
250 +
"\n\n"+tr(
"Message:")+
"\n"+msg.c_str();
252 catch (
const std::exception& excpt) {
253 const char* name =
typeid(excpt).name();
255 name = abi::__cxa_demangle(name, 0, 0, 0);
258 tr(
"Caught exception of type \"%1\".").arg(name)
259 +
"\n\n"+tr(
"Message:")+
"\n"+excpt.what();
261 catch (
const char* &msg) {
263 tr(
"Caught exception of type \"char*\".")
264 +
"\n\n"+tr(
"Message:")+
"\n" + msg;
267 errorMsg = tr(
"Caught exception of unknown type.");
269 if (!errorMsg.isEmpty()) {
270 QTextStream qerr(stderr);
271 qerr <<
"\n****************************************************\n\n"
272 << tr(
"Error during execution:") <<
"\n\n"
273 << errorMsg <<
"\n\n"
274 <<
"****************************************************"
293 QApplication::exit();
299 QString baseN = QFileInfo(fName).baseName();
303 QDir dynamPath = fm.
configDir().absoluteFilePath(
"dynamics");
304 if (dynamPath.exists()) {
305 QStringList wrpFiles = dynamPath.entryList(
306 QStringList(
"*.wrp"), QDir::Files);
307 wrpFiles = wrpFiles.filter(QRegExp(
"^" + baseN +
"_"));
308 for (
int i=0; i < wrpFiles.size(); i++) {
309 Q_ASSERT(QFileInfo(dynamPath.absoluteFilePath(wrpFiles[i])).
exists());
310 Q_ASSERT(QFileInfo(dynamPath.absoluteFilePath(wrpFiles[i])).isFile());
311 Q_ASSERT(wrpFiles[i].indexOf(
".wrp") > 0);
312 dynamPath.remove(wrpFiles[i]);
313 Q_ASSERT(!QFileInfo(wrpFiles[i]).
exists());
316 Q_ASSERT(fm.
configDir().mkdir(
"dynamics"));
321 dynamPath.absoluteFilePath(baseN).toStdString());
330 QTextStream qout(stdout,QIODevice::WriteOnly);
331 qout <<
"(DD) " << tr(
"path settings seem to be ok, keeping them")
339 QString globalPath =
"/usr/lib/charon-plugins";
343 QString globalPath = QCoreApplication::applicationDirPath();
347 settings.setValue(
"globalPluginPath", globalPath);
348 settings.setValue(
"privatePluginPath",QString());
349 settings.setValue(
"privatePluginPathD",QString());
Declaration of class FileManager.
void setupSettings()
setup settings
void busy()
signal to avoid new command prompt
PluginManager * _man
plugin manager
void updatePlugins()
update plugin information
static const FileManager & instance()
get a reference to the file Manager instance
static QWidget * dialogParent
parent widget for operation result dialogs
charon_core_DLL_PUBLIC SplitStream sout
QDir configDir() const
get config directory
CharonRun(QObject *parent=0)
constructor
void createMetadata(const std::string &targetPath="")
Common config file information and handling.
QString classesFile() const
get the path of the classes file
Declaration of class OptionsDialog.
void exitWhenFinished()
unlock exiting, quit application if all tasks are completed
void setExcludeList(const std::vector< std::string > &list)
void updateDynamics(QString fName)
update dynamic plugins of given workflow file
void _setupMan()
setup plugin manager
Declaration of class CharonRun.
void ready()
show that running tasks are complete
void _taskFinished()
decrease task counter
void runWorkflow(QString fName)
run given workflow file
void _taskStart()
increase task counter
void _freeMan()
release plugin manager
void createDynamicMetadata(const ParameterFile ¶mFile, const std::string &filePrefix)
static bool check()
Configures plugin paths.
void loadParameterFile(const ParameterFile &pf)