Changeset 29561
- Timestamp:
- Oct 26, 2010, 8:39:32 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 19 edited
-
ippScripts/scripts/magic_destreak.pl (modified) (6 diffs)
-
ippScripts/scripts/magic_destreak_cleanup.pl (modified) (3 diffs)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (4 diffs)
-
ippTasks/destreak.cleanup.pro (modified) (2 diffs)
-
ippTasks/destreak.pro (modified) (4 diffs)
-
ippTools/share/Makefile.am (modified) (2 diffs)
-
ippTools/share/chiptool_setimfiletoupdate.sql (modified) (1 diff)
-
ippTools/share/magicdstool_change_file_data_state.sql (added)
-
ippTools/share/magicdstool_change_run_state.sql (added)
-
ippTools/share/magicdstool_revertupdated.sql (added)
-
ippTools/share/magicdstool_setfiletoupdate.sql (added)
-
ippTools/share/magicdstool_todestreak_camera.sql (modified) (1 diff)
-
ippTools/share/magicdstool_todestreak_chip.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_todestreak_diff.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_todestreak_raw.sql (modified) (1 diff)
-
ippTools/share/magicdstool_todestreak_warp.sql (modified) (1 diff)
-
ippTools/share/magicdstool_torevert_chip.sql (modified) (1 diff)
-
ippTools/src/magicdstool.c (modified) (9 diffs)
-
ippTools/src/magicdstool.h (modified) (1 diff)
-
ippTools/src/magicdstoolConfig.c (modified) (3 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (5 diffs)
-
pstamp/scripts/pstamp_get_image_job.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_server_status (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak.pl
r29495 r29561 42 42 # Parse the command-line arguments 43 43 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction); 44 my ($streaks_path_base, $inv_streaks_path_base );44 my ($streaks_path_base, $inv_streaks_path_base, $run_state); 45 45 my ($outroot, $recoveryroot, $magicked); 46 46 my ($replace, $release); … … 50 50 'magic_ds_id=s' => \$magic_ds_id,# Magic destreak run identifier 51 51 'camera=s' => \$camera, # camera for evaluating file rules 52 'run-state=s' => \$run_state, # state of run (new or update) 52 53 'streaks_path_base=s' => \$streaks_path_base, # path_base for streaks data 53 54 'inv_streaks_path_base=s' => \$inv_streaks_path_base, #path_base for streaks from inverse diff … … 77 78 78 79 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 79 pod2usage( -msg => "Required options: --magic_ds_id --camera -- streaks --stage --stage_id --component --uri --path_base --outroot --magicked",80 pod2usage( -msg => "Required options: --magic_ds_id --camera --run_state --streaks --stage --stage_id --component --uri --path_base --outroot --magicked", 80 81 -exitval => 3) unless 81 82 defined $magic_ds_id and 82 83 defined $camera and 84 defined $run_state and 83 85 defined $streaks and 84 86 defined $streaks_path_base and … … 113 115 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 114 116 } 117 118 &my_die("Invalid value for run-state: $run_state", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 119 unless ($run_state eq 'new') or ($run_state eq 'update'); 120 115 121 $inv_streaks_path_base = undef if defined($inv_streaks_path_base) and ($inv_streaks_path_base eq "NULL"); 116 122 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL"); … … 479 485 # Input result into database 480 486 { 481 my $command = "$magicdstool -adddestreakedfile";487 my $command = "$magicdstool"; 482 488 $command .= " -magic_ds_id $magic_ds_id"; 483 489 $command .= " -component $component"; 484 490 $command .= " -setmagicked" if $replace; 485 $command .= " -backup_path_base $backup_path_base" if $backup_path_base; 486 $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base; 487 $command .= " $statsFlags" if $statsFlags; 491 if ($run_state eq 'new') { 492 $command .= " -adddestreakedfile"; 493 $command .= " -backup_path_base $backup_path_base" if $backup_path_base; 494 $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base; 495 $command .= " $statsFlags" if $statsFlags; 496 } else { 497 $command .= " -tofullfile"; 498 } 488 499 $command .= " -dbname $dbname" if defined $dbname; 489 500 … … 581 592 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 582 593 583 my $command = "$magicdstool -adddestreakedfile"; 594 my $command = "$magicdstool"; 595 596 if ($run_state eq 'new') { 597 $command .= " -adddestreakedfile"; 598 } else { 599 $command .= " -updatedestreakedfile"; 600 } 584 601 $command .= " -magic_ds_id $magic_ds_id"; 585 602 $command .= " -component $component"; -
trunk/ippScripts/scripts/magic_destreak_cleanup.pl
r29097 r29561 89 89 $q1 .= " WHERE magic_ds_id = $magic_ds_id"; 90 90 91 my $q2 = "SELECT * from magicDSFile wheremagic_ds_id = $magic_ds_id";91 my $q2 = "SELECT * from magicDSFile WHERE (data_state = 'full' OR data_state = 'update') AND magic_ds_id = $magic_ds_id"; 92 92 93 93 my $stmt1 = $dbh->prepare($q1); … … 245 245 delete_files($rimage, $rmask, $rweight, $rsources, undef, $bimage, $bmask, $bweight, $bsources); 246 246 } 247 } 248 249 $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n"; 250 251 if (!$no_update and ($num_components > 0)) { 252 my $result = $dbh->do("DELETE FROM magicDSFile WHERE magic_ds_id = ?", undef, $magic_ds_id); 253 # my $result = $stmt3->do($magic_ds_id); 254 my_die("attempt to delete magicDSFiles failed", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR) if $result eq "0E0"; 255 } 256 257 if (!$no_update) { 258 my $result = $dbh->do("UPDATE magicDSRun SET state = 'cleaned' WHERE magic_ds_id = ?", undef, $magic_ds_id); 259 my_die("attempt to update magicDSRun.state failed", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR) if $result eq "0E0"; 260 } else { 261 print STDERR "skipping update of magicDSRun\n"; 262 } 263 247 my $command = "$magicdstool -tocleanedfile -magic_ds_id $magic_ds_id -component $component"; 248 $command .= " -dbname $dbname" if defined $dbname; 249 250 unless ($no_update) { 251 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 252 run(command => $command, verbose => $verbose); 253 unless ($success) { 254 carp("failed to update database for $magic_ds_id"); 255 } 256 } else { 257 print "Skipping command: $command\n"; 258 } 259 } 264 260 265 261 ### Pau. … … 292 288 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 293 289 294 my $command = "$magicdstool -updaterun -set_state failed_cleanup";290 my $command = "$magicdstool -updaterun -set_state error_cleaned"; 295 291 $command .= " -magic_ds_id $magic_ds_id"; 296 292 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/magic_destreak_revert.pl
r27946 r29561 38 38 39 39 # Parse the command-line arguments 40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked );40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state); 41 41 my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum); 42 42 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); … … 47 47 'stage=s' => \$stage, # raw, chip, warp, or diff 48 48 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id 49 'run-state=s' => \$run_state, # current state of run 49 50 'component=s' => \$component, # the class_id or skycell_id 50 51 'path_base=s' => \$path_base, # path_base of the input … … 74 75 defined $path_base and 75 76 defined $magicked and 77 defined $run_state and 76 78 defined $outroot; 77 79 … … 248 250 { 249 251 my $command = "$magicdstool -revertdestreakedfile -i_am_sure"; 252 $command .= " -state $run_state"; 250 253 $command .= " -magic_ds_id $magic_ds_id"; 251 254 $command .= " -component $component"; -
trunk/ippTasks/destreak.cleanup.pro
r29250 r29561 50 50 periods -timeout 20 51 51 npending 1 52 active false53 52 54 53 stdout NULL … … 105 104 periods -exec $RUNEXEC 106 105 periods -timeout 60 107 active false108 106 109 107 task.exec -
trunk/ippTasks/destreak.pro
r29502 r29561 185 185 book getword magicToDS $pageName exp_id -var EXP_ID 186 186 book getword magicToDS $pageName magic_ds_id -var MAGIC_DS_ID 187 book getword magicToDS $pageName state -var RUN_STATE 187 188 book getword magicToDS $pageName camera -var CAMERA 188 189 book getword magicToDS $pageName streaks_uri -var STREAKS … … 215 216 # TODO: do not add recoveryroot or replace if they are null or zero 216 217 217 $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --exp_id $EXP_ID --streaks_path_base $STREAKS_PATH_BASE --inv_streaks_path_base $INV_STREAKS_PATH_BASE --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --cam_reduction $CAM_REDUCTION --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE --magicked $MAGICKED 218 $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --exp_id $EXP_ID --streaks_path_base $STREAKS_PATH_BASE --inv_streaks_path_base $INV_STREAKS_PATH_BASE --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --cam_reduction $CAM_REDUCTION --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE --magicked $MAGICKED --run-state $RUN_STATE 218 219 219 220 add_standard_args run … … 390 391 book getword magicDSToRevert $pageName camera -var CAMERA 391 392 book getword magicDSToRevert $pageName stage -var STAGE 393 book getword magicDSToRevert $pageName state -var RUN_STATE 392 394 book getword magicDSToRevert $pageName stage_id -var STAGE_ID 393 395 book getword magicDSToRevert $pageName component -var COMPONENT … … 414 416 end 415 417 416 $run = magic_destreak_revert.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --cam_reduction $CAM_REDUCTION --outroot $OUTROOT --logfile $logfile --replace $REPLACE --bothways $BOTHWAYS --magicked $MAGICKED 418 $run = magic_destreak_revert.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --cam_reduction $CAM_REDUCTION --outroot $OUTROOT --logfile $logfile --replace $REPLACE --bothways $BOTHWAYS --magicked $MAGICKED --run-state $RUN_STATE 417 419 418 420 add_standard_args run -
trunk/ippTools/share/Makefile.am
r29528 r29561 238 238 magictool_exposure.sql \ 239 239 magicdstool_clearstatefaults.sql \ 240 magicdstool_change_file_data_state.sql \ 241 magicdstool_change_run_state.sql \ 240 242 magicdstool_completed_runs.sql \ 241 243 magicdstool_completedrevert.sql \ … … 252 254 magicdstool_getskycells.sql \ 253 255 magicdstool_revertdestreakedfile.sql \ 256 magicdstool_revertupdated.sql \ 257 magicdstool_setfiletoupdate.sql \ 254 258 magicdstool_tocleanup.sql \ 255 259 magicdstool_todestreak_camera.sql \ -
trunk/ippTools/share/chiptool_setimfiletoupdate.sql
r28934 r29561 11 11 AND (chipRun.state = 'cleaned' OR chipRun.state = 'update') 12 12 AND (chipProcessedImfile.data_state = 'cleaned') 13 -- don't queue update if the associated magicDSFile exists 13 -- don't queue update if the associated magicDSFile exists and isn't cleaned 14 14 AND (chipRun.magicked = 0 15 OR (magicDSRun.state = 'cleaned' OR magicDSRun.state = 'new') 16 AND magicDSFile.component IS NULL) 15 OR ((magicDSRun.state = 'cleaned' OR magicDSRun.state = 'update') 16 AND (magicDSFile.data_state = 'cleaned`' OR magicDSFile.data_state = 'update')) 17 ) -
trunk/ippTools/share/magicdstool_todestreak_camera.sql
r29495 r29561 2 2 magicDSRun.magic_ds_id, 3 3 magicDSRun.magic_id, 4 magicDSRun.state, 4 5 chipRun.exp_id, 5 6 camRun.magicked, -
trunk/ippTools/share/magicdstool_todestreak_chip.sql
r29495 r29561 2 2 magicDSRun.magic_ds_id, 3 3 magicDSRun.magic_id, 4 magicDSRun.state, 4 5 chipRun.exp_id, 5 6 chipRun.magicked, … … 37 38 ON magicDSRun.label = Label.label 38 39 WHERE 39 magicDSRun.state = 'new' 40 ((magicDSRun.state = 'new' AND magicDSFile.component IS NULL) 41 OR (magicDSRun.state = 'update' AND magicDSFile.data_state = 'update' 42 AND magicDSFile.fault = 0)) 40 43 AND magicDSRun.stage = 'chip' 41 44 AND (chipRun.state = 'full' OR (chipRun.state = 'update' and chipProcessedImfile.data_state = 'full')) 42 45 AND chipProcessedImfile.fault = 0 43 46 AND chipProcessedImfile.quality = 0 44 AND magicDSFile.component IS NULL45 47 AND (Label.active OR Label.active IS NULL) -
trunk/ippTools/share/magicdstool_todestreak_diff.sql
r29495 r29561 3 3 magicDSRun.magic_ds_id, 4 4 magicRun.magic_id, 5 magicDSRun.state, 5 6 magicRun.exp_id, 6 7 magicDSRun.label, … … 50 51 magicDSRun.magic_ds_id, 51 52 magicRun.magic_id, 53 magicDSRun.state, 52 54 magicRun.exp_id, 53 55 magicDSRun.label, -
trunk/ippTools/share/magicdstool_todestreak_raw.sql
r29495 r29561 2 2 magicDSRun.magic_ds_id, 3 3 magicRun.magic_id, 4 magicDSRun.state, 4 5 magicRun.exp_id, 5 6 magicDSRun.label, -
trunk/ippTools/share/magicdstool_todestreak_warp.sql
r29495 r29561 2 2 magicDSRun.magic_ds_id, 3 3 magicRun.magic_id, 4 magicDSRun.state, 4 5 magicRun.exp_id, 5 6 magicDSRun.label, -
trunk/ippTools/share/magicdstool_torevert_chip.sql
r28853 r29561 22 22 JOIN rawExp ON chipRun.exp_id = rawExp.exp_id 23 23 WHERE magicDSRun.stage = 'chip' 24 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 24 AND (((magicDSRun.state = 'new' OR (magicDSRun.state = 'update')) 25 AND magicDSFile.fault > 0) 26 -- why don't we require a fault for these states? 25 27 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 26 28 AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL)) -
trunk/ippTools/src/magicdstool.c
r29358 r29561 39 39 static bool advancerunMode(pxConfig *config); 40 40 static bool revertdestreakedfileMode(pxConfig *config); 41 static bool updatedestreakedfileMode(pxConfig *config); 41 42 static bool clearstatefaultsMode(pxConfig *config); 42 43 static bool getskycellsMode(pxConfig *config); … … 45 46 static bool completedrevertMode(pxConfig *config); 46 47 static bool tocleanupMode(pxConfig *config); 48 static bool tofullfileMode(pxConfig *config); 49 static bool tocleanedfileMode(pxConfig *config); 50 static bool setfiletoupdateMode(pxConfig *config); 47 51 48 52 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state); … … 73 77 MODECASE(MAGICDSTOOL_MODE_ADVANCERUN, advancerunMode); 74 78 MODECASE(MAGICDSTOOL_MODE_REVERTDESTREAKEDFILE,revertdestreakedfileMode); 79 MODECASE(MAGICDSTOOL_MODE_UPDATEDESTREAKEDFILE,updatedestreakedfileMode); 75 80 MODECASE(MAGICDSTOOL_MODE_CLEARSTATEFAULTS, clearstatefaultsMode); 76 81 MODECASE(MAGICDSTOOL_MODE_GETSKYCELLS, getskycellsMode); … … 79 84 MODECASE(MAGICDSTOOL_MODE_COMPLETEDREVERT, completedrevertMode); 80 85 MODECASE(MAGICDSTOOL_MODE_TOCLEANUP, tocleanupMode); 86 MODECASE(MAGICDSTOOL_MODE_TOFULLFILE, tofullfileMode); 87 MODECASE(MAGICDSTOOL_MODE_TOCLEANEDFILE, tocleanedfileMode); 88 MODECASE(MAGICDSTOOL_MODE_SETFILETOUPDATE, setfiletoupdateMode); 81 89 default: 82 90 psAbort("invalid option (this should not happen)"); … … 558 566 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 559 567 568 if (!strcmp(state, "update")) { 569 fprintf(stderr, "'-updaterun -set_state update' is not supported. Use -setfiletoupdate"); 570 return false; 571 } 572 560 573 // optional 561 574 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); … … 907 920 return false; 908 921 } 922 923 return true; 924 } 925 static bool updatedestreakedfileMode(pxConfig *config) 926 { 927 PS_ASSERT_PTR_NON_NULL(config, false); 928 929 // required values 930 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false); 931 PXOPT_LOOKUP_STR(component, config->args, "-component", true, false); 932 933 // default values 934 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 935 PXOPT_LOOKUP_STR(backup_path_base, config->args, "-backup_path_base", false, false); 936 PXOPT_LOOKUP_STR(recovery_path_base, config->args, "-recovery_path_base", false, false); 937 PXOPT_LOOKUP_STR(data_state, config->args, "-data_state", false, false); 938 PXOPT_LOOKUP_F32(streak_frac, config->args, "-streak_frac", false, false); 939 PXOPT_LOOKUP_F32(nondiff_frac, config->args, "-nondiff_frac", false, false); 940 PXOPT_LOOKUP_F32(run_time, config->args, "-run_time", false, false); 941 942 psString query = psStringCopy("UPDATE magicDSFile"); 943 944 945 char *initial_separator = " SET"; 946 char *sep = initial_separator; 947 if (fault) { 948 psStringAppend(&query, "%s fault = %d", sep, fault); 949 sep = ", "; 950 } 951 if (backup_path_base) { 952 psStringAppend(&query, "%s backup_path_base = '%s'", sep, backup_path_base); 953 sep = ", "; 954 } 955 if (recovery_path_base) { 956 psStringAppend(&query, "%s recovery_path_base = '%s'", sep, recovery_path_base); 957 sep = ", "; 958 } 959 if (data_state) { 960 psStringAppend(&query, "%s data_state = '%s'", sep, data_state); 961 sep = ", "; 962 } 963 if (streak_frac) { 964 psStringAppend(&query, "%s streak_frac = '%f'", sep, streak_frac); 965 sep = ", "; 966 } 967 if (nondiff_frac) { 968 psStringAppend(&query, "%s nondiff_frac = '%f'", sep, nondiff_frac); 969 sep = ", "; 970 } 971 if (run_time) { 972 psStringAppend(&query, "%s run_time = '%f'", sep, run_time); 973 sep = ", "; 974 } 975 if (sep == initial_separator) { 976 psFree(query); 977 psError(PS_ERR_UNKNOWN, true, "must set at least one value"); 978 return false; 979 } 980 981 psStringAppend(&query, "\nWHERE magic_ds_id = %" PRId64 " AND component = '%s'\n", magic_ds_id, component); 982 983 if (!p_psDBRunQuery(config->dbh, query)) { 984 psError(PS_ERR_UNKNOWN, false, "database error"); 985 psFree(query); 986 return false; 987 } 988 psFree(query); 909 989 910 990 return true; … … 1019 1099 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "=="); 1020 1100 PXOPT_COPY_STR(config->args, where, "-component", "component", "=="); 1101 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 1021 1102 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); 1022 1103 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1023 1104 1024 psString query = pxDataGet("magicdstool_revertdestreakedfile.sql"); 1105 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 1106 1107 psString queryFile = NULL; 1108 if (state) { 1109 if (! strcmp(state, "new") ) { 1110 queryFile = "magicdstool_revertdestreakedfile.sql"; 1111 } else if (!strcmp(state, "update")) { 1112 queryFile = "magicdstool_revertupdated.sql"; 1113 } else { 1114 psError(PXTOOLS_ERR_SYS, true, "%s is not a valid value for state", state); 1115 return false; 1116 } 1117 } else { 1118 queryFile = "magicdstool_revertdestreakedfile.sql"; 1119 } 1120 psString query = pxDataGet(queryFile); 1121 if (!query) { 1122 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1123 return false; 1124 } 1025 1125 1026 1126 if (psListLength(where->list)) { … … 1241 1341 (strcmp(state, "censored") == 0) || 1242 1342 (strcmp(state, "cleaned") == 0) || 1343 (strcmp(state, "update") == 0) || 1243 1344 (strcmp(state, "goto_restored") == 0) || 1244 1345 (strcmp(state, "goto_censored") == 0) || … … 1520 1621 return true; 1521 1622 } 1623 1624 // update magicDSFile.data_state to given value. 1625 // afterwards, if all files in the magicDSRun have the new state, 1626 // update the state for it as well 1627 // shared code for the modes -tocleanedfile -tofullfile 1628 1629 static bool change_file_data_state(pxConfig *config, psString data_state) 1630 { 1631 PS_ASSERT_PTR_NON_NULL(config, false); 1632 1633 // magic_id, component 1634 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false); 1635 PXOPT_LOOKUP_STR(component, config->args, "-component", true, false); 1636 1637 psString query = pxDataGet("magicdstool_change_file_data_state.sql"); 1638 1639 if (!psDBTransaction(config->dbh)) { 1640 psError(PS_ERR_UNKNOWN, false, "database error"); 1641 return false; 1642 } 1643 if (!strcmp(data_state, "full")) { 1644 // if -tofullfile optoinally set the magicked value for the component 1645 PXOPT_LOOKUP_BOOL(setmagicked, config->args, "-setmagicked", false); 1646 // set the image file's magicked flag 1647 if (!setMagicked(config, magic_ds_id, component)) { 1648 psError(PS_ERR_UNKNOWN, false, "setMagicked failed"); 1649 if (!psDBRollback(config->dbh)) { 1650 psError(PS_ERR_UNKNOWN, false, "database error"); 1651 } 1652 return false; 1653 } 1654 } 1655 1656 if (!p_psDBRunQueryF(config->dbh, query, data_state, magic_ds_id, component)) { 1657 psFree(query); 1658 psError(PS_ERR_UNKNOWN, false, "database error"); 1659 // rollback 1660 if (!psDBRollback(config->dbh)) { 1661 psError(PS_ERR_UNKNOWN, false, "database error"); 1662 } 1663 psError(PS_ERR_UNKNOWN, false, "database error"); 1664 return false; 1665 } 1666 psFree(query); 1667 if (psDBAffectedRows(config->dbh) < 1) { 1668 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 1669 return false; 1670 } 1671 1672 query = pxDataGet("magicdstool_change_run_state.sql"); 1673 if (!p_psDBRunQueryF(config->dbh, query, data_state, magic_ds_id, data_state)) { 1674 psFree(query); 1675 // rollback 1676 if (!psDBRollback(config->dbh)) { 1677 psError(PS_ERR_UNKNOWN, false, "database error"); 1678 } 1679 psError(PS_ERR_UNKNOWN, false, "database error"); 1680 return false; 1681 } 1682 psFree(query); 1683 1684 if (!psDBCommit(config->dbh)) { 1685 psError(PS_ERR_UNKNOWN, false, "database error"); 1686 return false; 1687 } 1688 1689 return true; 1690 } 1691 static bool tocleanedfileMode(pxConfig *config) 1692 { 1693 return change_file_data_state(config, "cleaned"); 1694 } 1695 static bool tofullfileMode(pxConfig *config) 1696 { 1697 return change_file_data_state(config, "full"); 1698 } 1699 /* 1700 static bool topurgedimfileMode(pxConfig *config) 1701 { 1702 return change_imfile_data_state(config, "purged", "goto_purged"); 1703 } 1704 static bool toscrubbedfileMode(pxConfig *config) 1705 { 1706 return change_file_data_state(config, "scrubbed", "goto_scrubbed"); 1707 } 1708 */ 1709 1710 // a very specfic function to queue a cleaned magicDSFile to be updated 1711 static bool setfiletoupdateMode(pxConfig *config) 1712 { 1713 PS_ASSERT_PTR_NON_NULL(config, NULL); 1714 1715 PXOPT_LOOKUP_S64(magic_ds_id, config->args, "-magic_ds_id", true, false); 1716 PXOPT_LOOKUP_STR(component, config->args, "-component", false, false); 1717 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 1718 1719 psString query = pxDataGet("magicdstool_setfiletoupdate.sql"); 1720 if (!query) { 1721 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1722 return false; 1723 } 1724 1725 psString setHook = psStringCopy(""); 1726 if (label) { 1727 psStringAppend(&setHook, "\n , magicDSRun.label = '%s'", label); 1728 } 1729 1730 if (component) { 1731 psStringAppend(&query, " AND (magicDSFile.component = '%s')", component); 1732 } 1733 1734 if (!p_psDBRunQueryF(config->dbh, query, setHook, magic_ds_id)) { 1735 psError(PS_ERR_UNKNOWN, false, "database error"); 1736 return false; 1737 } 1738 1739 psFree(setHook); 1740 psFree(query); 1741 1742 return true; 1743 } 1744 1745 -
trunk/ippTools/src/magicdstool.h
r26960 r29561 38 38 MAGICDSTOOL_MODE_COMPLETEDREVERT, 39 39 MAGICDSTOOL_MODE_TOCLEANUP, 40 MAGICDSTOOL_MODE_TOCLEANEDFILE, 41 MAGICDSTOOL_MODE_TOFULLFILE, 42 MAGICDSTOOL_MODE_SETFILETOUPDATE, 43 MAGICDSTOOL_MODE_UPDATEDESTREAKEDFILE, 40 44 } MAGICDStoolMode; 41 45 -
trunk/ippTools/src/magicdstoolConfig.c
r28936 r29561 137 137 psMetadataAddS16(adddestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 138 138 139 // -updatedestreakedfile 140 psMetadata *updatedestreakedfileArgs = psMetadataAlloc(); 141 psMetadataAddS64(updatedestreakedfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magictool ID (required)", 0); 142 psMetadataAddStr(updatedestreakedfileArgs, PS_LIST_TAIL, "-component", 0, "define component name (required)", NULL); 143 psMetadataAddStr(updatedestreakedfileArgs, PS_LIST_TAIL, "-state", 0, "current value for magicDSRun.state", NULL); 144 psMetadataAddStr(updatedestreakedfileArgs, PS_LIST_TAIL, "-backup_path_base", 0, "define backup URI", NULL); 145 psMetadataAddStr(updatedestreakedfileArgs, PS_LIST_TAIL, "-recovery_path_base", 0, "define recovery pixels URI", NULL); 146 psMetadataAddStr(updatedestreakedfileArgs, PS_LIST_TAIL, "-data_state", 0, "change data_state", NULL); 147 psMetadataAddBool(updatedestreakedfileArgs, PS_LIST_TAIL, "-setmagicked", 0, "update the magicked state of the file", false); 148 psMetadataAddF32(updatedestreakedfileArgs, PS_LIST_TAIL, "-streak_frac", 0, "set fraction of pixels masked by streaks", 0); 149 psMetadataAddF32(updatedestreakedfileArgs, PS_LIST_TAIL, "-nondiff_frac", 0, "set fraction of pixels masked because nondiffed", 0); 150 psMetadataAddF32(updatedestreakedfileArgs, PS_LIST_TAIL, "-run_time", 0, "set the streaksremove run time for component ", 0); 151 psMetadataAddS16(updatedestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 152 139 153 // -revertdestreakedfile 140 154 psMetadata *revertdestreakedfileArgs = psMetadataAlloc(); 141 155 psMetadataAddS64(revertdestreakedfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magictool de-streak ID", 0); 156 psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-state", 0, "current value for magicDSRun.state", NULL); 142 157 psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-component", 0, "search by component", NULL); 143 158 psMetadataAddS16(revertdestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); … … 197 212 psMetadataAddU64(tocleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 198 213 psMetadataAddBool(tocleanupArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 214 215 // -tocleanedfile 216 psMetadata *tocleanedfileArgs = psMetadataAlloc(); 217 psMetadataAddS64(tocleanedfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic_ds_id", 0); 218 psMetadataAddStr(tocleanedfileArgs, PS_LIST_TAIL, "-component", 0, "define component", NULL); 219 220 // -tofullfile 221 psMetadata *tofullfileArgs = psMetadataAlloc(); 222 psMetadataAddS64(tofullfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic_ds_id", 0); 223 psMetadataAddStr(tofullfileArgs, PS_LIST_TAIL, "-component", 0, "define component", NULL); 224 psMetadataAddBool(tofullfileArgs, PS_LIST_TAIL, "-setmagicked", 0, "update the magicked state of the file", false); 225 226 // -setfiletoupdate 227 psMetadata *setfiletoupdateArgs = psMetadataAlloc(); 228 psMetadataAddS64(setfiletoupdateArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic_ds_id", 0); 229 psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-component", 0, "define component", NULL); 230 psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-set_label", 0, "set new label", NULL); 231 199 232 psFree(now); 200 233 … … 230 263 MAGICDSTOOL_MODE_TOCLEANUP, tocleanupArgs); 231 264 265 PXOPT_ADD_MODE("-tofullfile", "set component's data_state to full", 266 MAGICDSTOOL_MODE_TOFULLFILE, tofullfileArgs); 267 PXOPT_ADD_MODE("-tocleanedfile", "set component's data_state to cleaned", 268 MAGICDSTOOL_MODE_TOCLEANEDFILE, tocleanedfileArgs); 269 PXOPT_ADD_MODE("-setfiletoupdate", "set component's data_state to update", 270 MAGICDSTOOL_MODE_SETFILETOUPDATE, setfiletoupdateArgs); 271 PXOPT_ADD_MODE("-updatedestreakedfile", "update parameters of destreaked file", 272 MAGICDSTOOL_MODE_UPDATEDESTREAKEDFILE, updatedestreakedfileArgs); 273 232 274 233 275 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
trunk/pstamp/scripts/pstamp_checkdependent.pl
r29348 r29561 197 197 if (!$job_fault and ($stage eq 'chip')) { 198 198 # chip processing is done, start destreaking. 199 $job_fault = check_states_magicDSRun($stage, $stage_id, $rlabel, $need_magic, $it->{raw_magicked}, $it->{dsRun_state}); 199 my @chips; 200 push @chips, $it->{class_id}; 201 $job_fault = check_states_magicDSRun($stage, $stage_id, \@chips, $rlabel, $need_magic, $it->{raw_magicked}, $it->{magic_ds_id}, $it->{dsRun_state}); 200 202 } 201 203 if ($job_fault) { … … 217 219 my $dsRun_state; 218 220 my $raw_all_magicked = 1; # this gets cleared if any of the inputs aren't destreaked 221 my @chips; 222 my $magic_ds_id; 219 223 if (!$whole_run) { 220 224 foreach my $chip (@$metadatas) { 221 225 $dsRun_state = $chip->{dsRun_state}; 222 226 $raw_all_magicked &= ($chip->{raw_magicked} > 0); 227 $magic_ds_id = $chip->{magic_ds_id}; 228 229 push @chips, $chip->{class_id}; 223 230 224 231 if (($chip->{state} =~ /error/) or ($chip->{state} =~ /purged/) or ($chip->{state} =~ /scrubbed/)) { … … 273 280 } 274 281 275 my $status = check_states_magicDSRun('chip', $chip_id, $rlabel, $need_magic, $raw_all_magicked, $dsRun_state);282 my $status = check_states_magicDSRun('chip', $chip_id, \@chips, $rlabel, $need_magic, $raw_all_magicked, $magic_ds_id, $dsRun_state); 276 283 277 284 return $status; … … 633 640 my $stage = shift; 634 641 my $stage_id = shift; 642 my $components = shift; 635 643 my $rlabel = shift; 636 644 my $need_magic = shift; 637 645 my $input_magicked = shift; 646 my $magic_ds_id = shift; 638 647 my $dsRun_state = shift; 639 648 640 649 # XXX: this code assumes that destreaking is handled at the chip stage 641 my_die ("check_states_magicDSRun only works for stage chip", $PS_EXIT_PROG_ERROR) if $stage ne 'chip';650 my_die ("check_states_magicDSRun only implemented for chip stage", $PS_EXIT_PROG_ERROR) if $stage ne 'chip'; 642 651 643 652 # if called from check_states_warp dsRun_state is unknown. Go find it. … … 654 663 print "No magicDSRun for chipRun $stage_id and magic is required\n"; 655 664 faultJobs('stop', undef, undef, $PSTAMP_NOT_DESTREAKED); 656 } elsif ($dsRun_state eq 'cleaned') { 657 my $command = "$magicdstool -updaterun -set_state new -stage $stage -stage_id $stage_id"; 658 $command .= " -set_label $rlabel" if $rlabel; 659 if (!$no_update) { 660 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 661 run(command => $command, verbose => $verbose); 662 unless ($success) { 663 my_die("failed to set destreak run to 'new' for ${stage}Run $stage_id", 664 $PS_EXIT_UNKNOWN_ERROR); 665 } elsif (($dsRun_state eq 'cleaned') or ($dsRun_state eq 'update')) { 666 foreach my $c (@$components) { 667 my $command = "$magicdstool -setfiletoupdate -magic_ds_id $magic_ds_id -component $c"; 668 $command .= " -set_label $rlabel" if $rlabel; 669 if (!$no_update) { 670 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 671 run(command => $command, verbose => $verbose); 672 unless ($success) { 673 my_die("failed to set destreaked component to 'update' for ${stage}Run $stage_id $c", 674 $PS_EXIT_UNKNOWN_ERROR); 675 } 676 } else { 677 print "skipping $command\n"; 665 678 } 666 } else {667 print "skipping $command\n";668 679 } 669 680 } elsif ($dsRun_state eq 'failed_revert') { -
trunk/pstamp/scripts/pstamp_get_image_job.pl
r27874 r29561 105 105 $command .= " --prefix $prefix"; 106 106 $command .= " --magicked" if $magicked; 107 # DANGER DANGER do not commit next line 108 # $command .= " --no_magic"; 109 # DANGER DANGER do not commit last line 107 110 $command .= " --dbname $dbname" if $dbname; 108 111 $command .= " --verbose" if $verbose; -
trunk/pstamp/scripts/pstamp_server_status
r29174 r29561 57 57 $error_code = (($error_code >> 8) or 1); 58 58 if ($error_code == 12) { 59 print "Postage Stamp Server is not running\n"; 59 #print "Postage Stamp Server is not running\n"; 60 print "Postage Stamp Server will be down for maintenance until approximately 0400 UTC October 26\n"; 60 61 exit 0; 61 62 }
Note:
See TracChangeset
for help on using the changeset viewer.
