29 #include <QLocalServer> 30 #include <QLocalSocket> 53 void ProgramLauncher::RunIsisProgram(QString programName,
56 FileName isisExecutableFileName(
"$ISISROOT/bin/" + program.
name());
57 bool isIsisProgram =
false;
59 if(isisExecutableFileName.fileExists()) {
61 program = isisExecutableFileName;
64 QString command = program.
expanded() +
" " + parameters +
68 QString msg =
"Program [" + programName +
"] does not appear to be a " 69 "valid Isis 3 program";
73 QString serverName =
"isis_" + Application::UserName() +
77 server.listen(serverName);
79 QProcess childProcess;
80 childProcess.setProcessChannelMode(QProcess::ForwardedChannels);
81 childProcess.start(command);
82 childProcess.waitForStarted();
84 bool connected =
false;
86 while(!connected && childProcess.state() != QProcess::NotRunning) {
89 connected = server.waitForNewConnection(30000);
90 childProcess.waitForFinished(100);
94 QString msg =
"Isis child process failed to communicate with parent";
98 QLocalSocket *childSocket = server.nextPendingConnection();
102 while(childSocket->state() != QLocalSocket::UnconnectedState) {
103 bool insideCode =
true;
104 bool messageDone =
false;
110 if(childSocket->waitForReadyRead(1000)) {
111 lineData = childSocket->read(childSocket->bytesAvailable());
113 for(
int i = 0; i < lineData.size(); i++) {
115 if(lineData[i] != (
char)27) {
123 if(lineData[i] != (
char)27) {
124 message += lineData[i];
135 ProcessIsisMessageFromChild(code, message));
144 childProcess.waitForFinished();
146 if(childProcess.exitCode() != 0) {
147 QString msg =
"Running Isis program [" + programName +
"] failed with " 148 "return status [" +
toString(childProcess.exitCode()) +
"]";
165 ProgramLauncher::ProcessIsisMessageFromChild(QString code, QString msg) {
168 if(code ==
"PROGRESSTEXT" && iApp) {
171 else if(code ==
"PROGRESS" && iApp) {
174 else if(code ==
"LOG" && iApp) {
175 stringstream msgStream;
180 if(logPvl.groups() == 1 &&
181 logPvl.keywords() == 0 &&
182 logPvl.objects() == 0) {
183 iApp->
Log(logPvl.group(0));
186 else if(code ==
"GUILOG" && iApp) {
189 else if(code ==
"ERROR") {
190 stringstream msgStream;
193 msgStream >> errorPvl;
195 for(
int i = 0; i < errorPvl.groups(); i++) {
197 QString eclass = g[
"Class"];
198 QString emsg = g[
"Message"];
199 int ecode = g[
"Code"];
200 QString efile = g[
"File"];
201 int eline = g[
"Line"];
223 void ProgramLauncher::RunSystemCommand(QString fullCommand) {
224 int status = system(fullCommand.toLatin1().data());
227 QString msg =
"Executing command [" + fullCommand +
228 "] failed with return status [" +
toString(status) +
"]";
File name manipulation and expansion.
int toInt(const QString &string)
Global function to convert from a string to an integer.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Namespace for the standard library.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
static void GuiLog(const Pvl &results)
Writes the Pvl results to the sessionlog, but not to the printfile.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
static void Log(PvlGroup &results)
Writes Pvl results to sessionlog and printfile.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Container for cube-like labels.
ErrorType
Contains a set of exception error types.
Namespace for ISIS/Bullet specific routines.
void UpdateProgress(const QString &text, bool print)
Updates the progress bar in the gui.