Example #1
1
int FileEnvProcess::execute(const QString& program, const QStringList& arguments)
{
    QByteArray programBa = program.toLatin1();
    const char* programCharPtr = programBa.data();
    
    QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
    QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
    tmpRideFilePtr->open(QIODevice::WriteOnly);
    
    addHeader(tmpRideFilePtr);
    tmpRideFilePtr->write(programCharPtr);
    
    QByteArray tmpByteArray;
    for(size_t i = 0; i < arguments.size(); i++)
    {
        tmpByteArray.append(arguments.at(i) + "\n");
        tmpRideFilePtr->write(tmpByteArray);
        tmpByteArray.clear();
    }
    
    tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
    tmpRideFilePtr->write("\necho \"Finished execution.\"");
    tmpRideFilePtr->close();
    
    QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
    QProcess qprocess;
    qprocess.execute("chmod", stringlst);
    
    return qprocess.execute(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
}
Example #2
0
bool classepub::ebubUnzip(QString fileName)
{
  //  QDir::homePath()+"/.kirtasse/download"
    QDir dir;

               QString pathToExtract=QDir::homePath()+"/.kirtasse/download/epub";
   dir.mkdir(pathToExtract);
  QProcess prosses;

    if (dir.exists(pathToExtract)) //التاكد من وجود مجلد المؤقت
    {
        prosses.execute("rm -r  "+pathToExtract);
       prosses.waitForFinished();

    }

   //dir.mkdir(pathToExtract);

//     prosses.execute("unzip  \""+fileName+"\" -d  "+pathToExtract);
    if(QFile::exists("/usr/bin/7z")){
         prosses.execute("7z x  \""+fileName+"\" -o"+pathToExtract);
    }else if(QFile::exists("/usr/bin/unzip")){
       prosses.execute("unzip  \""+fileName+"\" -d  "+pathToExtract);
    }else{
        QMessageBox::information(0,"","please install 7z or unzip ");
    }



    prosses.waitForFinished();
    ebubOpenContainer(QDir::homePath()+"/.kirtasse/download/epub");
    curentPage=1;

    return true;
}
Example #3
0
bool MTFile::copy(QString dest)
{
    QFileInfo dest_fi(dest);
    if (!dest_fi.dir().exists()) {
        QDir().mkpath(dest_fi.dir().absolutePath());
    }
#ifndef USE_UNIX_TOUCH_COMMAND
#ifndef Q_WS_MAC

    return this->QFile::copy(dest);

#endif
#else

	bool ok = false;
	if (QFile::symLinkTarget(fileName()).isEmpty()) { ok = this->QFile::copy(dest); }
	else {
		QStringList arguments; QProcess cp;
		arguments << "-R" << fileName() << dest;
		ok = cp.execute("cp", arguments) == 0;
	}
	if (ok) {
		QStringList arguments; QProcess touch;
		arguments << "-cf" << "-r" << fileName() << dest;
		if (touch.execute("touch", arguments) != 0) { return false; }
        return QFileInfo(fileName()).lastModified() == dest_fi.lastModified();
	} else { return false; }
	return false;

#endif
}
Example #4
0
int FileEnvProcess::execute(const QString& program)
{
    QByteArray programBa = program.toLatin1();
    const char* programCharPtr = programBa.data();
    
    QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
    QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
    tmpRideFilePtr->open(QIODevice::WriteOnly);

    addHeader(tmpRideFilePtr);
    tmpRideFilePtr->write(programCharPtr);
    tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
    tmpRideFilePtr->write("\necho \"Finished execution.\"");
    tmpRideFilePtr->close();

    QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
    QProcess qprocess;
    qprocess.execute("chmod", stringlst);
    
    int rtn = qprocess.execute(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
    QByteArray output = qprocess.readAllStandardOutput();
    cout << cct::bold("\nOutput: ") << output.data() << endl;
    
    return rtn;
}
Example #5
0
void
SpotifyAccount::killExistingResolvers()
{
    QProcess p;
#if defined(Q_OS_UNIX)
    const int ret = p.execute( "killall -9 spotify_tomahawkresolver" );
    qDebug() << "Tried to killall -9 spotify_tomahawkresolver with return code:" << ret;
#elif defined(Q_OS_WIN)
    const int ret = p.execute( "taskkill.exe /F /im spotify_tomahawkresolver.exe" );
    qDebug() << "Tried to taskkill.exe /F /im spotify_tomahawkresolver.exe with return code:" << ret;
#endif
}
Example #6
0
void OOoReportBuilder::saveReport()
{
    m_readyReportFile.clear();

    QFile file(m_filename);
    QFileInfo info(file);
    QString newFile = m_outputDir + "\\" + info.baseName() + QString("_gen%1.%2")
            .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"))
            .arg(info.completeSuffix());
    if (!file.copy(newFile)) {
        QMessageBox::critical(QApplication::activeWindow(),
                              "saveReport",tr("Can't copy file! "));
        return;
    }

    m_readyReportFile = newFile;

    QStringList args;
    args << "a" << newFile
         << m_outputDir + "\\content.xml";

    QProcess *arh = new QProcess();

    arh->execute("7z", args);

    QFile f(m_outputDir + "\\content.xml");
    f.remove();
}
Example #7
0
bool MTFile::openAndTouch(QString other_path)
{
#ifdef Q_WS_WIN
    //touch.setWorkingDirectory(QFileInfo(app->arguments().at(0)).absolutePath());
    HANDLE in = CreateFileW(other_path.replace('/', '\\').toStdWString().c_str(),
                               GENERIC_READ,
                               FILE_SHARE_READ,
                               NULL,
                               OPEN_EXISTING,
                               FILE_ATTRIBUTE_NORMAL,
                               NULL);
    FILETIME time;
    GetFileTime(in, NULL, NULL, &time);
    CloseHandle(in);
    HANDLE out = CreateFileW(fileName().replace('/', '\\').toStdWString().c_str(),
                               GENERIC_WRITE,
                               FILE_SHARE_READ,
                               NULL,
                               OPEN_ALWAYS,
                               FILE_ATTRIBUTE_NORMAL,
                               NULL);
    SetFileTime(out, NULL, NULL, &time);
    CloseHandle(out);
    return true;
#endif
    if (!exists()) {
        if (!open(QIODevice::ReadWrite)) return false;
    }
    QStringList arguments; QProcess touch;
    arguments << "-cf" << "-r" << "\"" + other_path + "\"" << "\"" + fileName() + "\"";
    if (touch.execute("touch", arguments) == 0) {
        return true;
    } else { return false; }
    return false;
}
void MainWindow::setInitialUiState()
{
    ui->mxfSoundRadio2->setChecked(1);

    // set initial screen indexes
    j2kSetStereoscopicState();
    mxfSetStereoscopicState();
    mxfSetHVState();
    mxfSetSoundState();
    mxfSetSlideState();

    // Check For Kakadu
    QProcess *kdu;
    kdu = new QProcess(this);
    int exitCode = kdu->execute("kdu_compress", QStringList() << "-version");
    if (exitCode) {
        int value = ui->encoderComboBox->findText("Kakadu");
        ui->encoderComboBox->removeItem(value);
    }
    delete kdu;

    // Set thread count
#ifdef Q_OS_WIN32
    ui->threadsSpinBox->setMaximum(6);
#endif
    ui->threadsSpinBox->setMaximum(QThreadPool::globalInstance()->maxThreadCount());
    ui->threadsSpinBox->setValue(QThread::idealThreadCount());

    ui->mxfSourceTypeComboBox->setCurrentIndex(0);
    ui->mxfInputStack->setCurrentIndex(0);
    ui->mxfTypeComboBox->setCurrentIndex(1);
    ui->tabWidget->setCurrentIndex(0);
}
Example #9
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QTextCodec* codec = QTextCodec::codecForName("CP1251");
    QTextCodec::setCodecForLocale(codec);

    if(argc == 6) {
        QString prog_name = argv[5];

        QString update_command = QString("%1 %2 %3%4 ").arg(argv[1]).arg(argv[2]).arg(argv[3]).arg(QDir::toNativeSeparators(argv[4]));

        QProcess *vec = new QProcess;

        qDebug() << "Update application...";

        int res = vec->execute(update_command);
        //TODO:
        //Message Box with warning of fault update process if res != 0
        // -2 = нет файла обновления

        qDebug() << "Restart programm...";
        vec->startDetached(prog_name);
        delete vec;

        return 0;
    }

    return a.exec();
}
bool CalculateVelocityHandler::GenTimeGrid(float &p_wave, float &s_wave, int channel_id)
{
    if (pickinfo_list_.count() == 0)
    {
        return false;
    }
    if (!GenTimeGridInfoFile(p_wave, s_wave, channel_id) || !GenObsFile(pickinfo_list_.at(0).event_id))
    {
        return false;
    }


    QStringList arguments;
    arguments <<"TimegridInfo" <<"locPar" <<"obs";
    QProcess proc;

    int ret = proc.execute("./genTimeGrid", arguments);

    if ((ret == -1)||(ret == -2))
    {
        return false;
    }

    return true;
}
Example #11
0
bool PHIApplication::startPhisService()
{
    qWarning() << "phiapp start" << _serverBin;
#ifdef PHIEMBEDEDSERVER
    return false;
#else
    if ( !QFile::exists( _serverBin ) ) return false;
    qWarning() << "phiapp start" << _serverBin;
    QProcess proc;
#ifdef Q_OS_WIN
    proc.execute( _serverBin, QStringList() << L1( "-i" ) );
#endif
    if ( proc.execute( _serverBin, QStringList() )!=0 ) return false;
    return true;
#endif
}
Example #12
0
bool Parse::getScopeAndLocals(Scope * sc, const QString &expr, const QString &ident)
{
	// initialize scope if nothing better is found
	sc->scope = "";
	sc->localdef = "";

	/* create a tags file for `expr' with function names only.
	 * The function with the highest line number is our valid scope
	 * --sort=no, because tags generation probably faster, and
	 * so I just have to look for the last entry to find 'my' tag
	 */

	QString command =
	    ctagsCmdPath +
	    " --language-force=c++ --sort=no --fields=fKmnsz --c++-kinds=fn -o \"" +
	    smallTagsFilePath + "\" \"" + parsedFilePath + '\"';

	// I don't process any user input, so system() should be safe enough
	QProcess ctags;
	ctags.execute(command);
	QFile::remove (parsedFilePath);
	if (ctags.exitStatus() == QProcess::CrashExit)
		return false;

	/* find the last entry, this is our current scope */
	tagFileInfo info;
	tagFile *tfile = tagsOpen(smallTagsFilePath.toAscii(), &info);
	tagEntry entry;
	const char *scope = NULL;
	if (tfile && info.status.opened)
	{
		if (tagsFirst(tfile, &entry) == TagSuccess)
		{
			do
				scope = tagsField(&entry, "class");
			while (tagsNext(tfile, &entry) == TagSuccess);
		}
		tagsClose(tfile);
	}

	/* must be before the 'type = extract_type_qualifier()' code, which modifies scope */
	if (scope)
		sc->scope = scope;

	/* get local definition (if any) */
	if (ident!="")
	{
		QString type = extractTypeQualifier(expr, ident);
		if (type.length())
		{
			sc->localdef = type;
		}
		else
			sc->localdef = "";
	}

	QFile::remove (smallTagsFilePath);
	
	return true;
}
Example #13
0
void MainWindow::setInitialUiState()
{
    ui->mxfSoundRadio2->setChecked(1);

    // set initial screen indexes
    j2kSetStereoscopicState();
    mxfSetStereoscopicState();
    mxfSetInitialState();

    // add encoders
    ui->encoderComboBox->addItem("OpenJPEG", QVariant(OPENDCP_ENCODER_OPENJPEG));
    #ifdef HAVE_RAGNAROK
    ui->encoderComboBox->addItem("Ragnarok", QVariant(OPENDCP_ENCODER_RAGNAROK));
    #endif
    QProcess *kdu;
    kdu = new QProcess(this);
    int exitCode = kdu->execute("kdu_compress", QStringList() << "-version");
    if (!exitCode) {
        ui->encoderComboBox->addItem("Kakadu", QVariant(OPENDCP_ENCODER_KAKADU));
    }
    delete kdu;
  

    // Set thread count
#ifdef Q_OS_WIN32
    ui->threadsSpinBox->setMaximum(6);
#endif
    ui->threadsSpinBox->setMaximum(QThreadPool::globalInstance()->maxThreadCount());
    ui->threadsSpinBox->setValue(QThread::idealThreadCount());

    ui->mxfSourceTypeComboBox->setCurrentIndex(0);
    ui->mxfInputStack->setCurrentIndex(0);
    ui->mxfTypeComboBox->setCurrentIndex(1);
    ui->tabWidget->setCurrentIndex(0);
}
Example #14
0
bool checkForUpdates(QString path) {
    QProcess updater;
    QStringList args = QStringList() << "-quickcheck" << "-justcheck";

    int exit = updater.execute(path+"/wyUpdate", args);

    return exit == 2;
}
Example #15
0
void MimeTypeWriter::runUpdateMimeDatabase()
{
    const QString localPackageDir = KStandardDirs::locateLocal("xdgdata-mime", QString());
    Q_ASSERT(!localPackageDir.isEmpty());
    QProcess proc;
    if (!proc.execute("update-mime-database", QStringList() << localPackageDir)) {
        kWarning() << "update-mime-database exited with error code" << proc.exitCode();
    }
}
Example #16
0
/** Ejecuta la linea que le pasemos*/
int GsRenderEngine::executeCommand(const QString &d){
    int rtn=-1;
    QProcess convertgs;
    if (testGsInstallation()){
        m_command=QString("%1 %2").arg(m_strExecutable).arg(d);
        rtn=convertgs.execute(m_command);
    }
    return rtn;
}
Example #17
0
void MainWindow::on_Send_Eq_clicked()
{
    QString program = "/home/franz/altera/Interface/cgi_medipix/Interface_QT/Morpheus/Morpheus/send_eq";
    QStringList arguments;

    QProcess *myProcess = new QProcess(this);
    myProcess->execute(program,arguments);
    QThread::sleep(1);
    ui->ready_bar->setValue(100);
}
void EmulibMain::on_gamesTable_doubleClicked(const QModelIndex &index)
{
    QProcess process;
    QString fceux = "C:/wamp64/www/emulib_client/fceux/fceux.exe";
    QStringList args;
    args += "-lua";
    args += "c:/wamp64/www/emulib_client/lua/smb3test.lua";
    args += "c:/wamp64/www/emulib_client/roms/smb3.nes";
    process.execute(fceux,args);
}
Example #19
0
bool PHIApplication::stopPhisService()
{
#ifdef PHIEMBEDEDSERVER
    return false;
#else
    if ( !QFile::exists( _serverBin ) ) return false;
    QProcess proc;
    if ( proc.execute( _serverBin, QStringList() << L1( "-t" ) )!=0 ) return false;
    return true;
#endif
}
Example #20
0
void InstallerForm::processFile()
{
    ui->label->setText(tr("unpacking downloaded file"));
    QProcess sc;
    sc.execute("tar -xf "+downloadPath+" -C "+QDir::homePath());
    sc.waitForFinished();

    sc.startDetached("rm -f "+ downloadPath);

    runConfiguration();
}
Example #21
0
bool PHIApplication::clearPhisServiceCache()
{
#ifdef PHIEMBEDEDSERVER
    return false;
#else
    if ( !QFile::exists( _serverBin ) ) return false;
    QProcess proc;
    int res=proc.execute( _serverBin, QStringList() << QStringLiteral( "-c" ) );
    if ( res ) return false;
    return true;
#endif
}
Example #22
0
void runProgram(QString path, QString args) {
    QProcess proc;
    QStringList largs;
    QFileInfo info(path);


    if (path.contains("%")) {
	path.replace("%u", args);
	path.replace("%U", args);
	path.replace("%f", args);
	path.replace("%F", args);
	path.replace("%c", path.split(" ")[0]);
	path.replace("%k", path.split(" ")[0]);
	args = "";
    } 

    QString toRun = path + " " + args;
    toRun = toRun.simplified();
    






    QString r;

    //    r = "xdg-open \"" + path + "\" " + args + " 2>/dev/null || sh -c \"" + path + "\" " + args;

    r = "xdg-open \"" + path.trimmed() + "\" " + args.trimmed() + " 2>/dev/null || sh -c \"" + path.trimmed() + " "  + args + "\"";


    //    qDebug() << r.simplified();
    QStringList ra;

    ra += "-c";
    ra += r.trimmed().simplified();
    //    qDebug() << ra;

    // Firefox needs special treatment in KDE
    // else it falls behind a window
    if ((path.contains("http://",Qt::CaseInsensitive) ||
	 path.contains("firefox",Qt::CaseInsensitive)) &&
	getDesktop() == DESKTOP_KDE) {
	proc.execute("sh",ra);
    } else {
	proc.startDetached("sh",ra);
    }

    //proc.execute("sh", ra);
    
    return;
}
Example #23
0
void ScreenLockerKcm::test(const QString &plugin)
{
    if (plugin.isEmpty() || plugin == QLatin1String("none")) {
        return;
    }

    QProcess proc;
    QStringList arguments;
    arguments << plugin << QStringLiteral("--testing");
    if (proc.execute(KSCREENLOCKER_GREET_BIN, arguments)) {
        QMessageBox::critical(this, i18n("Error"), i18n("Failed to successfully test the screen locker."));
    }
}
Example #24
0
/** Genear y ejecuta el comando*/
int GsRenderEngine::render(){
    int rtn=-1;
    QFileInfo info(m_strInputFile);
    QString suffix=info.completeSuffix();
    //Si es un pdf procedo como siempre a renderizar
    if (!suffix.compare("pdf",Qt::CaseInsensitive)){
        if (testGsInstallation()){
            QString tmp=m_strOutputFile;
            if (m_doubleRes){ //Si es con doble resolucion, lo hago en dos pasos
                QFile::remove(TEMP_GS_FILE);
                m_strOutputFile=TEMP_GS_FILE;
            }
            m_command=QString("\"%1\" -sOutputFile=\"%2\" -r%3 -sDEVICE=%4  -sOutputICCProfile=\"%5\" -dNOPAUSE -dBATCH  %6 \"%7\"").arg(m_strExecutable).arg(m_strOutputFile).arg(m_strResolution).arg(m_strDevice).arg(m_strICCFile).arg(m_strExtraOptions).arg(m_strInputFile);
            //m_command=QString("\"%1\" -sOutputFile=\"%2\" -r%3 -sDEVICE=%4  -sOutputICCProfile=\"%5\" -dNOPAUSE -dBATCH  %6 \"%7\"").arg(m_strExecutable).arg(outputFoo).arg(m_strResolution).arg(m_strDevice).arg(m_strICCFile).arg(m_strExtraOptions).arg(localFile);
            //emit SendDebugInfo(LOGGER_ERROR,tr("%1 - %2").arg(localFile).arg(outputFoo));

            QProcess convertgs;
            rtn=convertgs.execute(m_command);
            qDebug()<<m_command;
            emit SendDebugInfo(LOGGER_WARNING,m_command);
            if (m_doubleRes){
                QImage *tmpImage=new QImage(m_strOutputFile);
                m_strOutputFile=tmp;
                int width=tmpImage->width();
                int height=tmpImage->height();
                QImage *dest=new QImage(width/2,height,tmpImage->format());
                dest->fill(Qt::white);
                for (int x=0;x<width;x=x+2){
                    for (int y=0;y<height;y++){
                        dest->setPixel(x/2,y,tmpImage->pixel(x,y));
                    }
                }
                dest->save(m_strOutputFile);
                delete (dest);
                delete (tmpImage);
            }

        }
    }
    //Detecto que es una imagen
    else if ((!suffix.compare("png",Qt::CaseInsensitive))|| (!suffix.compare("jpeg",Qt::CaseInsensitive))||(!suffix.compare("jpg",Qt::CaseInsensitive))||(!suffix.compare("bmp",Qt::CaseInsensitive))||(!suffix.compare("tif",Qt::CaseInsensitive))){ //Si es un archivo de imagen
        QPixmap dummy=QPixmap(m_strInputFile);
        if (!dummy.isNull()){
            dummy.save(QString("%1").arg(m_strOutputFile),"bmp");
            rtn=1;
        }
    }
    return rtn;
}
Example #25
0
void WidgetRdpView::resizeVmDesktopAndConnectViaRdp()
{
  QStringList args;

  QPalette palette;
  palette.setColor(QPalette::Background,Qt::blue);
  freeRDPwidget_->setPalette(palette);
  freeRDPwidget_->setAutoFillBackground(true);

  screenWidth_ = this->width() - subtractDisplayWidthMin_;
  int remainingWidth = screenWidth_ % 4;
  subtractDisplayWidthCurrent_ = subtractDisplayWidthMin_ + remainingWidth;
  screenWidth_ = this->width() - subtractDisplayWidthCurrent_;
  ILOG("WidgetRdpView::connectViaRdp() subtractDisplayWidthCurrent: " + QString::number(subtractDisplayWidthCurrent_) + " >= " + QString::number(subtractDisplayWidthMin_))

  screenHeight_ = this->height() - subtractDisplayHeightMin_;
  int remainingHeight = screenHeight_ % 4;
  subtractDisplayHeightCurrent_ = subtractDisplayHeightMin_ + remainingHeight;
  screenHeight_ = this->height() - subtractDisplayHeightCurrent_;
  ILOG("WidgetRdpView::connectViaRdp() subtractDisplayHeightCurrent: " + QString::number(subtractDisplayHeightCurrent_) + " >= " + QString::number(subtractDisplayHeightMin_))

  // Tell VirtualBox to change the display size
  args.clear();
  args.append("controlvm");
  args.append(pmInstance_->getConfig()->vmName);
  args.append("setvideomodehint");
  args.append(QString::number(screenWidth_));
  args.append(QString::number(screenHeight_));
  args.append("32");
  ILOG("WidgetRdpView::connectViaRdp() resize using command: vboxmanage " + args.join(" "));
  QProcess procResize;
  procResize.execute("vboxmanage", args);
  procResize.waitForFinished(3000);

#ifndef SKIP_FREERDP_CODE

  freeRDPwidget_->resize(screenWidth_, screenHeight_);
  freeRDPwidget_->setDesktopSize(screenWidth_, screenHeight_);
  freeRDPwidget_->connectToHost("localhost", rdpPort_);
  freeRDPwidget_->show();
  freeRDPwidget_->repaint();

#else
  freeRDPwidget_->setText("to connect run: xfreerdp /network:broadband /size:" + QString::number(screenWidth_) + "x" + QString::number(screenHeight_) + " -encryption /v:localhost:" + QString::number(rdpPort_));
#endif

  emit signalScreenResize( this );
  connectionEstablished_ = true;
}
Example #26
0
void OOoReportBuilder::loadReportFile(QString filename)
{
    m_isLoaded = false;
    m_filename = filename;

    if (m_filename.isEmpty())
        return;

    if (!QFile::exists(m_filename)) {
        QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                              tr("File '%1' not found! ").arg(m_filename));
        return;
    }

    m_fileContent = m_outputDir + "\\content.xml";

    QStringList args;
    args << "e" << m_filename << QString("-o%1")
            .arg(m_outputDir)
         << "content.xml" << "-y";

    QProcess *arh = new QProcess();

    int exitCode = arh->execute("7z", args);


    if (exitCode == 0) {
        m_isLoaded = true;
        loadContentFile(m_fileContent);
    } else {
        if (exitCode == -2) {
            QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                                  tr("Can'c create process unpacking! "));
        } else if (exitCode == -1) {
                QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                                      tr("Error in unpacking! "));
        } else if (exitCode == 1) {
                QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                                      tr("Error in unpacking (ExitCode: 1 - Warning)"));
        } else if (exitCode == 2) {
                QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                                      tr("Error in unpacking (ExitCode: 2 - Fatal Error)"));
        } else {
                QMessageBox::critical(QApplication::activeWindow(),"loadReportFile",
                                      tr("Unknown error (ExitCode: %1)")
                                      .arg(exitCode));
        }
    }
}
Example #27
0
DialogProgress::DialogProgress(QWidget *parent) :  QDialog(parent),  ui(new Ui::DialogProgress)
{
    ui->setupUi(this);

    bool ready = false;
    QString strUmount("umount /dev/udisk");
    QString strMount("mount /dev/udisk /udisk");

    int exitCode;
    QProcess *proc = new QProcess(this);
    QTime time;

    while(!ready)
    {
        //демонтирам и отново монтирам флашката във файловата система.Така ако последната операция е успешна
        //се уверявам, че флашката е поставена.
        //unmount
        exitCode = proc->execute(strUmount);
        //mount and check the  exit code
        exitCode = proc->execute(strMount);

        if(exitCode==0){ ready=true; }
        else
        {
            if(time.elapsed()>6000)
            {//проверка за таймаут
                QMessageBox::critical(this,tr("ГРЕШКА"),tr("Външна USB памет не може да бъде открита"));
                //beep();
                if(proc!=NULL) delete proc;
                return;
            }
        }
//!!!!!!
        qApp->processEvents();
    }
}
Example #28
0
bool MTFile::touch(QApplication *
#ifdef Q_WS_WIN
    app
#endif
    )
{
    QStringList arguments; QProcess touch;
#ifdef Q_WS_WIN
    touch.setWorkingDirectory(QFileInfo(app->arguments().at(0)).absolutePath());
#endif
	arguments << "-cmf" << fileName();
	if (touch.execute("touch", arguments) == 0) {
		return true;
	} else { return false; }
	return false;
}
Example #29
0
bool UpdateExtractor::extract(const QString &archive, const QString &directory)
{
    QFileInfo fi(archive);

    if (!fi.exists())
        return false;

    // create output directory if it doesn't exist
    QFileInfo di(directory);
    QDir _d(".");
    if (di.exists())
        _d.rmdir(directory);

    QProcess proc;
    return proc.execute("7z.exe", QStringList() << "x" << QString("-o%1").arg(directory) << archive) == 0;
}
Example #30
0
void CInstallThread::execute(QString cmd){

    QProcess passwdProcess;

    QString command="echo 'abc123' | sudo -S ";
    command.append(cmd);

    // print the command
    QString outputCommand="Command  ";
    outputCommand.append(cmd);
    emit notifyOutput(QByteArray(outputCommand.toAscii()));

    //execute the command
    passwdProcess.execute("sh",QStringList()<<"-c"<<command);

    // print the error after execute the command
    QByteArray error = passwdProcess.readAllStandardError();
    emit notifyOutput(error);
}