HTTPLiveStream::HTTPLiveStream(QString srcFile, uint16_t width, uint16_t height, uint32_t bitrate, uint32_t abitrate, uint16_t maxSegments, uint16_t segmentSize, uint32_t aobitrate, int32_t srate) : m_writing(false), m_streamid(-1), m_sourceFile(srcFile), m_sourceWidth(0), m_sourceHeight(0), m_segmentSize(segmentSize), m_maxSegments(maxSegments), m_segmentCount(0), m_startSegment(0), m_curSegment(0), m_height(height), m_width(width), m_bitrate(bitrate), m_audioBitrate(abitrate), m_audioOnlyBitrate(aobitrate), m_sampleRate(srate), m_created(MythDate::current()), m_lastModified(MythDate::current()), m_percentComplete(0), m_status(kHLSStatusUndefined) { if ((m_width == 0) && (m_height == 0)) m_width = 640; if (m_bitrate == 0) m_bitrate = 800000; if (m_audioBitrate == 0) m_audioBitrate = 64000; if (m_segmentSize == 0) m_segmentSize = 10; if (m_audioOnlyBitrate == 0) m_audioOnlyBitrate = 32000; m_sourceHost = gCoreContext->GetHostName(); QFileInfo finfo(m_sourceFile); m_outBase = finfo.fileName() + QString(".%1x%2_%3kV_%4kA").arg(m_width).arg(m_height) .arg(m_bitrate/1000).arg(m_audioBitrate/1000); SetOutputVars(); m_fullURL = m_httpPrefix + m_outBase + ".m3u8"; m_relativeURL = m_httpPrefixRel + m_outBase + ".m3u8"; StorageGroup sgroup("Streaming", gCoreContext->GetHostName()); m_outDir = sgroup.GetFirstDir(); QDir outDir(m_outDir); if (!outDir.exists() && !outDir.mkdir(m_outDir)) { LOG(VB_RECORD, LOG_ERR, "Unable to create HTTP Live Stream output " "directory, Live Stream will not be created"); return; } AddStream(); }
void PhraseDictionaryTransliteration::GetTargetPhraseCollection(InputPath &inputPath) const { const Phrase &sourcePhrase = inputPath.GetPhrase(); size_t hash = hash_value(sourcePhrase); CacheColl &cache = GetCache(); std::map<size_t, std::pair<const TargetPhraseCollection*, clock_t> >::iterator iter; iter = cache.find(hash); if (iter != cache.end()) { // already in cache const TargetPhraseCollection *tpColl = iter->second.first; inputPath.SetTargetPhrases(*this, tpColl, NULL); } else { // TRANSLITERATE char *ptr = tmpnam(NULL); string inFile(ptr); ptr = tmpnam(NULL); string outDir(ptr); ofstream inStream(inFile.c_str()); inStream << sourcePhrase.ToString() << endl; inStream.close(); string cmd = m_scriptDir + "/Transliteration/prepare-transliteration-phrase-table.pl" + " --transliteration-model-dir " + m_filePath + " --moses-src-dir " + m_mosesDir + " --external-bin-dir " + m_externalDir + " --input-extension " + m_inputLang + " --output-extension " + m_outputLang + " --oov-file " + inFile + " --out-dir " + outDir; int ret = system(cmd.c_str()); UTIL_THROW_IF2(ret != 0, "Transliteration script error"); TargetPhraseCollection *tpColl = new TargetPhraseCollection(); vector<TargetPhrase*> targetPhrases = CreateTargetPhrases(sourcePhrase, outDir); vector<TargetPhrase*>::const_iterator iter; for (iter = targetPhrases.begin(); iter != targetPhrases.end(); ++iter) { TargetPhrase *tp = *iter; tpColl->Add(tp); } std::pair<const TargetPhraseCollection*, clock_t> value(tpColl, clock()); cache[hash] = value; inputPath.SetTargetPhrases(*this, tpColl, NULL); // clean up temporary files remove(inFile.c_str()); cmd = "rm -rf " + outDir; system(cmd.c_str()); } }
int main(int argc, char **argv) { po::options_description desc("Options"); desc.add_options() ("help,h", "Print help messages") ("indir", po::value<std::string>()->required(), "input directory") ("outdir", po::value<std::string>()->required(), "output directory"); po::positional_options_description posOpt; posOpt.add("indir", 1); posOpt.add("outdir", 1); po::variables_map vm; try { po::store(po::command_line_parser(argc, argv) .options(desc).positional(posOpt).run(), vm); if (vm.count("help") ) { std::cout << "Usage: stacktr INDIR OUTDIR" << std::endl; std::cout << std::endl; std::cout << " INDIR is the input directory" << std::endl; std::cout << " OUTDIR is the output directory" << std::endl; return 0; } po::notify(vm); // } catch (po::required_option &e) { std::cerr << "Missing a required option" << std::endl; return 1; } catch (po::error &e) { std::cerr << "Something wrong during the parsing" << std::endl; return 2; } std::cout << std::endl; fs::path inDir(vm["indir"].as<std::string>()); fs::path outDir(vm["outdir"].as<std::string>()); std::vector<fs::path> fileList; retrieveFileList(fileList, inDir); // Create folder if not exist. boost::system::error_code retErr; fs::create_directories(outDir, retErr); if (!retErr) { std::cout << "Output directory created" << std::endl; } // Transposed stack will contain as much layer as the amount of stacks. size_t nLayer = fileList.size(); processFileList(fileList, outDir, static_cast<uint16_t>(nLayer)); waitForKeypress(); return 0; }
void AddImageWidget::checkFiles() { QString imagePath = imageWgt->text(); if ( ! QFile::exists(imagePath)) { qCritical() << QString("File %1 not found!").arg(imagePath); imageLabel->setStyleSheet("QLabel { color : red; }"); return; } QString kmlPath = kmlWgt->text(); if ( ! QFile::exists(kmlPath)) { qCritical() << QString("File %1 not found!").arg(kmlPath); kmlLabel->setStyleSheet("QLabel { color : red; }"); return; } qint32 lowZoomValue = lowZoom->value(); qint32 topZoomValue = topZoom->value(); if (lowZoomValue > topZoomValue) { lowZoomValue = topZoomValue; topZoomValue = lowZoom->value(); } QString zoomStr = (lowZoomValue == topZoomValue) ? QString::number(lowZoomValue) : QString("%1-%2").arg(lowZoomValue).arg(topZoomValue); QFileInfo fi(imagePath); granuleName = fi.fileName(); QDir outDir(_configData->cacheDir); if (QDir(_configData->cacheDir+"/"+granuleName).exists()) { tileCreatedSlot(); close(); return; } outDir.mkdir(granuleName); outDir.cd(granuleName); QString cmd = QString("python slbtiles.py --image %1 --kml %2 --zoom %3 -o %4") .arg(imagePath).arg(kmlPath).arg(zoomStr).arg(outDir.path()); qDebug() << "==> " << cmd; tileProc = new QProcess(this); connect(tileProc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(tileCreatedSlot(int,QProcess::ExitStatus))); tileProc->start(cmd); close(); }
void ElastixManager::preprocessExecuter() { QStringList parameterFiles = mParameters->getActiveParameterFiles(); QString timestamp = QDateTime::currentDateTime().toString(timestampSecondsFormat()); QDir outDir(mServices->patient()->getActivePatientFolder()+"/"+mParameters->getConfigUid()+"/"+timestamp); mExecuter->setDisplayProcessMessages(mDisplayProcessMessages->getValue()); mExecuter->setInput(mParameters->getActiveExecutable()->getEmbeddedPath().getAbsoluteFilepath(), mServices->registration()->getFixedData(), mServices->registration()->getMovingData(), outDir.absolutePath(), parameterFiles); if (mDisableRendering->getValue()) { mServices->view()->enableRender(false); } }
void HbSplashGenerator::regenerate() { QString themeName = hbInstance->theme()->name(); qDebug() << PRE << "regenerate() theme:" << themeName; if (!themeName.isEmpty()) { try { emit regenerateStarted(); QTime queuePrepTime; queuePrepTime.start(); // Delete existing splash screens. This is important because apps // should never pick up a screen with the previous theme or // language. If the generation of the new screens (at least the // empty view) has not finished when a new app is started then it is // better to show no splash screen at all. QDir outDir(hbsplash_output_dir()); if (outDir.exists()) { QStringList names = outDir.entryList(QStringList() << "*", QDir::Files); foreach(const QString & name, names) { outDir.remove(name); } } // Clear the queue, generating screens with a non-current theme is // not possible anyway. mQueue.clear(); // If this is the first invocation then put some requests for // screens we won't use. On certain platforms the very first // rendering (with a newly created mainwindow) may lead to // mysteriously scaled down output. if (mFirstRegenerate) { mFirstRegenerate = false; mQueue.enqueue(QueueItem(themeName, Qt::Vertical)); mQueue.enqueue(QueueItem(themeName, Qt::Horizontal)); } // Queue the screenshot request for both orientations. mQueue.enqueue(QueueItem(themeName, Qt::Vertical)); mQueue.enqueue(QueueItem(themeName, Qt::Horizontal)); queueAppSpecificItems(themeName, Qt::Vertical); queueAppSpecificItems(themeName, Qt::Horizontal); qDebug() << PRE << "queue preparation time (ms):" << queuePrepTime.elapsed(); QMetaObject::invokeMethod(this, "processQueue", Qt::QueuedConnection); } catch (const std::bad_alloc &) {
TskModule::Status TskExecutableModule::execute(TskFile * fileToAnalyze){ try { // Perform macro expansion on command line args. std::string arguments = expandArgumentMacros(m_arguments, fileToAnalyze); // Split the arguments into a vector of strings. Poco::StringTokenizer tokenizer(arguments, " "); std::vector<std::string> vectorArgs(tokenizer.begin(), tokenizer.end()); // Perform macro expansion on our output location std::string outFilePath = expandArgumentMacros(m_output, fileToAnalyze); // If an output file has been specified we need to ensure that anything // written to stdout gets put in the file. This is accomplished by passing // a pipe to Poco::Process::launch and reading its contents once the process // has terminated. if (!outFilePath.empty()) { // Create directories that may be missing along the path. std::string outFilePathNoQuote(TskUtilities::stripQuotes(outFilePath)); Poco::Path outPath(outFilePathNoQuote); Poco::File outDir(outPath.parent()); outDir.createDirectories(); // Create the output file if it does not exist. Poco::File outFile(outFilePathNoQuote); if (!outFile.exists()) { outFile.createFile(); } // Create process redirecting its output to a Pipe. Poco::Pipe outPipe; Poco::ProcessHandle handle = Poco::Process::launch(m_modulePath, vectorArgs, NULL, &outPipe, NULL); // Copy output from Pipe to the output file. Poco::PipeInputStream istr(outPipe); Poco::FileOutputStream ostr(outFile.path(), std::ios::out|std::ios::app); while (istr) { Poco::StreamCopier::copyStream(istr, ostr); } // The process should be finished. Check its exit code. int exitCode = Poco::Process::wait(handle); if (exitCode != 0) { // If a module fails we log a warning message and continue. std::wstringstream msg; msg << L"TskExecutableModule::execute - Module (" << m_modulePath.c_str() << L") failed with exit code: " << exitCode << std::endl; LOGWARN(msg.str()); } } else { // No output file was specified. Poco::ProcessHandle handle = Poco::Process::launch(m_modulePath, vectorArgs); // Wait for the process to complete int exitCode = Poco::Process::wait(handle); if (exitCode != 0) { // If a module fails we log a warning message and continue. std::wstringstream msg; msg << L"TskExecutableModule::execute - Module (" << m_modulePath.c_str() << L") failed with exit code: " << exitCode << std::endl; LOGWARN(msg.str()); } } } catch (Poco::Exception& ex) { std::wstringstream errorMsg; errorMsg << L"TskExecutableModule::execute - Error: " << ex.displayText().c_str() << std::endl; LOGERROR(errorMsg.str()); throw TskException("Module execution failed."); } return TskModule::OK; }
int main(int argc, char** argv) { cerr << "Starte mit einlesen\n"; if(argc <= 4) { cerr << "Usage: vpf_importer <DataBase> <Library> <Coverage(id)> <Feature(id)> [<first Element(id)>]\n"; return 1; } // Zielverzeichnis der Kartendateien ... string outDir((string)"/data/KartenDaten/VPF-Daten/heiner/" + argv[2] + "/"); VpfRectangle bounds; bounds.minX = -180.0; bounds.maxX = 180.0; bounds.minY = -90.0; bounds.maxY = 90.0; VpfDataBase db( argv[1] ); cout << "Number of libraries: " << db.getLibraryCount() << endl; VpfLibrary lib( db.getLibrary(argv[2]) ); cout << "Number of coverages: " << lib.getCoverageCount() << endl; int coverCount = lib.getCoverageCount(); cout << "<->\n"; int cID(0), fID(0), idStart(0); sscanf(argv[3], "%d", &cID); sscanf(argv[4], "%d", &fID); if(argc > 5) { sscanf(argv[5], "%d", &idStart); } VpfCoverage cover(lib.getCoverage(cID)); int featureCount = cover.getFeatureCount(); cout << "Coverage: " << cover.getName() << " (" << cID << ") Features: " << cover.getFeatureCount() << endl; VpfFeature feature(cover.getFeature(fID)); string fileName((string)argv[1] + "/" + (string)argv[2] + "/" + (string)cover.getName() + "/" + (string)feature.getName()); // Ausgabe-Datei öffnen: string outFileName((string)cover.getName() + "_" + (string)feature.getName()); string idFileName = outDir + "/IDS/" + outFileName + ".id"; outFileName = outDir + outFileName; ofstream outFile; ifstream idFile; cout << "\n"; cout << " Öffne Ausgabedatei: " << outFileName << " ..."; /* idFile.open(idFileName.c_str(), ios::in); if(!idFile) { cerr << "FEHLER! bei ID File\n" << idFileName.c_str() << endl; return 0; } */ outFile.open(outFileName.c_str(), ios::out | ios::app ); if(!outFile) { cerr << "FEHLER!\n"; return 1; } else { cout << "fertig\n"; } cout << endl; cout << " Bearbeite " << cover.getName() << " (" << cID << ") " << feature.getName() << " (" << fID << ")\n"; switch(feature.getTopologyType()) { case VpfFeature::POINT: fileName += ".pft"; break; case VpfFeature::LINE: fileName += ".lft"; break; case VpfFeature::POLYGON: fileName += ".aft"; break; case VpfFeature::LABEL: fileName += ".tft"; break; default: throw VpfException("Unsupported topology type"); } VpfTable table(fileName); dump_table_header(table, outFile); char p[20]; int id(-1), oldID(-1), rowLoop; int rowCount = table.getRowCount(); int colCount = table.getColumnCount(); int topologyType = feature.getTopologyType(); for(int rowLoop = idStart; rowLoop < table.getRowCount(); rowLoop++) { outFile << "[NEW]\n"; std::string header = ""; for(int colLoop = 0; colLoop < colCount; colLoop++) { outFile << table.getColumnDecl(colLoop).getName() << "=" << table.getValue(rowLoop, colLoop) << endl; } try { //cout << "\r"; cout << "id: "; cout.width(10); cout << rowLoop << " von "; cout.width(10); cout << rowCount << " ( "; cout.precision(2); cout.width(4); cout.setf(ios::fixed); cout << (float)((float)rowLoop / (float)rowCount * 100) << "% )\n"; switch(topologyType) { case VpfFeature::POINT: dump_point(feature.getPoint(rowLoop), outFile); break; case VpfFeature::LINE: dump_line(feature.getLine(rowLoop), outFile); break; case VpfFeature::POLYGON: dump_polygon(feature.getPolygon(rowLoop), outFile, table, rowLoop); break; case VpfFeature::LABEL: dump_label(feature.getLabel(rowLoop), outFile); break; default: throw VpfException("Unsupported topology type"); } } catch(VpfException &e) { cerr << "Fehler: " << e.getMessage() << endl; } outFile << "[END]\n"; } outFile.close(); cout << endl; return 0; }
void MergeFastqWorkerFactory::init() { Descriptor desc( ACTOR_ID, MergeFastqWorker::tr("FASTQ Merger"), MergeFastqWorker::tr("Merges input sequences to one output file") ); QList<PortDescriptor*> p; { Descriptor inD(BaseNGSWorker::INPUT_PORT, MergeFastqWorker::tr("Input File"), MergeFastqWorker::tr("Set of FASTQ reads files")); Descriptor outD(BaseNGSWorker::OUTPUT_PORT, MergeFastqWorker::tr("Output File"), MergeFastqWorker::tr("Output FASTQ file")); QMap<Descriptor, DataTypePtr> inM; inM[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); p << new PortDescriptor(inD, DataTypePtr(new MapDataType("cf.input-url", inM)), true); QMap<Descriptor, DataTypePtr> outM; outM[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); p << new PortDescriptor(outD, DataTypePtr(new MapDataType("cf.output-url", outM)), false, true); } QList<Attribute*> a; { Descriptor outDir(BaseNGSWorker::OUT_MODE_ID, MergeFastqWorker::tr("Output directory"), MergeFastqWorker::tr("Select an output directory. <b>Custom</b> - specify the output directory in the 'Custom directory' parameter. " "<b>Workflow</b> - internal workflow directory. " "<b>Input file</b> - the directory of the input file.")); Descriptor customDir(BaseNGSWorker::CUSTOM_DIR_ID, MergeFastqWorker::tr("Custom directory"), MergeFastqWorker::tr("Select the custom output directory.")); Descriptor outName(BaseNGSWorker::OUT_NAME_ID, MergeFastqWorker::tr("Output file name"), MergeFastqWorker::tr("A name of an output file. If default of empty value is provided the output name is the name of the first file with additional extention.")); a << new Attribute(outDir, BaseTypes::NUM_TYPE(), false, QVariant(FileAndDirectoryUtils::WORKFLOW_INTERNAL)); Attribute* customDirAttr = new Attribute(customDir, BaseTypes::STRING_TYPE(), false, QVariant("")); customDirAttr->addRelation(new VisibilityRelation(BaseNGSWorker::OUT_MODE_ID, FileAndDirectoryUtils::CUSTOM)); a << customDirAttr; a << new Attribute( outName, BaseTypes::STRING_TYPE(), false, QVariant(BaseNGSWorker::DEFAULT_NAME)); } QMap<QString, PropertyDelegate*> delegates; { QVariantMap directoryMap; QString fileDir = MergeFastqWorker::tr("Input file"); QString workflowDir = MergeFastqWorker::tr("Workflow"); QString customD = MergeFastqWorker::tr("Custom"); directoryMap[fileDir] = FileAndDirectoryUtils::FILE_DIRECTORY; directoryMap[workflowDir] = FileAndDirectoryUtils::WORKFLOW_INTERNAL; directoryMap[customD] = FileAndDirectoryUtils::CUSTOM; delegates[BaseNGSWorker::OUT_MODE_ID] = new ComboBoxDelegate(directoryMap); delegates[BaseNGSWorker::CUSTOM_DIR_ID] = new URLDelegate("", "", false, true); } ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); proto->setEditor(new DelegateEditor(delegates)); proto->setPrompter(new MergeFastqPrompter()); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_NGS_BASIC(), proto); DomainFactory *localDomain = WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID); localDomain->registerEntry(new MergeFastqWorkerFactory()); }
void QualityTrimWorkerFactory::init() { Descriptor desc( ACTOR_ID, QualityTrimWorker::tr("FASTQ Quality Trimmer"), QualityTrimWorker::tr("The workflow scans each input sequence from the end to find the first position where the quality is greater or equal to the minimum quality threshold. " "Then it trims the sequence to that position. If a the whole sequence has quality less than the threshold or the length of the output sequence less than " "the minimum length threshold then the sequence is skipped.") ); QList<PortDescriptor*> p; { Descriptor inD(BaseNGSWorker::INPUT_PORT, QualityTrimWorker::tr("Input File"), QualityTrimWorker::tr("Set of FASTQ reads files")); Descriptor outD(BaseNGSWorker::OUTPUT_PORT, QualityTrimWorker::tr("Output File"), QualityTrimWorker::tr("Output FASTQ files")); QMap<Descriptor, DataTypePtr> inM; inM[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); p << new PortDescriptor(inD, DataTypePtr(new MapDataType("cf.input-url", inM)), true); QMap<Descriptor, DataTypePtr> outM; outM[BaseSlots::URL_SLOT()] = BaseTypes::STRING_TYPE(); p << new PortDescriptor(outD, DataTypePtr(new MapDataType("cf.output-url", outM)), false, true); } QList<Attribute*> a; { Descriptor outDir(BaseNGSWorker::OUT_MODE_ID, QualityTrimWorker::tr("Output directory"), QualityTrimWorker::tr("Select an output directory. <b>Custom</b> - specify the output directory in the 'Custom directory' parameter. " "<b>Workflow</b> - internal workflow directory. " "<b>Input file</b> - the directory of the input file.")); Descriptor customDir(BaseNGSWorker::CUSTOM_DIR_ID, QualityTrimWorker::tr("Custom directory"), QualityTrimWorker::tr("Select the custom output directory.")); Descriptor outName(BaseNGSWorker::OUT_NAME_ID, QualityTrimWorker::tr("Output file name"), QualityTrimWorker::tr("A name of an output file. If default of empty value is provided the output name is the name of the first file with additional extention.")); Descriptor qualT(QUALITY_ID, QualityTrimWorker::tr("Quality threshold"), QualityTrimWorker::tr("Quality threshold for trimming.")); Descriptor lenT(LEN_ID, QualityTrimWorker::tr("Min Length"), QualityTrimWorker::tr("Too short reads are discarded by the filter.")); Descriptor bothD(BOTH_ID, QualityTrimWorker::tr("Trim both ends"), QualityTrimWorker::tr("Trim the both ends of a read or not. Usually, you need to set <b>True</b> for <b>Sanger</b> sequencing and <b>False</b> for <b>NGS</b>")); a << new Attribute(outDir, BaseTypes::NUM_TYPE(), false, QVariant(FileAndDirectoryUtils::WORKFLOW_INTERNAL)); Attribute* customDirAttr = new Attribute(customDir, BaseTypes::STRING_TYPE(), false, QVariant("")); customDirAttr->addRelation(new VisibilityRelation(BaseNGSWorker::OUT_MODE_ID, FileAndDirectoryUtils::CUSTOM)); a << customDirAttr; a << new Attribute( outName, BaseTypes::STRING_TYPE(), false, QVariant(BaseNGSWorker::DEFAULT_NAME)); a << new Attribute( qualT, BaseTypes:: NUM_TYPE(), false, QVariant(30)); a << new Attribute( lenT, BaseTypes::NUM_TYPE(), false, QVariant(0)); a << new Attribute( bothD, BaseTypes::BOOL_TYPE(), false, true); } QMap<QString, PropertyDelegate*> delegates; { QVariantMap directoryMap; QString fileDir = QualityTrimWorker::tr("Input file"); QString workflowDir = QualityTrimWorker::tr("Workflow"); QString customD = QualityTrimWorker::tr("Custom"); directoryMap[fileDir] = FileAndDirectoryUtils::FILE_DIRECTORY; directoryMap[workflowDir] = FileAndDirectoryUtils::WORKFLOW_INTERNAL; directoryMap[customD] = FileAndDirectoryUtils::CUSTOM; delegates[BaseNGSWorker::OUT_MODE_ID] = new ComboBoxDelegate(directoryMap); delegates[BaseNGSWorker::CUSTOM_DIR_ID] = new URLDelegate("", "", false, true); QVariantMap len; len["minimum"] = 0; len["maximum"] = INT_MAX; delegates[QUALITY_ID] = new SpinBoxDelegate(len); delegates[LEN_ID] = new SpinBoxDelegate(len); } ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a); proto->setEditor(new DelegateEditor(delegates)); proto->setPrompter(new QualityTrimPrompter()); WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_NGS_BASIC(), proto); DomainFactory *localDomain = WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID); localDomain->registerEntry(new QualityTrimWorkerFactory()); }