IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29625


Ignore:
Timestamp:
Nov 1, 2010, 12:51:37 PM (16 years ago)
Author:
bills
Message:

When processing root node, insert the streaks object before the node result.
Change -addmask to not set magicRun.state to full. Do that in addresult
if node == 'root' and fault == 0. In revert delete mask objects if the
associted root node is faulted.

Location:
trunk
Files:
1 added
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_process.pl

    r29524 r29625  
    325325}
    326326
    327 ### Input result into database
    328 {
    329     my $command = "$magictool -addresult";
    330     $command   .= " -magic_id $magic_id";
    331     $command   .= " -node $node";
    332     $command   .= " -path_base $outroot";
    333     $command   .= " -dbname $dbname" if defined $dbname;
    334 
    335     # Add the processed file to the database
    336     unless ($no_update) {
    337         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    338             run(command => $command, verbose => $verbose);
    339         unless ($success) {
    340             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    341             &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code);
    342         }
    343     } else {
    344         print "Skipping command: $command\n";
    345     }
    346 }
    347327
    348328if ($node eq "root") {
     
    376356        my $exposures = $mdcParser->parse_list(join "", @$stdout_buf);
    377357        my $exp = $$exposures[0]; # Exposure of interest (should only be one)
     358        if (!$exp) {
     359            &my_die("magictool -exposure returned no output", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     360        }
    378361
    379362        $exp_id = $exp->{exp_id};
     
    429412            unless ($success) {
    430413                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    431                 # XXX: This my_die isn't going to work because the result for the root node was already
    432                 # added to the database up above.
    433                 # There is a magicMask has a fault column. Maybe we should
    434                 # use that and add a new revert mode that deletes the magicMask and the magicNodeResult
    435                 # for the root node.
    436414                &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code);
    437415            }
     
    439417            print "Skipping command: $command\n";
    440418        }
     419    }
     420}
     421
     422    ### Input result into database
     423{
     424    my $command = "$magictool -addresult";
     425    $command   .= " -magic_id $magic_id";
     426    $command   .= " -node $node";
     427    $command   .= " -path_base $outroot";
     428    $command   .= " -dbname $dbname" if defined $dbname;
     429
     430    # Add the processed file to the database
     431    unless ($no_update) {
     432        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     433            run(command => $command, verbose => $verbose);
     434        unless ($success) {
     435            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     436            # XXX: if this is the root node we need to revert delete the magicMask object
     437            # inserted above
     438            &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code);
     439        }
     440    } else {
     441        print "Skipping command: $command\n";
    441442    }
    442443}
  • trunk/ippTools/share/Makefile.am

    r29611 r29625  
    213213        flatcorr_dropchip.sql \
    214214        flatcorr_dropcamera.sql \
    215         magictool_addmask.sql \
     215        magictool_deletemask.sql \
    216216        magictool_restore_camera.sql \
    217217        magictool_restore_chip.sql \
     
    237237        magictool_revertnode.sql \
    238238        magictool_exposure.sql \
     239        magictool_setfull.sql \
    239240        magicdstool_clearstatefaults.sql \
    240241        magicdstool_change_file_data_state.sql \
  • trunk/ippTools/src/magictool.c

    r29553 r29625  
    10591059    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    10601060
     1061    if (!psDBTransaction(config->dbh)) {
     1062        psError(PS_ERR_UNKNOWN, false, "database error");
     1063        return false;
     1064    }
     1065
    10611066    if (!magicNodeResultInsert(config->dbh,
    10621067                               magic_id,
     
    10691074    }
    10701075
     1076    if (fault == 0 && !strcmp(node, "root")) {
     1077        // Set the magicRun state
     1078        psString query = pxDataGet("magictool_setfull.sql");
     1079        if (!query) {
     1080            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1081            if (!psDBRollback(config->dbh)) {
     1082                psError(PS_ERR_UNKNOWN, false, "database error");
     1083            }
     1084            return false;
     1085        }
     1086
     1087        // manually add constraint
     1088        psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);
     1089
     1090        if (!p_psDBRunQuery(config->dbh, query)) {
     1091            psError(PS_ERR_UNKNOWN, false, "database error");
     1092            psFree(query);
     1093            if (!psDBRollback(config->dbh)) {
     1094                psError(PS_ERR_UNKNOWN, false, "database error");
     1095            }
     1096            return false;
     1097        }
     1098        psFree(query);
     1099    }
     1100    if (!psDBCommit(config->dbh)) {
     1101        psError(PS_ERR_UNKNOWN, false, "database error");
     1102        return false;
     1103    }
     1104
    10711105    return true;
    10721106}
     
    10821116    pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "==");
    10831117
    1084     psString query = pxDataGet("magictool_revertnode.sql");
     1118    if (!psListLength(where->list)) {
     1119        psError(PS_ERR_UNKNOWN, false, "search parameters are required");
     1120        psFree(where);
     1121        return false;
     1122    }
     1123    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1124    psFree(where);
     1125
     1126    // don't need a transaction because it is ok if the first query succeeds
     1127    // but the second query does not
     1128    psString query = pxDataGet("magictool_deletemask.sql");
    10851129    if (!query) {
    10861130        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    10871131        return false;
    10881132    }
    1089 
    1090     if (psListLength(where->list)) {
    1091         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1092         psStringAppend(&query, " AND %s", whereClause);
     1133    psStringAppend(&query, " AND %s", whereClause);
     1134    if (!p_psDBRunQuery(config->dbh, query)) {
    10931135        psFree(whereClause);
    1094     } else {
    1095         psError(PS_ERR_UNKNOWN, false, "search parameters are required");
    1096         psFree(where);
    1097         return false;
    1098     }
    1099     psFree(where);
     1136        psFree(query);
     1137        psError(PS_ERR_UNKNOWN, false, "failed to delete faulted masks");
     1138        return false;
     1139    }
     1140    psFree(query);
     1141
     1142    query = pxDataGet("magictool_revertnode.sql");
     1143    if (!query) {
     1144        psFree(whereClause);
     1145        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1146        return false;
     1147    }
     1148    psStringAppend(&query, " AND %s", whereClause);
     1149    psFree(whereClause);
    11001150
    11011151    if (!p_psDBRunQuery(config->dbh, query)) {
     1152        psFree(query);
    11021153        psError(PS_ERR_UNKNOWN, false, "failed to revert");
    11031154        return false;
    11041155    }
     1156    psFree(query);
    11051157
    11061158    psS32 numUpdated = psDBAffectedRows(config->dbh);
     
    11801232    // required
    11811233    PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false);
     1234    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    11821235
    11831236    // optional
    1184 //    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
    1185     PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
    11861237    PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false);
    1187 
    1188     // default values
    11891238    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
    1190 
    1191     if (!psDBTransaction(config->dbh)) {
    1192         psError(PS_ERR_UNKNOWN, false, "database error");
    1193         return false;
    1194     }
    11951239
    11961240    if (!magicMaskInsert(config->dbh,
     
    12051249            psError(PS_ERR_UNKNOWN, false, "database error");
    12061250        }
    1207         return false;
    1208     }
    1209 
    1210     // Set the magicRun state
    1211     psString query = pxDataGet("magictool_addmask.sql");
    1212     if (!query) {
    1213         psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    1214         if (!psDBRollback(config->dbh)) {
    1215             psError(PS_ERR_UNKNOWN, false, "database error");
    1216         }
    1217         return false;
    1218     }
    1219 
    1220     // manually add constraint
    1221     psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);
    1222 
    1223     if (!p_psDBRunQuery(config->dbh, query)) {
    1224         psError(PS_ERR_UNKNOWN, false, "database error");
    1225         psFree(query);
    1226         if (!psDBRollback(config->dbh)) {
    1227             psError(PS_ERR_UNKNOWN, false, "database error");
    1228         }
    1229         return false;
    1230     }
    1231     psFree(query);
    1232 
    1233     if (!psDBCommit(config->dbh)) {
    1234         psError(PS_ERR_UNKNOWN, false, "database error");
    12351251        return false;
    12361252    }
Note: See TracChangeset for help on using the changeset viewer.