Debian Codegraph @

HercUtilities/GenericUtility.cpp

raw symbols SCIP
1 /*
2 * File: GenericUtility.h
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 26, 2010
6 *
7 * Copyright (c) 2010 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 "GenericUtility.h"cxx . . $ `<file>/HercUtilities/GenericUtility.h`/
26 #include "UtilityExecutor.h"cxx . . $ `<file>/HercUtilities/UtilityExecutor.h`/
27
28 #include <QMessageBox>
29 #include <QTimer>
30
31 GenericUtilitycxx . . $ GenericUtility#::GenericUtilitycxx . . $ GenericUtility#GenericUtility(c2ce7417dc68f8ba).(QStringcxx . . $ QString# name, QWidgetcxx . . $ QWidget# *parent) :
32 QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent),
33 mNamecxx . . $ GenericUtility#mName.(name),
34 mExecutorcxx . . $ GenericUtility#mExecutor.(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!),
35 mRunnercxx . . $ GenericUtility#mRunner.(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!),
36 mErrorRunnercxx . . $ GenericUtility#mErrorRunner.(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
37 {
38
39 }
40
41 GenericUtilitycxx . . $ GenericUtility#::~cxx . . $ GenericUtility#`~GenericUtility`(49f6e7a06ebc5aa8).GenericUtilitycxx . . $ GenericUtility#()
42 {
43 delete mRunnercxx . . $ GenericUtility#mRunner.;
44 delete mErrorRunnercxx . . $ GenericUtility#mErrorRunner.;
45 delete mExecutorcxx . . $ GenericUtility#mExecutor.;
46 }
47
48 bool GenericUtilitycxx . . $ GenericUtility#::runOrStopClickedcxx . . $ GenericUtility#runOrStopClicked(c9857a73d68e59ba).()
49 {
50 if (mExecutorcxx . . $ GenericUtility#mExecutor. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
51 {
52 mExecutorcxx . . $ GenericUtility#mExecutor.->terminatecxx . . $ UtilityExecutor#terminate(49f6e7a06ebc5aa8).();
53 mExecutorcxx . . $ GenericUtility#mExecutor. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
54 QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(21b6fd1dd558cc82).(this, mNamecxx . . $ GenericUtility#mName.,
55 mNamecxx . . $ GenericUtility#mName. +cxx . . $ operator+(3d22f08efddf8107)." operation was aborted at user's request",
56 QMessageBoxcxx . . $ QMessageBox#::Okcxx . . $ QMessageBox#Ok.,
57 QMessageBoxcxx . . $ QMessageBox#::NoButtoncxx . . $ QMessageBox#NoButton.);
58 return false;
59 }
60 else
61 {
62 return true;
63 }
64 }
65
66 int GenericUtilitycxx . . $ GenericUtility#::executecxx . . $ GenericUtility#execute(e5618828c763ae1e).(const stdcxx . . $ std/::stringcxx . . $ std/string# & command, const stdcxx . . $ std/::stringcxx . . $ std/string#& path, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>& parameters, const QStringcxx . . $ QString# &workingDirectory)
67 {
68 mStartedcxx . . $ GenericUtility#mStarted. = true;
69 mFinishedcxx . . $ GenericUtility#mFinished. = false;
70 parameters.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).("EXTERNALGUI"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
71
72 mExecutorcxx . . $ GenericUtility#mExecutor. = new UtilityExecutorcxx . . $ UtilityExecutor#UtilityExecutor(749de1b6ae65bddd).(this);
73 mRunnercxx . . $ GenericUtility#mRunner. = new UtilityRunnercxx . . $ UtilityRunner#UtilityRunner(fe7997c7923ebae2).(mExecutorcxx . . $ GenericUtility#mExecutor.);
74 mErrorRunnercxx . . $ GenericUtility#mErrorRunner. = new UtilityRunnercxx . . $ UtilityRunner#UtilityRunner(fe7997c7923ebae2).(mExecutorcxx . . $ GenericUtility#mExecutor.);
75 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! outputcxx . . $ GenericUtility#output(ddc4016aa177531b).(getFlatCommandcxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).(command,path,parameters).c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).());
76 int ret = mExecutorcxx . . $ GenericUtility#mExecutor.->runcxx . . $ UtilityExecutor#run(2ff047e9671f3437).(command, path, parameterscxx . . $ std/vector#vector(a1201200cf0efa42)., mRunnercxx . . $ GenericUtility#mRunner., mErrorRunnercxx . . $ GenericUtility#mErrorRunner., workingDirectory);
77
78 // do not wait forever
79 //QTimer::singleShot(2000, this, SLOT(timeout()));
80
81 // we should know if finished
82 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mExecutorcxx . . $ GenericUtility#mExecutor.->getQProcesscxx . . $ UtilityExecutor#getQProcess(54dfb229bc559d84).(),SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished(int,QProcess::ExitStatus)),this,SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(finished(int, QProcess::ExitStatus)));
83
84 // connect to default handlers (superclass can override these slots)
85 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mRunnercxx . . $ GenericUtility#mRunner., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(error(QByteArray)), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(runnerError(QByteArray)));
86 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mErrorRunnercxx . . $ GenericUtility#mErrorRunner., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(error(QByteArray)), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(runnerError(QByteArray)));
87
88 // general error status handler
89 connectcxx . . $ QObject#connect(158df1d9a01a3410).(this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(error()), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(errorSlot()));
90
91 return ret;
92 }
93
94 void GenericUtilitycxx . . $ GenericUtility#::timeoutcxx . . $ GenericUtility#timeout(49f6e7a06ebc5aa8).()
95 {
96 }
97
98 void GenericUtilitycxx . . $ GenericUtility#::finishedcxx . . $ GenericUtility#finished(15c350e1a5203cbf).(int result, QProcesscxx . . $ QProcess#::ExitStatuscxx . . $ QProcess#ExitStatus# status)
99 {
100 mFinishedcxx . . $ GenericUtility#mFinished. = true;
101 mRccxx . . $ GenericUtility#mRc. = result;
102 mFinishedOKcxx . . $ GenericUtility#mFinishedOK. = ( (status==QProcesscxx . . $ QProcess#::NormalExitcxx . . $ QProcess#NormalExit.) && (mRccxx . . $ GenericUtility#mRc. == 0) );
103 QByteArraycxx . . $ QByteArray# rcLine = mNamecxx . . $ QByteArray#QByteArray(45672f3c6961a244)..toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).() +cxx . . $ operator+(8f17b704cda0d21f). " ended; rc=";
104 rcLine +=cxx . . $ QByteArray#`operator+=`(827fa2bc2c144560). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(result);
105 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! outputcxx . . $ GenericUtility#output(ddc4016aa177531b).(rcLinecxx . . $ QByteArray#QByteArray(45672f3c6961a244).);
106 finishedSlotcxx . . $ GenericUtility#finishedSlot(49f6e7a06ebc5aa8).();
107 }
108
109 void GenericUtilitycxx . . $ GenericUtility#::errorSlotcxx . . $ GenericUtility#errorSlot(49f6e7a06ebc5aa8).()
110 {
111 QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(21b6fd1dd558cc82).(this, mNamecxx . . $ GenericUtility#mName.,
112 mNamecxx . . $ GenericUtility#mName. +cxx . . $ operator+(3d22f08efddf8107). " failed. Please check the log for details",
113 QMessageBoxcxx . . $ QMessageBox#::Okcxx . . $ QMessageBox#Ok.,
114 QMessageBoxcxx . . $ QMessageBox#::NoButtoncxx . . $ QMessageBox#NoButton.);
115 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
116 }
117
118 void GenericUtilitycxx . . $ GenericUtility#::runnerErrorcxx . . $ GenericUtility#runnerError(45672f3c6961a244).(const QByteArraycxx . . $ QByteArray#& line)
119 {
120 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! outputcxx . . $ GenericUtility#output(ddc4016aa177531b).(linecxx . . $ QByteArray#QByteArray(45672f3c6961a244).);
121 }
122
123 stdcxx . . $ std/::stringcxx . . $ std/string# GenericUtilitycxx . . $ GenericUtility#::getFlatCommandcxx . . $ GenericUtility#getFlatCommand(d005fb85d13f8245).(const stdcxx . . $ std/::stringcxx . . $ std/string# & command, const stdcxx . . $ std/::stringcxx . . $ std/string#& path, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#>& parameters)
124 {
125 stdcxx . . $ std/::stringcxx . . $ std/string# resultcxx . . $ std/__cxx11/basic_string#basic_string(49f6e7a06ebc5aa8).;
126 result =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). path;
127 if (path.sizecxx . . $ std/__cxx11/basic_string#size(48278e53df7b52a5).() > 0 ) result +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). "/";
128 result+=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75).command;
129 for (unsigned int i = 0;
130 i < parameters.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()-1;
131 i++)
132 {
133 result +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). " ";
134 result+=cxx . . $ std/__cxx11/basic_string#`operator+=`(c0b47be1fddc0e75).parameters[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).i];
135 }
136 return resultcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).;
137 }