//This function carries out the entire BLAST search procedure automatically, without user input. //It returns an error string which is empty if all goes well. QString BlastSearch::doAutoBlastSearch() { cleanUp(); QString makeblastdbCommand = "makeblastdb"; if (!findProgram("makeblastdb", &makeblastdbCommand)) return "Error: The program makeblastdb was not found. Please install NCBI BLAST to use this feature."; BuildBlastDatabaseWorker buildBlastDatabaseWorker(makeblastdbCommand); buildBlastDatabaseWorker.buildBlastDatabase(); if (buildBlastDatabaseWorker.m_error != "") return buildBlastDatabaseWorker.m_error; loadBlastQueriesFromFastaFile(g_settings->blastQueryFilename); QString blastnCommand = "blastn"; if (!findProgram("blastn", &blastnCommand)) return "Error: The program blastn was not found. Please install NCBI BLAST to use this feature."; QString tblastnCommand = "tblastn"; if (!findProgram("tblastn", &tblastnCommand)) return "Error: The program tblastn was not found. Please install NCBI BLAST to use this feature."; RunBlastSearchWorker runBlastSearchWorker(blastnCommand, tblastnCommand, g_settings->blastSearchParameters);; runBlastSearchWorker.runBlastSearch(); if (runBlastSearchWorker.m_error != "") return runBlastSearchWorker.m_error; blastQueryChanged("all"); return ""; }
void MainForm::scanImage() { scanProcess->terminate(); scanProcess->waitForFinished(10000); if (useXSane) { if (!findProgram("xsane")) { QMessageBox::warning(this, trUtf8("Warning"), trUtf8("xsane not found")); return; } QStringList sl; sl.append("-s"); sl.append("-n"); sl.append("-N"); sl.append(workingDir + "input.jpg"); QStringList env = QProcess::systemEnvironment(); QFileInfo lib; lib.setFile("/usr/local/lib/yagf/libxspreload.so"); if (!lib.exists()) lib.setFile("/usr/lib/yagf/libxspreload.so"); if (!lib.exists()) lib.setFile("/usr/lib64/yagf/libxspreload.so"); if (!lib.exists()) lib.setFile("/usr/local/lib64/yagf/libxspreload.so"); if (!lib.exists()) { QMessageBox::warning(this, trUtf8("Error"), trUtf8("libxspreload.so not found")); return; } env.append("LD_PRELOAD=" + lib.filePath()); scanProcess->setEnvironment(env); scanProcess->start("xsane", sl); // proc.waitForFinished(-1); } }
void beginProgram (int argumentCount, char **argumentVector) { #if defined(GRUB_RUNTIME) #else /* at exit */ atexit(endProgram); #endif /* at exit */ initializeSystemObject(); prepareLocale(); if ((programPath = getProgramPath())) { registerProgramMemory("program-path", &programPath); } else { programPath = argumentVector[0]; } if (!isExplicitPath(programPath)) { char *path = findProgram(programPath); if (!path) path = testProgram(".", programPath); if (path) programPath = path; } if (isExplicitPath(programPath)) { #if defined(HAVE_REALPATH) && defined(PATH_MAX) if (!isAbsolutePath(programPath)) { char buffer[PATH_MAX]; char *path = realpath(programPath, buffer); if (path) { char *realPath = strdup(path); if (realPath) { programPath = realPath; } else { logMallocError(); } } else { logSystemError("realpath"); } } #endif /* defined(HAVE_REALPATH) && defined(PATH_MAX) */ if (!isAbsolutePath(programPath)) { char *directory; if ((directory = getWorkingDirectory())) { char *path; if ((path = makePath(directory, programPath))) programPath = path; free(directory); } } } programName = locatePathName(programPath); pushLogPrefix(programName); }
void WmSelectDialog::addWindowManager(const QString &program, const QString &description) { QListWidgetItem *item = new QListWidgetItem(description, ui->wmList); item->setData(Qt::UserRole, QVariant(program)); bool enable = findProgram(program); if (!enable) item->setFlags(Qt::NoItemFlags); if (enable && ui->wmList->currentRow() < 0) { ui->wmList->setCurrentItem(item); } }
// // // // // CzProgramManager Implementation // // // // void CzProgramManager::addProgram(CzProgram* program) { #if defined(CZ_REMOVE_DUPLICATES) CzProgram* prog = findProgram(program->getNameHash()); if (prog != NULL) { CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Program - Already exists, program was replaced - ", program->getName().c_str()); removeProgram(program); } #endif Programs.push_back(program); program->setManager(this); }
// // // // // CIwGameProgramManager Implementation // // // // void CIwGameProgramManager::addProgram(CIwGameProgram* program) { #if defined(IW_REMOVE_DUPLICATES) CIwGameProgram* prog = findProgram(program->getNameHash()); if (prog != NULL) { CIwGameError::LogError("Warning: Program already exists, program was replaced - ", program->getName().c_str()); removeProgram(program); } #endif Programs.push_back(program); program->setManager(this); }
void MainForm::recognize() { QFile::remove(workingDir + "input*.bmp"); if (!imageLoaded) { QMessageBox::critical(this, trUtf8("Error"), trUtf8("No image loaded")); return; } if (settings.getSelectedEngine() == UseCuneiform) { if (!findProgram("cuneiform")) { if (findProgram("tesseract")) { QMessageBox::warning(this, trUtf8("Warning"), trUtf8("cuneiform not found, switching to tesseract")); settings.setSelectedEngine(UseTesseract); } else { QMessageBox::warning(this, trUtf8("Warning"), trUtf8("No recognition engine found.\nPlease install either cuneiform or tesseract")); return; } } } if (settings.getSelectedEngine() == UseTesseract) { if (!findProgram("tesseract")) { if (findProgram("cuneiform")) { QMessageBox::warning(this, trUtf8("Warning"), trUtf8("tesseract not found, switching to cuneiform")); settings.setSelectedEngine(UseCuneiform); } else { QMessageBox::warning(this, trUtf8("Warning"), trUtf8("No recognition engine found.\nPlease install either cuneiform or tesseract")); return; } } } if (graphicsInput->blocksCount() > 0) { for (int i = graphicsInput->blocksCount(); i >= 0; i--) if (!graphicsInput->getBlockByIndex(i).isNull()) recognizeInternal(graphicsInput->getBlockByIndex(i)); } else { recognizeInternal(graphicsInput->getAdaptedImage()); } }
int executeRetrace(const std::vector<const char *> & opts, const char *traceName, trace::API api) { os::log("cli_retrace start executing Retrace, traceName is %s \n", traceName); const char *retraceName; switch (api) { case trace::API_GL: retraceName = "glretrace"; break; case trace::API_EGL: retraceName = "eglretrace"; break; case trace::API_DX: case trace::API_D3D7: case trace::API_D3D8: case trace::API_D3D9: case trace::API_DXGI: // Use prefix so that it can be used with WINE retraceName = "d3dretrace.exe"; break; default: std::cerr << "warning: could not guess trace's API\n"; retraceName = "glretrace"; break; } os::log("retraceName is %s\n", retraceName); std::vector<const char *> command; os::String retracePath = findProgram(retraceName); if (retracePath.length()) { command.push_back(retracePath); } else { command.push_back(retraceName); } command.insert(command.end(), opts.begin(), opts.end()); if (traceName) { command.push_back(traceName); } command.push_back(NULL); //os::log("command[0] : %s",&command[0]); return os::execute((char * const *)&command[0]); }
void SessionConfigWindow::handleCfgComboBox(QComboBox * cb, const QStringList &availableValues, const QString &value ) { QStringList realValues; foreach (QString s, availableValues) { if (findProgram(s)) realValues << s; } cb->clear(); cb->addItems(realValues); int ix = cb->findText(value); if (ix == -1) cb->lineEdit()->setText(value); else cb->setCurrentIndex(ix); }
int main( int argc, _TCHAR* argv[] ) { _TCHAR* errorMsg; _TCHAR* program; _TCHAR* iniFile; _TCHAR* ch; _TCHAR** configArgv = NULL; int configArgc = 0; int exitCode = 0; int ret = 0; void * handle = 0; RunMethod runMethod; SetInitialArgs setArgs; setlocale(LC_ALL, ""); initialArgc = argc; initialArgv = malloc((argc + 1) * sizeof(_TCHAR*)); memcpy(initialArgv, argv, (argc + 1) * sizeof(_TCHAR*)); /* * Strip off any extroneous <CR> from the last argument. If a shell script * on Linux is created in DOS format (lines end with <CR><LF>), the C-shell * does not strip off the <CR> and hence the argument is bogus and may * not be recognized by the launcher or eclipse itself. */ ch = _tcschr( argv[ argc - 1 ], _T_ECLIPSE('\r') ); if (ch != NULL) { *ch = _T_ECLIPSE('\0'); } /* Determine the full pathname of this program. */ program = findProgram(argv); /* Parse configuration file arguments */ iniFile = checkForIni(argc, argv); if (iniFile != NULL) ret = readConfigFile(iniFile, &configArgc, &configArgv); else ret = readIniFile(program, &configArgc, &configArgv); if (ret == 0) { parseArgs (&configArgc, configArgv); } /* Parse command line arguments */ /* Overrides configuration file arguments */ parseArgs( &argc, argv ); /* Special case - user arguments specified in the config file * are appended to the user arguments passed from the command line. */ if (configArgc > 0) { createUserArgs(configArgc, configArgv, &argc, &argv); } /* Initialize official program name */ officialName = name != NULL ? _tcsdup( name ) : getDefaultOfficialName(program); /* Find the directory where the Eclipse program is installed. */ programDir = getProgramDir(program); /* Find the eclipse library */ eclipseLibrary = findLibrary(eclipseLibrary, program); if(eclipseLibrary != NULL) handle = loadLibrary(eclipseLibrary); if(handle == NULL) { errorMsg = malloc( (_tcslen(libraryMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) ); _stprintf( errorMsg, libraryMsg, officialName ); if (!suppressErrors) displayMessage( officialName, errorMsg ); else _ftprintf(stderr, _T_ECLIPSE("%s:\n%s\n"), officialName, errorMsg); free( errorMsg ); exit( 1 ); } setArgs = (SetInitialArgs)findSymbol(handle, SET_INITIAL_ARGS); if(setArgs != NULL) setArgs(initialArgc, initialArgv, eclipseLibrary); else { if(!suppressErrors) displayMessage(officialName, entryMsg); else _ftprintf(stderr, _T_ECLIPSE("%s:\n%s\n"), officialName, entryMsg); exit(1); } runMethod = (RunMethod)findSymbol(handle, RUN_METHOD); if(runMethod != NULL) exitCode = runMethod(argc, argv, userVMarg); else { if(!suppressErrors) displayMessage(officialName, entryMsg); else _ftprintf(stderr, _T_ECLIPSE("%s:\n%s\n"), officialName, entryMsg); exit(1); } unloadLibrary(handle); free( eclipseLibrary ); free( programDir ); free( program ); free( officialName ); return exitCode; }
CzProgram* CzProgramManager::findProgram(const char* name) { return findProgram(CzString::CalculateHash(name)); }
ProgramRunner::ProgramRunner( const BSONObj &args ) { verify( !args.isEmpty() ); string program( args.firstElement().valuestrsafe() ); verify( !program.empty() ); boost::filesystem::path programPath = findProgram(program); string prefix( "mongod-" ); bool isMongodProgram = string("mongod") == program || program.compare( 0, prefix.size(), prefix ) == 0; prefix = "mongos-"; bool isMongosProgram = string("mongos") == program || program.compare( 0, prefix.size(), prefix ) == 0; #if 0 if (isMongosProgram == "mongos") { _argv.push_back("valgrind"); _argv.push_back("--log-file=/tmp/mongos-%p.valgrind"); _argv.push_back("--leak-check=yes"); _argv.push_back("--suppressions=valgrind.suppressions"); //_argv.push_back("--error-exitcode=1"); _argv.push_back("--"); } #endif _argv.push_back( programPath.string() ); _port = -1; BSONObjIterator j( args ); j.next(); // skip program name (handled above) while(j.more()) { BSONElement e = j.next(); string str; if ( e.isNumber() ) { stringstream ss; ss << e.number(); str = ss.str(); } else { verify( e.type() == mongo::String ); str = e.valuestr(); } if ( str == "--port" ) _port = -2; else if ( _port == -2 ) _port = strtol( str.c_str(), 0, 10 ); _argv.push_back(str); } if ( ! isMongodProgram && ! isMongosProgram && program != "mongobridge" ) _port = 0; else { if ( _port <= 0 ) log() << "error: a port number is expected when running " << program << " from the shell" << endl; verify( _port > 0 ); } if ( _port > 0 ) { bool haveDbForPort = registry.isPortRegistered( _port ); if ( haveDbForPort ) { log() << "already have db for port: " << _port << endl; verify( !haveDbForPort ); } } }
MainForm::MainForm(QWidget *parent): QMainWindow(parent) { setupUi(this); ///!!!!! //alignButton->hide(); //unalignButton->hide(); setWindowTitle("YAGF"); spellChecker = new SpellChecker(textEdit); spellChecker->enumerateDicts(); selectLangsBox = new QComboBox(); QLabel *label = new QLabel(); label->setMargin(4); label->setText(trUtf8("Recognition language")); frame->show(); toolBar->addWidget(label); selectLangsBox->setFrame(true); toolBar->addWidget(selectLangsBox); graphicsInput = new QGraphicsInput(QRectF(0, 0, 2000, 2000), graphicsView) ; graphicsInput->addToolBarAction(actionHideShowTolbar); graphicsInput->addToolBarAction(this->actionTBLV); graphicsInput->addToolBarAction(this->actionSmaller_view); graphicsInput->addToolBarSeparator(); graphicsInput->addToolBarAction(actionRotate_90_CCW); graphicsInput->addToolBarAction(actionRotate_180); graphicsInput->addToolBarAction(actionRotate_90_CW); graphicsInput->addToolBarAction(actionDeskew); graphicsInput->addToolBarSeparator(); graphicsInput->addToolBarAction(actionSelect_Text_Area); graphicsInput->addToolBarAction(actionSelect_multiple_blocks); graphicsInput->addToolBarAction(ActionClearAllBlocks); statusBar()->show(); imageLoaded = false; useXSane = TRUE; textSaved = TRUE; hasCopy = false; //rotation = 0; m_menu = new QMenu(graphicsView); ifCounter = 0; connect(actionOpen, SIGNAL(triggered()), this, SLOT(loadImage())); connect(actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(this, SIGNAL(windowShown()), this, SLOT(onShowWindow()), Qt::QueuedConnection); connect(actionScan, SIGNAL(triggered()), this, SLOT(scanImage())); connect(actionPreviousPage, SIGNAL(triggered()), this, SLOT(loadPreviousPage())); connect(actionNextPage, SIGNAL(triggered()), this, SLOT(loadNextPage())); connect(actionRecognize, SIGNAL(triggered()), this, SLOT(recognize())); connect(action_Save, SIGNAL(triggered()), this, SLOT(saveText())); connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDlg())); connect(actionOnlineHelp, SIGNAL(triggered()), this, SLOT(showHelp())); connect(actionCopyToClipboard, SIGNAL(triggered()), this, SLOT(copyClipboard())); textEdit->setContextMenuPolicy(Qt::CustomContextMenu); connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool))); connect(textEdit, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(graphicsInput, SIGNAL(rightMouseClicked(int, int, bool)), this, SLOT(rightMouseClicked(int, int, bool))); tesMap = new TesMap(); fillLanguagesBox(); initSettings(); delTmpFiles(); scanProcess = new QProcess(this); QXtUnixSignalCatcher::connectUnixSignal(SIGUSR2); ba = new QByteArray(); connect(QXtUnixSignalCatcher::catcher(), SIGNAL(unixSignal(int)), this, SLOT(readyRead(int))); connect(textEdit->document(), SIGNAL(cursorPositionChanged(const QTextCursor &)), this, SLOT(updateSP())); //displayLabel->installEventFilter(this); textEdit->installEventFilter(this); QPixmap l_cursor; l_cursor.load(":/resize.png"); resizeCursor = new QCursor(l_cursor); graphicsInput->setMagnifierCursor(resizeCursor); l_cursor.load(":/resize_block.png"); resizeBlockCursor = new QCursor(l_cursor); // textEdit->setContextMenuPolicy(Qt::ActionsContextMenu); this->sideBar->show(); connect(sideBar, SIGNAL(fileSelected(const QString &)), this, SLOT(fileSelected(const QString &))); connect(actionRecognize_All_Pages, SIGNAL(triggered()), this, SLOT(recognizeAll())); graphicsInput->setSideBar(sideBar); QPixmap pm; pm.load(":/align.png"); //alignButton->setIcon(pm); pm.load(":/undo.png"); //unalignButton->setIcon(pm); //connect(unalignButton, SIGNAL(clicked()), this, SLOT(unalignButtonClicked())); //clearBlocksButton->setDefaultAction(ActionClearAllBlocks); loadFromCommandLine(); emit windowShown(); pdfx = NULL; if (findProgram("pdftoppm")) { pdfx = new PDF2PPT(); } else if (findProgram("gs")) { pdfx = new GhostScr(); } if (pdfx) { connect(pdfx, SIGNAL(addPage(QString)), this, SLOT(addPDFPage(QString)), Qt::QueuedConnection); connect (pdfx, SIGNAL(finished()), this, SLOT(finishedPDF())); } pdfPD.setWindowTitle("YAGF"); pdfPD.setLabelText(trUtf8("Importing pages from the PDF document...")); pdfPD.setCancelButtonText(trUtf8("Cancel")); pdfPD.setMinimum(-1); pdfPD.setMaximum(-1); pdfPD.setWindowIcon(QIcon(":/yagf.png")); if (pdfx) connect(&pdfPD, SIGNAL(canceled()), pdfx, SLOT(cancel())); }
ProgramRunner::ProgramRunner(const BSONObj& args, const BSONObj& env) { uassert(ErrorCodes::FailedToParse, "cannot pass an empty argument to ProgramRunner", !args.isEmpty()); string program(args.firstElement().valuestrsafe()); uassert(ErrorCodes::FailedToParse, "invalid program name passed to ProgramRunner", !program.empty()); boost::filesystem::path programPath = findProgram(program); boost::filesystem::path programName = programPath.stem(); string prefix("mongod-"); bool isMongodProgram = string("mongod") == programName || programName.string().compare(0, prefix.size(), prefix) == 0; prefix = "mongos-"; bool isMongosProgram = string("mongos") == programName || programName.string().compare(0, prefix.size(), prefix) == 0; if (isMongodProgram) { _name = "d"; } else if (isMongosProgram) { _name = "s"; } else if (programName == "mongobridge") { _name = "b"; } else { _name = "sh"; } _argv.push_back(programPath.string()); _port = -1; // Parse individual arguments into _argv BSONObjIterator j(args); j.next(); // skip program name (handled above) while (j.more()) { BSONElement e = j.next(); string str; if (e.isNumber()) { stringstream ss; ss << e.number(); str = ss.str(); } else { verify(e.type() == mongo::String); str = e.valuestr(); } if (str == "--port") { _port = -2; } else if (_port == -2) { _port = strtol(str.c_str(), 0, 10); } else if (isMongodProgram && str == "--configsvr") { _name = "c"; } _argv.push_back(str); } // Load explicitly set environment key value pairs into _envp. for (const BSONElement& e : env) { // Environment variable values must be strings verify(e.type() == mongo::String); _envp.emplace(std::string(e.fieldName()), std::string(e.valuestr())); } // Import this process' environment into _envp, for all keys that have not already been set. // We need to do this so that the child process has all the PATH and locale variables, unless // we explicitly override them. #ifdef _WIN32 wchar_t* processEnv = GetEnvironmentStringsW(); ON_BLOCK_EXIT( [](wchar_t* toFree) { if (toFree) FreeEnvironmentStringsW(toFree); }, processEnv); // Windows' GetEnvironmentStringsW returns a NULL terminated array of NULL separated // <key>=<value> pairs. while (processEnv && *processEnv) { std::wstring envKeyValue(processEnv); size_t splitPoint = envKeyValue.find('='); invariant(splitPoint != std::wstring::npos); std::string envKey = toUtf8String(envKeyValue.substr(0, splitPoint)); std::string envValue = toUtf8String(envKeyValue.substr(splitPoint + 1)); _envp.emplace(std::move(envKey), std::move(envValue)); processEnv += envKeyValue.size() + 1; } #else // environ is a POSIX defined array of char*s. Each char* in the array is a <key>=<value>\0 // pair. char** environEntry = environ; while (*environEntry) { std::string envKeyValue(*environEntry); size_t splitPoint = envKeyValue.find('='); invariant(splitPoint != std::string::npos); std::string envKey = envKeyValue.substr(0, splitPoint); std::string envValue = envKeyValue.substr(splitPoint + 1); _envp.emplace(std::move(envKey), std::move(envValue)); ++environEntry; } #endif bool needsPort = isMongodProgram || isMongosProgram || (programName == "mongobridge"); if (!needsPort) { _port = -1; } uassert(ErrorCodes::FailedToParse, str::stream() << "a port number is expected when running " << program << " from the shell", !needsPort || _port >= 0); uassert(ErrorCodes::BadValue, str::stream() << "can't start " << program << ", port " << _port << " already in use", _port < 0 || !registry.isPortRegistered(_port)); }