moved musrWiz.log to /home/suter_a/.musrfit/musredit

This commit is contained in:
suter_a 2017-04-03 18:17:38 +02:00
parent f906c81448
commit 9cad7580b7
2 changed files with 3246 additions and 3232 deletions

View File

@ -1,138 +1,140 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <QApplication> #include <QApplication>
#include <QProcess> #include <QProcess>
#include <QMessageBox> #include <QMessageBox>
#include <QObject> #include <QObject>
#include "git-revision.h" #include "git-revision.h"
#include "musrWiz.h" #include "musrWiz.h"
#include "PAdmin.h" #include "PAdmin.h"
#include "PMusrWiz.h" #include "PMusrWiz.h"
//------------------------------------------------------------------- //-------------------------------------------------------------------
/** /**
* *
*/ */
void PParam::init() void PParam::init()
{ {
fName = QString("UnDef"); fName = QString("UnDef");
fNumber = -1; fNumber = -1;
fValue = 0.0; fValue = 0.0;
fStep = 0.0; fStep = 0.0;
fPosErr = QString("UnDef"); fPosErr = QString("UnDef");
fBoundLow = QString("UnDef"); fBoundLow = QString("UnDef");
fBoundHigh = QString("UnDef"); fBoundHigh = QString("UnDef");
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
/** /**
* *
*/ */
void musrWiz_syntax() void musrWiz_syntax()
{ {
std::cout << "usage: musrWiz [[--version | -v] | --debug [0|1|2] | --help]" << std::endl << std::endl; std::cout << "usage: musrWiz [[--version | -v] | --debug [0|1|2] | --help]" << std::endl << std::endl;
std::cout << " --version | -v : print current git-version." << std::endl; std::cout << " --version | -v : print current git-version." << std::endl;
std::cout << " --debug 0 : dump's the instrument definition(s) at startup." << std::endl; std::cout << " --debug 0 : dump's the instrument definition(s) at startup." << std::endl;
std::cout << " --debug 1 : dump's the musrfit functions at startup." << std::endl; std::cout << " --debug 1 : dump's the musrfit functions at startup." << std::endl;
std::cout << " --debug 2 : dump's the musrfit functions and instrument definition(s) at startup." << std::endl; std::cout << " --debug 2 : dump's the musrfit functions and instrument definition(s) at startup." << std::endl;
std::cout << " --log : writes a log-file '.musrWiz.log' which contains the path-file-name of" << std::endl; std::cout << " --log : writes a log-file 'musrWiz.log' which contains the path-file-name of" << std::endl;
std::cout << " the created msr-file." << std::endl; std::cout << " the created msr-file." << std::endl;
std::cout << " --help : shows this help." << std::endl << std::endl; std::cout << " --help : shows this help." << std::endl << std::endl;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
/** /**
* *
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int dump = -1; int dump = -1;
bool logFile = false; bool logFile = false;
if (argc == 2) { if (argc == 2) {
if (!strcmp(argv[1], "--version") || (!strcmp(argv[1], "-v"))) { if (!strcmp(argv[1], "--version") || (!strcmp(argv[1], "-v"))) {
std::cout << std::endl << "musrWiz - alpha - git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl; std::cout << std::endl << "musrWiz - alpha - git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
return 0; return 0;
} else if (!strcmp(argv[1], "--help")) { } else if (!strcmp(argv[1], "--help")) {
musrWiz_syntax(); musrWiz_syntax();
return 0; return 0;
} else if (!strcmp(argv[1], "--log")) { // thought to be used from within musredit only } else if (!strcmp(argv[1], "--log")) { // thought to be used from within musredit only
logFile = true; logFile = true;
} else { } else {
musrWiz_syntax(); musrWiz_syntax();
return 0; return 0;
} }
} else if (argc == 3) { } else if (argc == 3) {
dump = atoi(argv[2]); dump = atoi(argv[2]);
if ((dump < 0) || (dump > 2)) { if ((dump < 0) || (dump > 2)) {
musrWiz_syntax(); musrWiz_syntax();
return 0; return 0;
} }
} }
Q_INIT_RESOURCE(musrWiz); Q_INIT_RESOURCE(musrWiz);
QApplication app(argc, argv); QApplication app(argc, argv);
PAdmin *admin = new PAdmin(); PAdmin *admin = new PAdmin();
if (!admin->IsValid()) { if (!admin->IsValid()) {
delete admin; delete admin;
return 1; return 1;
} }
admin->dump(dump); admin->dump(dump);
PMsrData *info = new PMsrData(); // this content will eventually be set by the xml-handler PMsrData *info = new PMsrData(); // this content will eventually be set by the xml-handler
PMusrWiz wizard(admin, info); PMusrWiz wizard(admin, info);
wizard.show(); wizard.show();
app.exec(); app.exec();
int result = wizard.result(); int result = wizard.result();
if (result == 1) { // if everything went fine up to this point if (result == 1) { // if everything went fine up to this point
// check if a log-file shall be written // check if a log-file shall be written
if (logFile) { QProcessEnvironment procEnv = QProcessEnvironment::systemEnvironment();
std::ofstream fout(".musrWiz.log", std::ofstream::out); QString pathName = procEnv.value("HOME", "");
fout << "path-file-name: " << info->getMsrPathName().toLatin1().data() << "/" << info->getMsrFileName().toLatin1().data() << std::endl; pathName += "/.musrfit/musredit/musrWiz.log";
fout.close(); if (logFile) {
} std::ofstream fout(pathName.toLatin1().data(), std::ofstream::out);
fout << "path-file-name: " << info->getMsrPathName().toLatin1().data() << "/" << info->getMsrFileName().toLatin1().data() << std::endl;
// check if musrt0 shall be called. If the option --log is set, only add musrt0 flag to in the .musrWiz.log file fout.close();
if (info->getT0Tag() == T0_FROM_MUSR_T0) { }
if (logFile) {
std::ofstream fout(".musrWiz.log", std::ofstream::app); // check if musrt0 shall be called. If the option --log is set, only add musrt0 flag to in the musrWiz.log file
fout << "musrt0-tag: yes" << std::endl; if (info->getT0Tag() == T0_FROM_MUSR_T0) {
fout.close(); if (logFile) {
} else { std::ofstream fout(pathName.toLatin1().data(), std::ofstream::app);
QProcessEnvironment pe = QProcessEnvironment::systemEnvironment(); fout << "musrt0-tag: yes" << std::endl;
QString musrt0Path = pe.value("MUSRFITPATH", "??"); fout.close();
if (musrt0Path == "??") { // not found hence try ROOTSYS } else {
musrt0Path = pe.value("ROOTSYS", "??"); QString musrt0Path = procEnv.value("MUSRFITPATH", "??");
if (musrt0Path != "??") { if (musrt0Path == "??") { // not found hence try ROOTSYS
musrt0Path += "/bin"; musrt0Path = procEnv.value("ROOTSYS", "??");
} if (musrt0Path != "??") {
} musrt0Path += "/bin";
}
if (musrt0Path != "??") { }
QString musrt0 = musrt0Path + "/musrt0";
QString pathFln = QString("%1/%2").arg(info->getMsrPathName()).arg(info->getMsrFileName()); if (musrt0Path != "??") {
QStringList arguments; QString musrt0 = musrt0Path + "/musrt0";
arguments << pathFln; QString pathFln = QString("%1/%2").arg(info->getMsrPathName()).arg(info->getMsrFileName());
QProcess::startDetached(musrt0, arguments, "./"); QStringList arguments;
} else { arguments << pathFln;
QMessageBox::warning(0, "WARNING", "Couldn't find musrt0 :-(.\n Only the msr-file has been generated."); QProcess::startDetached(musrt0, arguments, "./");
} } else {
} QMessageBox::warning(0, "WARNING", "Couldn't find musrt0 :-(.\n Only the msr-file has been generated.");
} }
} }
}
if (info) }
delete info;
if (admin) if (info)
delete admin; delete info;
if (admin)
return result; delete admin;
}
return result;
}

File diff suppressed because it is too large Load Diff