/**
 * @brief This internal function controls if the Paraview is opened passing a file or to open a new
 * instance of Paraview
 *
 */
void MainWindow::seeParaviewResults()
{
    QString _currentPath;
    if (_projectData.getProjectPath().isEmpty())
        _currentPath = QCoreApplication::applicationDirPath();//QDir::currentPath();
    else
        _currentPath = QDir(_projectData.getProjectPath()).filePath(TOOL4);

    QString _viewFile = QFileDialog::getOpenFileName(this, tr("Select the file to see with Paraview"),
                                                            _currentPath,
                                                            tr("Paraview Files (*.vtk)"));

    if (!_viewFile.isEmpty())
    {
        QString _postProcessorPath = _userPreferencesData.getPostProcessorViewerPath();
        QString _command;
        if ( (!_postProcessorPath.isNull()) && (!_postProcessorPath.isEmpty()) )
            _command = _postProcessorPath;
        else
            _command = "paraview";

        QProcess * _viewProcess = new QProcess(this);
        _command = _command + " --data="+_viewFile;
        connect(_viewProcess, SIGNAL(error(QProcess::ProcessError)),
                this, SLOT(slotProcessError(QProcess::ProcessError)));
        _viewProcess->start(_command);
    }
}
/**
 * @brief
 *
 */
void SalomeOptimizationDialog::runPythonFile()
{
    QFileInfo _salomeFilePath(_salomeMeshPath);
    QString _salomeToolPath = _salomeFilePath.absolutePath();
    if (_salomeToolPath.isEmpty())
        return;
    ui->pushButton->setEnabled(false);
    _regEditor->append("Starting Python JobManager Execution ....");
    _meshCreationProcess = new QProcess(this);
    _meshCreationProcess->setWorkingDirectory(QDir(_projectPath).filePath("Python"));
  QString _meshCommand("") ;
    _meshCommand = _salomeToolPath + "/runSession runSalome -t -u" + _projectName +"_opt.py";
    connect(_meshCreationProcess, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(slotProcessError(QProcess::ProcessError)));
    connect(_meshCreationProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(outputConsole()));
    connect(_meshCreationProcess, SIGNAL(readyReadStandardError()), this, SLOT(errorConsole()));
    connect(_meshCreationProcess, SIGNAL(finished(int)), this, SLOT(meshCreationFinished()));

    _regEditor->append("[START MESH CREATION] --> Running " + _meshCommand);
    _meshCreationProcess->start(_meshCommand);

    // Updating the Text of the Create Mesh Button


}
/** @brief This internal function controls how to launch the Salome tool, specially due to the path of this tool (not in
* traditional Linux paths like usr/bin). So, with this function we locate the path to Salome to run it
*
*/
void MainWindow::launchSalomeMeshTool()
{
   // Step 1. Set up the working directory in the project

   QString _workingDir = QDir(_projectData.getProjectPath()).filePath(TOOL4);
   _salomeLocationProccess->setWorkingDirectory(_workingDir);

   // Esto no funciona --> Revisar ...
   QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
   env.insert("WORKINGDIR", _workingDir); // Add an environment variable
   _salomeLocationProccess->setProcessEnvironment(env);

   // Step 2. Launch Mesh Tool
 //  QString _command = "export WORKINGDIR=\"" +_workingDir +"\"; echo $WORKINGDIR";//+
   QString _command = _userPreferencesData.getMeshViewerPath();
   // By default for Salome tools
   if ( (_command.isNull()) || (_command.isEmpty()) )
   {
       // There is no configuration for the Salome Mesher. The user shall provide the location of the executable
        MeshingToolConfigurationWarningDialog _meshingWarning;
        _meshingWarning.initializeStructures(&_userPreferencesData,&_solverManager);
        _meshingWarning.exec();
        return;
   }


    QProcess * _runSalome = new QProcess(this) ;
    connect(_runSalome, SIGNAL(error(QProcess::ProcessError)),
             this, SLOT(slotProcessError(QProcess::ProcessError)));
    _runSalome->start(_command);

}
void CvsJob::start()
{
    if( !d->rsh.isEmpty() )
        d->childproc->setEnv("CVS_RSH", d->rsh);

    if( !d->server.isEmpty() )
        d->childproc->setEnv("CVS_SERVER", d->server);

    if( !d->directory.isEmpty() ) {
        kDebug(9500) << "Working directory:" << d->directory;
        d->childproc->setWorkingDirectory(d->directory);
    }

    connect(d->childproc, SIGNAL(finished(int, QProcess::ExitStatus)),
            SLOT(slotProcessExited(int, QProcess::ExitStatus)));
    connect(d->childproc, SIGNAL(error(QProcess::ProcessError)),
            SLOT(slotProcessError(QProcess::ProcessError)));

    connect(d->lineMaker, SIGNAL(receivedStdoutLines(const QStringList&)),
            SLOT(slotReceivedStdout(const QStringList&)));
    connect(d->lineMaker, SIGNAL(receivedStderrLines(const QStringList&)),
            SLOT(slotReceivedStderr(const QStringList&)) );

    kDebug(9500) << "Execute cvs command:" << cvsCommand();

    d->outputLines.clear();
    d->isRunning = true;
    d->childproc->setOutputChannelMode( d->commMode );
    d->childproc->setProgram( d->command );
    d->childproc->start();
}
Example #5
0
void TemplateIconView::searchLaTeXClassFiles()
{
	if(!m_templateManager) {
		return;
	}

	m_output.clear();

	QString command = "kpsewhich -format=tex scrartcl.cls beamer.cls prosper.cls HA-prosper.sty";

	delete m_proc;

	m_proc = new KProcess(this);
	(*m_proc) << KShell::splitArgs(command);

	m_proc->setOutputChannelMode(KProcess::MergedChannels);
	m_proc->setReadChannel(QProcess::StandardOutput);

	connect(m_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotProcessOutput()));
	connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotProcessExited(int, QProcess::ExitStatus)));
	connect(m_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotProcessError()));
	KILE_DEBUG_MAIN << "=== NewFileWidget::searchClassFiles() ====================";
	KILE_DEBUG_MAIN << "\texecute: " << command;
	m_proc->start();
}
/**
 * @brief This function is the one capable of locating the Salome path in the client side
 *
 */
void MainWindow::getSalomePathSlot()
{
    QString _pathSalomeBin = _salomeLocationProccess->readAllStandardOutput();
    _userPreferencesData.setMeshViewerPath(_pathSalomeBin);
    QProcess * _runSalome = new QProcess(this) ;

    connect(_runSalome, SIGNAL(error(QProcess::ProcessError)),
            this, SLOT(slotProcessError(QProcess::ProcessError)));

    _runSalome->start(_pathSalomeBin);
}
Example #7
0
void ATSkeletonWindow::connectTunnel( Tunnel_c &tunnel )
{
 	Tunnel_c *pt = &tunnel;
 
 	AddToLog( tunnel, "Connecting tunnel %s...", qPrintable( pt->strName ) );
 	AddToLog( tunnel, "Host: %s - Tunnel: %d:%s:%d", qPrintable( pt->strSSHHost ), pt->iLocalPort, qPrintable( pt->strRemoteHost ), pt->iRemotePort );
 
 	if ( pt->strSSHHost.isEmpty() )
 	{
 		AddToLog( tunnel, "Error: Tunnel %s has no host, please check the settings.", qPrintable( pt->strName ) );
 		return;
 	}
 
 #ifdef WIN32
 	QString strPlink = "plink.exe";
 
 	// Check that the executable is found
 	{
 		QDir dir( argv0 );
 		dir.cdUp();
 		if ( !dir.exists( strPlink ) )
 		{
 			const char *ptr = argv0, *ptr2 = argv0;
 			while ( *ptr2 ) { if ( *ptr2 == '\\' ) ptr = ptr2+1; ptr2++; }
 			AddToLog( tunnel, "Error: Could not find %s, please check that it is in the same directory as %s.", qPrintable( strPlink ), ptr );
 			return;
 		}
 	}
 #else
 	QString strPlink = "ssh";
 #endif
 
 	if ( pt->pProcess != NULL ) return; // already connected?

	if ( tunnel.twi ) tunnel.twi->setIcon( 0, QPixmap( ":connecting.png" ) );
  	//QTreeWidgetItem *twi = getTreeItemFromTunnelIndex( iTunnelIndex );
  	//if ( twi ) twi->setIcon( 0, QPixmap( ":connecting.png" ) );
 
 	ATASSERT( pt->pConnector == NULL );
 	pt->pConnector = new ATTunnelConnector_c( this, &tunnel );
 
 	pt->pProcess = new QProcess;
 	pt->pProcess->setProcessChannelMode( QProcess::MergedChannels );
 
 	QString strCommand;
 
 	strCommand += strPlink + " ";
 	strCommand += "-v ";
 
 #ifdef _WIN32
 	QStringList strListSSHHost = pt->strSSHHost.split( ':', QString::SkipEmptyParts );
 	if ( strListSSHHost.count() == 1 ) strListSSHHost << "22";
 
 	strCommand += strListSSHHost.at(0) + " -P " + strListSSHHost.at(1) + " ";
 #else
 	strCommand += pt->strSSHHost + " ";
 #endif
 
 	if ( !pt->strUsername.isEmpty() ) strCommand += QString( "-l %1 " ).arg( pt->strUsername );
 
 	if ( pt->bCompression ) strCommand += "-C ";
 
 	strCommand += ( pt->iSSH1or2 == 1 ) ? "-1 " : "-2 ";
 
 	if ( pt->iDirection == 0 ) // Local -> Remote
 	{
 		IF_NWIN32( strCommand += "-g " );
 		strCommand += QString( "-L %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 	else // Remote -> Local
 	{
 		strCommand += QString( "-R %1:%2:%3 " ).arg( pt->iLocalPort ).arg( pt->strRemoteHost).arg( pt->iRemotePort );		
 	}
 
 	if ( !pt->strSSHKeyFile.isEmpty() ) strCommand += QString( "-i %1 " ).arg( pt->strSSHKeyFile );
 
 	strCommand += pt->strExtraArguments;
 
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardOutput() ), pt->pConnector, SLOT( slotProcessReadStandardOutput() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( readyReadStandardError() ), pt->pConnector, SLOT( slotProcessReadStandardError() ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( error(QProcess::ProcessError) ), pt->pConnector, SLOT( slotProcessError(QProcess::ProcessError) ) ) );
 	ATVERIFY( connect( pt->pProcess, SIGNAL( finished(int, QProcess::ExitStatus) ), pt->pConnector, SLOT( slotProcessFinished(int, QProcess::ExitStatus) ) ) );
 	ATVERIFY( connect( pt->pConnector, SIGNAL( finished(Tunnel_c*) ), this, SLOT( slotConnectorFinished(Tunnel_c*) ), Qt::QueuedConnection ) );
 
 	AddToLog( tunnel, "%s", qPrintable( strCommand ) );
 
 	pt->pProcess->start( strCommand );
}