Esempio n. 1
0
/*******************************************
* WorkflowRunFromCMDLineBase
*******************************************/
WorkflowRunFromCMDLineBase::WorkflowRunFromCMDLineBase()
    : Task(tr("Workflow run from cmdline"), TaskFlag_None),
      schema(NULL),
      optionsStartAt(-1),
      loadTask(NULL),
      workflowRunTask(NULL)
{
    GCOUNTER(cvar,tvar,"workflow_run_from_cmdline");

    CMDLineRegistry * cmdLineRegistry = AppContext::getCMDLineRegistry();

    // try to process schema without 'task' option (it can only be the first one)
    QStringList pureValues = CMDLineRegistryUtils::getPureValues();
    if( !pureValues.isEmpty() ) {
        QString schemaName = pureValues.first();
        processLoadSchemaTask( schemaName, 1 ); // because after program name
    }
    if( loadTask != NULL ) {
        addSubTask( loadTask );
        return;
    }

    // process schema with 'task' option
    int taskOptionIdx = CMDLineRegistryUtils::getParameterIndex( WorkflowDesignerPlugin::RUN_WORKFLOW );
    if(taskOptionIdx != -1) {
        processLoadSchemaTask( cmdLineRegistry->getParameterValue( WorkflowDesignerPlugin::RUN_WORKFLOW, taskOptionIdx ), taskOptionIdx );
    }
    if( loadTask == NULL ) {
        setError( tr( "no task to run" ) );
        return;
    }
    addSubTask( loadTask );
}
Esempio n. 2
0
void DumpLicenseTask::initHelp() {
    CMDLineRegistry * cmdlineRegistry = AppContext::getCMDLineRegistry();

    CMDLineHelpProvider * helpSection = new CMDLineHelpProvider(
        LICENSE_CMDLINE_OPTION,
        tr( "Shows license information." ));

    cmdlineRegistry->registerCMDLineHelpProvider(helpSection);
}
Esempio n. 3
0
void WorkflowRunFromCMDLineBase::run() {
    CMDLineRegistry *cmdLineRegistry = AppContext::getCMDLineRegistry();
    SAFE_POINT(NULL != cmdLineRegistry, "CMDLineRegistry is NULL", );
    CHECK(NULL != workflowRunTask, );

    const QString reportFilePath = cmdLineRegistry->getParameterValue(CmdlineTaskRunner::REPORT_FILE_ARG);
    CHECK(!reportFilePath.isEmpty(), );

    QFile reportFile(reportFilePath);
    const bool opened = reportFile.open(QIODevice::WriteOnly);
    CHECK_EXT(opened, setError(L10N::errorOpeningFileWrite(reportFilePath)), );

    reportFile.write(workflowRunTask->generateReport().toLocal8Bit());
}
Esempio n. 4
0
Task* GUITestService::createTestSuiteLauncherTask() const {

    Q_ASSERT(!testLauncher);

    CMDLineRegistry* cmdLine = AppContext::getCMDLineRegistry();
    Q_ASSERT(cmdLine);

    bool ok;
    int suiteNumber = cmdLine->getParameterValue(CMDLineCoreOptions::LAUNCH_GUI_TEST_SUITE).toInt(&ok);
    if(!ok){
        QString pathToSuite = cmdLine->getParameterValue(CMDLineCoreOptions::LAUNCH_GUI_TEST_SUITE);
        Task *task = new GUITestLauncher(pathToSuite);
        Q_ASSERT(task);
        return task;
    }

    Task *task = new GUITestLauncher(suiteNumber);
    Q_ASSERT(task);

    return task;
}
void WorkflowDesignerPlugin::registerCMDLineHelp() {
    CMDLineRegistry * cmdLineRegistry = AppContext::getCMDLineRegistry();
    assert( NULL != cmdLineRegistry );

    CMDLineHelpProvider * taskSection = new CMDLineHelpProvider(
        RUN_WORKFLOW,
        tr("Runs the specified task."),
        tr("Runs the specified task. A path to a user-defined UGENE workflow"
           " be used as a task name."),
        tr("<task_name> [<task_parameter>=value ...]"));

    cmdLineRegistry->registerCMDLineHelpProvider( taskSection );

    CMDLineHelpProvider * printSection = new CMDLineHelpProvider(
        PRINT,
        tr("Prints the content of the specified slot."),
        tr("Prints the content of the specified slot. The incoming/outcoming content of"
        " specified slot is printed to the standard output."),
        tr("<actor_name>.<port_name>.<slot_name>"));
    Q_UNUSED(printSection);

    CMDLineHelpProvider * galaxyConfigSection = new CMDLineHelpProvider(
        GalaxyConfigTask::GALAXY_CONFIG_OPTION,
        tr("Creates new Galaxy tool config."),
        tr("Creates new Galaxy tool config from existing workflow. Paths to UGENE"
        " and Galaxy can be set"),
        tr("<uwl-file> [--ugene-path=value] [--galaxy-path=value]"));

    cmdLineRegistry->registerCMDLineHelpProvider( galaxyConfigSection );

    //CMDLineHelpProvider * remoteMachineSectionArguments = new CMDLineHelpProvider( REMOTE_MACHINE, "<path-to-machine-file>");
    //CMDLineHelpProvider * remoteMachineSection = new CMDLineHelpProvider( REMOTE_MACHINE, tr("run provided tasks on given remote machine") );
    //TODO: bug UGENE-23
    //cmdLineRegistry->registerCMDLineHelpProvider( remoteMachineSectionArguments );
    //cmdLineRegistry->registerCMDLineHelpProvider( remoteMachineSection );
}
Esempio n. 6
0
void PhylipPlugin::processCmdlineOptions() {
    CMDLineRegistry *cmdLineRegistry = AppContext::getCMDLineRegistry();
    CHECK(cmdLineRegistry->hasParameter(PhylipCmdlineTask::PHYLIP_CMDLINE), );
    CHECK(cmdLineRegistry->hasParameter(CmdlineInOutTaskRunner::OUT_DB_ARG), );
    CHECK(cmdLineRegistry->hasParameter(CmdlineInOutTaskRunner::IN_DB_ARG), );
    CHECK(cmdLineRegistry->hasParameter(CmdlineInOutTaskRunner::IN_ID_ARG), );

    CreatePhyTreeSettings settings = fetchSettings();
    QString outDbString = cmdLineRegistry->getParameterValue(CmdlineInOutTaskRunner::OUT_DB_ARG);
    QString inDbString = cmdLineRegistry->getParameterValue(CmdlineInOutTaskRunner::IN_DB_ARG);
    QString idString = cmdLineRegistry->getParameterValue(CmdlineInOutTaskRunner::IN_ID_ARG);

    U2OpStatus2Log os;
    U2DbiRef outDbiRef = CmdlineInOutTaskRunner::parseDbiRef(outDbString, os);
    CHECK_OP(os, );
    U2DbiRef inDbiRef = CmdlineInOutTaskRunner::parseDbiRef(inDbString, os);
    CHECK_OP(os, );
    U2DataId dataId = CmdlineInOutTaskRunner::parseDataId(idString, inDbiRef, os);
    CHECK_OP(os, );

    Task *t = new PhylipTask(U2EntityRef(inDbiRef, dataId), outDbiRef, settings);
    connect(AppContext::getPluginSupport(), SIGNAL(si_allStartUpPluginsLoaded()), new TaskStarter(t), SLOT(registerTask()));
}
Esempio n. 7
0
void ConsoleLogDriver::setLogSettings() {
    CMDLineRegistry *cmd = AppContext::getCMDLineRegistry();
    if(cmd->hasParameter(CMDLineCoreOptions::LOG_FORMAT)) {
       QString logFormat = cmd->getParameterValue(CMDLineCoreOptions::LOG_FORMAT);
       settings.showLevel = logFormat.contains("L", Qt::CaseSensitive);
       settings.showCategory = logFormat.contains("C", Qt::CaseSensitive);
       settings.showDate = logFormat.contains(QRegExp("[M{2}Y{2,4}d{2}H{2}m{2}s{2}z{3}]"));
       settings.logPattern = logFormat;
    } else if(cmd->hasParameter( LOG_SHOW_DATE_CMD_OPTION ) || //old options
        cmd->hasParameter( LOG_SHOW_LEVEL_CMD_OPTION ) ||
        cmd->hasParameter( LOG_SHOW_CATEGORY_CMD_OPTION )){

        settings.logPattern = "";
        if (cmd->hasParameter( LOG_SHOW_DATE_CMD_OPTION )) {
            settings.showDate = true;
            settings.logPattern += "[hh:mm]";
        }
        if (cmd->hasParameter( LOG_SHOW_LEVEL_CMD_OPTION )) {
            settings.showLevel = true;
            settings.logPattern += "[L]";
        }
        if (cmd->hasParameter( LOG_SHOW_CATEGORY_CMD_OPTION )) {
            settings.showCategory = true;
            settings.logPattern += "[C]";
        }
    } else{
        settings.logPattern = "[hh:mm][L]";
    }

    QString logLevel;
    if(cmd->hasParameter(CMDLineCoreOptions::LOG_LEVEL)){
        logLevel = cmd->getParameterValue(CMDLineCoreOptions::LOG_LEVEL);
    } else if( cmd->hasParameter( LOG_LEVEL_NONE_CMD_OPTION ) ){
        logLevel = "NONE";
    } else if(cmd->hasParameter( LOG_LEVEL_ERROR_CMD_OPTION )) {
        logLevel = "ERROR";
    }else if( cmd->hasParameter( LOG_LEVEL_INFO_CMD_OPTION ) ) {
        logLevel = "INFO";
    } else if( cmd->hasParameter( LOG_LEVEL_DETAILS_CMD_OPTION ) ) {
        logLevel = "DETAILS";
    } else if( cmd->hasParameter( LOG_LEVEL_TRACE_CMD_OPTION ) ) {
        logLevel = "TRACE";
    }else {
        logLevel = "ERROR";
    }

    LogServer* ls = LogServer::getInstance();
    const QStringList& categoryList = ls->getCategories();
    logLevel = logLevel.remove(" ");
    QStringList cats = logLevel.split(QRegExp("[,=]"));

    LogCategories::init();
    if(cats.size() == 1) {
        int minLevel = 10;
        for (int i=0; i<LogLevel_NumLevels; i++) {
            if(getLevelName((LogLevel)i) == logLevel) {
                minLevel = i;
            }
        }
        for (int i=0; i<LogLevel_NumLevels; i++) {
            settings.activeLevelGlobalFlag[i] = (i >= minLevel);
        }
        foreach(const QString &str, categoryList) {
            LoggerSettings cs;
            cs.categoryName = str;
            for (int i=0; i<LogLevel_NumLevels; i++) {
                cs.activeLevelFlag[i] = (i >= minLevel);
            }
            settings.categories[str] = cs;
        }
Esempio n. 8
0
void CMDLineRegistryUtils::setCMDLineParams( QList<StringPair> & to ) {
    CMDLineRegistry * cmdlineRegistry = AppContext::getCMDLineRegistry();
    if( cmdlineRegistry != NULL ) {
        to = cmdlineRegistry->getParameters();
    }
}