IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11731


Ignore:
Timestamp:
Feb 9, 2007, 11:56:47 AM (19 years ago)
Author:
jhoblitt
Message:

add p4tool -updaterun

Location:
trunk/ippTools/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/warptool.c

    r11723 r11731  
    3232
    3333static bool definerunMode(pxConfig *config);
     34static bool updaterunMode(pxConfig *config);
    3435static bool addinputexpMode(pxConfig *config);
    3536static bool toscfileMode(pxConfig *config);
     
    4344static bool diffimfileMode(pxConfig *config);
    4445
     46static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state);
     47static bool isValidMode(pxConfig *config, const char *mode);
     48
    4549# define MODECASE(caseName, func) \
    4650    case caseName: \
     
    5862    switch (config->mode) {
    5963        MODECASE(P4TOOL_MODE_DEFINERUN,         definerunMode);
     64        MODECASE(P4TOOL_MODE_UPDATERUN,         updaterunMode);
    6065        MODECASE(P4TOOL_MODE_ADDINPUTEXP,       addinputexpMode);
    6166        MODECASE(P4TOOL_MODE_TOSCFILE,          toscfileMode);
     
    8893}
    8994
     95
    9096static bool definerunMode(pxConfig *config)
    9197{
     
    101107    if (!mode) {
    102108        psError(PS_ERR_UNKNOWN, true, "-mode is required");
     109        return false;
     110    }
     111    // check mode
     112    if (mode && !isValidMode(config, mode)) {
     113        psError(PS_ERR_UNKNOWN, false, "invalud mode");
    103114        return false;
    104115    }
     
    168179    return true;
    169180}
     181
     182
     183static bool updaterunMode(pxConfig *config)
     184{
     185    PS_ASSERT_PTR_NON_NULL(config, false);
     186
     187    bool status = false;
     188    psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");
     189    if (!status) {
     190        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4t_id");
     191        return false;
     192    }
     193    if (!p4_id) {
     194        psError(PS_ERR_UNKNOWN, true, "-p4_id is required");
     195        return false;
     196    }
     197
     198    psString state = psMetadataLookupStr(&status, config->args, "-state");
     199    if (!status) {
     200        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
     201        return false;
     202    }
     203    if (!state) {
     204        psError(PS_ERR_UNKNOWN, true, "-state is required");
     205        return false;
     206    }
     207
     208    if (state) {
     209        // set detRun.state to state
     210        return setp4RunState(config, p4_id, state);
     211    }
     212
     213    return true;
     214}
     215
    170216
    171217static bool addinputexpMode(pxConfig *config)
     
    857903    return true;
    858904}
     905
     906static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state)
     907{
     908    PS_ASSERT_PTR_NON_NULL(p4_id, false);
     909    PS_ASSERT_PTR_NON_NULL(state, false);
     910
     911    // check that state is a valid string value
     912    if (!(
     913            (strncmp(state, "run", 4) == 0)
     914            || (strncmp(state, "stop", 5) == 0)
     915            || (strncmp(state, "reg", 4) == 0)
     916        )
     917    ) {
     918        psError(PS_ERR_UNKNOWN, false,
     919                "invalid p4Run state: %s", state);
     920        return false;
     921    }
     922
     923    char *query = "UPDATE p4Run SET state = '%s' WHERE det_id = '%s'";
     924    if (!p_psDBRunQuery(config->dbh, query, state, p4_id)) {
     925        psError(PS_ERR_UNKNOWN, false,
     926                "failed to change state for det_id %s", p4_id);
     927        return false;
     928    }
     929
     930    return true;
     931}
     932
     933static bool isValidMode(pxConfig *config, const char *mode)
     934{
     935    PS_ASSERT_PTR_NON_NULL(config, false);
     936    PS_ASSERT_PTR_NON_NULL(mode, false);
     937
     938    // check that state is a valid string value
     939    if (!(
     940            (strncmp(mode, "master", 7) == 0)
     941            || (strncmp(mode, "verify", 7) == 0)
     942        )
     943    ) {
     944        psError(PS_ERR_UNKNOWN, false,
     945                "invalid detRun mode: %s", mode);
     946        return false;
     947    }
     948
     949    return true;
     950}
  • trunk/ippTools/src/warptool.h

    r11723 r11731  
    2626    P4TOOL_MODE_NONE           = 0x0,
    2727    P4TOOL_MODE_DEFINERUN,
     28    P4TOOL_MODE_UPDATERUN,
    2829    P4TOOL_MODE_ADDINPUTEXP,
    2930    P4TOOL_MODE_TOSCFILE,
  • trunk/ippTools/src/warptoolConfig.c

    r11723 r11731  
    5656    psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple",  0,
    5757            "use the simple output format", false);
     58 
     59    // -updaterun
     60    psMetadata *updaterunArgs = psMetadataAlloc();
     61    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-p4_id", 0,
     62            "define p4 ID (required)", NULL);
     63    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0,
     64            "set state (required)", NULL);
     65#if 0
     66    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-workdir", 0,
     67            "define workdir (required)", NULL);
     68    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-registered",  0,
     69            "time detrend run was registered", now);
     70#endif
    5871
    5972    // -addinputexp
     
    194207    // find which mode we're running under
    195208    PXTOOL_MODE("-definerun",       P4TOOL_MODE_DEFINERUN,      definerunArgs);
     209    PXTOOL_MODE("-updaterun",       P4TOOL_MODE_UPDATERUN,      updaterunArgs);
    196210    PXTOOL_MODE("-addinputexp",     P4TOOL_MODE_ADDINPUTEXP,    addinputexpArgs);
    197211    PXTOOL_MODE("-toscfile",        P4TOOL_MODE_TOSCFILE,       toscfileArgs);
Note: See TracChangeset for help on using the changeset viewer.