Debian Codegraph @

HercUtilities/UtilityExecutor.cpp

raw symbols SCIP
1 /*
2 * File: UtilityExecutor.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "UtilityExecutor.h"cxx . . $ `<file>/HercUtilities/UtilityExecutor.h`/
26 #include "HerculesStudio.h"cxx . . $ `<file>/HercStudio/HerculesStudio.h`/
27 #include "UtilityRunner.h"cxx . . $ `<file>/HercUtilities/UtilityRunner.h`/
28
29 #include <QProcess>
30 #include <QString>
31 #include <QStringList>
32 #include <cerrno>
33 #include <cstdio>
34
35 UtilityExecutorcxx . . $ UtilityExecutor#::UtilityExecutorcxx . . $ UtilityExecutor#UtilityExecutor(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) :QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent)
36 {
37 mProcesscxx . . $ UtilityExecutor#mProcess. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
38 }
39
40 UtilityExecutorcxx . . $ UtilityExecutor#::~cxx . . $ UtilityExecutor#`~UtilityExecutor`(49f6e7a06ebc5aa8).UtilityExecutorcxx . . $ UtilityExecutor#()
41 {
42 }
43
44 //TODO convert all std::string parameters to QString
45 int UtilityExecutorcxx . . $ UtilityExecutor#::runcxx . . $ UtilityExecutor#run(2ff047e9671f3437).(const stdcxx . . $ std/::stringcxx . . $ std/string# & pCommand, const stdcxx . . $ std/::stringcxx . . $ std/string#& pPath, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> pParameters, UtilityRunnercxx . . $ UtilityRunner# * runner,
46 UtilityRunnercxx . . $ UtilityRunner# * errorRunner, const QStringcxx . . $ QString#& workingDirectory)
47 {
48 QStringcxx . . $ QString# programcxx . . $ QString#QString(e1217c004a86c950). = pPathcxx . . $ QString#QString(85c52e162fed56f9)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
49 if (pPath.sizecxx . . $ std/__cxx11/basic_string#size(48278e53df7b52a5).() > 0) program +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "/";
50 program +=cxx . . $ QString#`operator+=`(d02845eef0c33901). pCommand.c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
51 QStringListcxx . . $ QStringList# argumentscxx . . $ QStringList#QStringList(49f6e7a06ebc5aa8).;
52 for (unsigned int i=0; i<pParameters.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++)
53 {
54 arguments <<cxx . . $ QStringList#`operator<<`(85116071a693d053). pParameterscxx . . $ QString#QString(85c52e162fed56f9).[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).i].c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
55 }
56 mProcesscxx . . $ UtilityExecutor#mProcess. = new QProcesscxx . . $ QProcess#();
57 if (runner != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
58 {
59 runner->startcxx . . $ QThread#start(bd4fe741c868f69f).();
60 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mProcesscxx . . $ UtilityExecutor#mProcess.,
61 SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardOutput()),
62 runner,
63 SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(readStandardOutput()));
64 }
65 if (errorRunner != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
66 {
67 errorRunner->startcxx . . $ QThread#start(bd4fe741c868f69f).();
68 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mProcesscxx . . $ UtilityExecutor#mProcess.,
69 SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(readyReadStandardError()),
70 errorRunner,
71 SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(readStandardError()));
72 }
73 for (int i=0 ; i<arguments.sizecxx . . $ QList#size(455f465bc33b4cdf).(); i++)
74 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(1, " " << arguments.value(i).toStdString());
75 if (!workingDirectory.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).())
76 mProcesscxx . . $ UtilityExecutor#mProcess.->setWorkingDirectorycxx . . $ QProcess#setWorkingDirectory(3520e46b33348bf6).(workingDirectory);
77 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(1, mProcess->workingDirectory().toStdString());
78 mProcesscxx . . $ UtilityExecutor#mProcess.->startcxx . . $ QProcess#start(5e315ba9c811784d).(program,arguments);
79 Q_PIDcxx . . $ Q_PID# pid = mProcesscxx . . $ UtilityExecutor#mProcess.->pidcxx . . $ QProcess#pid(98833e9ab7de59a4).();
80
81 if (pid != 0)
82 return 0;
83 else
84 return -1;
85 }
86
87 bool UtilityExecutorcxx . . $ UtilityExecutor#::runningcxx . . $ UtilityExecutor#running(c9857a73d68e59ba).()
88 {
89 if (mProcesscxx . . $ UtilityExecutor#mProcess. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
90 return mProcesscxx . . $ UtilityExecutor#mProcess.->statecxx . . $ QProcess#state(12547b18370478e0).() == QProcesscxx . . $ QProcess#::Runningcxx . . $ QProcess#Running.;
91 else return false;
92
93 }
94
95 void UtilityExecutorcxx . . $ UtilityExecutor#::terminatecxx . . $ UtilityExecutor#terminate(49f6e7a06ebc5aa8).()
96 {
97 if (mProcesscxx . . $ UtilityExecutor#mProcess. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
98 {
99 //mProcess->close();
100 mProcesscxx . . $ UtilityExecutor#mProcess. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
101 }
102 }