Changeset 30317 for trunk/pstamp/scripts
- Timestamp:
- Jan 20, 2011, 10:28:02 AM (15 years ago)
- Location:
- trunk/pstamp/scripts
- Files:
-
- 5 edited
-
pstamp_checkdependent.pl (modified) (1 diff)
-
pstamp_job_run.pl (modified) (8 diffs)
-
pstamp_parser_run.pl (modified) (3 diffs)
-
pstamp_server_status (modified) (1 diff)
-
pstampparse.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_checkdependent.pl
r29624 r30317 680 680 foreach my $c (@$components) { 681 681 my $command = "$magicdstool -destreakedfile -magic_ds_id $magic_ds_id -component $c"; 682 # XXX: get this from a config file 683 $command .= " -set_recoveryroot neb://any/gpc1/destreak/recover"; 682 684 my $dsfile = runToolAndParseExpectOne($command, $verbose); 683 685 if (!$dsfile) { -
trunk/pstamp/scripts/pstamp_job_run.pl
r30001 r30317 14 14 use File::Basename; 15 15 use File::Copy; 16 use File::Temp qw(tempfile); 16 17 use Digest::MD5::File qw( file_md5_hex ); 17 18 use PS::IPP::PStamp::RequestFile qw( :standard ); 19 use PS::IPP::PStamp::Job qw( :standard ); 18 20 use IPC::Cmd 0.36 qw( can_run run ); 19 21 use POSIX; … … 26 28 27 29 my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options); 28 my ($verbose, $dbname, $dbserver, $no_update );30 my ($verbose, $dbname, $dbserver, $no_update, $save_temps); 29 31 30 32 GetOptions( … … 39 41 'verbose' => \$verbose, 40 42 'no-update' => \$no_update, 43 'save-temps' => \$save_temps, 41 44 ); 42 45 … … 75 78 my $pstamp_get_image_job = can_run('pstamp_get_image_job.pl') or (warn "Can't find pstamp_get_image_job.pl" and $missing_tools = 1); 76 79 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1); 80 my $streaksreplace = can_run('streaksreplace') or (warn "Can't find streaksreplace" and $missing_tools = 1); 81 my $magicdstool = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1); 77 82 78 83 if ($missing_tools) { … … 88 93 my $argString; 89 94 $argString = $params->{job_args}; 95 my $stage = $params->{stage}; 90 96 91 97 # XXX: should we do any other sanity checking? 92 98 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 93 99 94 $argString .= " -file $params->{image}"; 100 my $nan_masked = 1; 101 my $muggle = 0; 102 if (!$params->{magicked}) { 103 $nan_masked = 0; 104 } elsif ($params->{magicked} and ($options & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED))) { 105 # Attempt to find or create a muggle image 106 $nan_masked = 0; 107 $muggle = 1; 108 } 109 110 my $image = $params->{image}; 111 my $mask; 112 my $variance; 113 my $fileArgs = " -file $params->{image}"; 95 114 my @file_list = ($params->{image}); 96 115 97 my $nan_masked = 1;98 if (!$params->{magicked}) {99 $nan_masked = 0;100 }101 116 if ($nan_masked or ($options & $PSTAMP_SELECT_MASK)) { 102 $argString .= " -mask $params->{mask}"; 103 push @file_list, $params->{mask}; 117 $mask = $params->{mask}; 118 $fileArgs .= " -mask $mask"; 119 push @file_list, $mask; 104 120 } 105 121 if ($options & $PSTAMP_SELECT_VARIANCE) { 106 $argString .= " -variance $params->{weight}"; 107 push @file_list, $params->{weight}; 122 $variance = $params->{weight}; 123 $fileArgs .= " -variance $variance"; 124 push @file_list, $variance; 108 125 } 109 126 … … 113 130 } 114 131 115 check_files(@file_list); 116 117 my $command = "$ppstamp $outputBase $argString"; 132 # check that actual input files exist 133 check_files($PSTAMP_GONE, @file_list); 134 135 # find our output directory 136 my $outdir = dirname($outputBase); 137 my ($tmpImage, $tmpMask, $tmpVariance, $tmproot); 138 139 if ($muggle) { 140 # first see if the original uncensored images are around 141 if (check_for_backups($params, \$fileArgs)) { 142 # We're good to go. fileArgs has been edited to contain the paths for the original uncensored images 143 print "Making stamps from backup images\n"; 144 } elsif (($options & $PSTAMP_REQUIRE_UNCENSORED) and ($stage ne 'chip')) { 145 # user required uncensored but since stage isn't chip we can't rebuild them 146 my_die("uncensored inputs not available for job $job_id", $job_id, $PSTAMP_NOT_AVAILABLE); 147 } elsif (($options & $PSTAMP_REQUEST_UNCENSORED) and ($stage ne 'chip')) { 148 # make stamps from uncensored images 149 $muggle = 0; 150 } else { 151 # Try and replace the streaks from the recovery images 152 153 @file_list = (); 154 $tmproot = "$outdir/$job_id"; 155 mkdir $tmproot or 156 my_die( "failed to create temporary directory $tmproot", $job_id, $PS_EXIT_UNKNOWN_ERROR); 157 my $muggle_command = "$streaksreplace -stage $stage -tmproot $tmproot"; 158 # find the "directory" of the input path_base 159 my $inputdir = dirname($image); 160 my $base = basename($image); 161 $tmpImage = "$tmproot/$base"; 162 163 # XXX: We should get the recovery_path_base from the magicDSFile but that requires a bunch of file rule and 164 # stage work. Import the rule here. 165 my $recImage = "$inputdir/REC_$base"; 166 my $newFileArgs = " -file $tmpImage"; 167 $muggle_command .= " -image $image -recimage $recImage"; 168 push @file_list, $recImage; 169 170 if ($mask) { 171 $base = basename($mask); 172 $tmpMask = "$tmproot/$base"; 173 $newFileArgs .= " -mask $tmpMask"; 174 my $recMask = "$inputdir/REC_$base"; 175 $muggle_command .= " -mask $mask -recmask $recMask"; 176 push @file_list, $recMask; 177 } 178 179 if ($variance) { 180 $base = basename($variance); 181 $tmpVariance = "$tmproot/$base"; 182 $newFileArgs .= " -weight $tmpVariance"; 183 my $recVariance = "$inputdir/REC_$base"; 184 $muggle_command .= " -weight $variance -recweight $recVariance"; 185 push @file_list, $recVariance; 186 } 187 if (check_files(0, @file_list)) { 188 # recovery files exist and are accessible restore the excised pixels 189 190 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 run(command => $muggle_command, verbose => $verbose); 192 unless ($success) { 193 my $exitStatus = WEXITSTATUS($error_code); 194 my_die( "streaksreplace failed with error code: $exitStatus", $job_id, $exitStatus); 195 } 196 197 # set the ppstamp file arguments 198 $fileArgs = $newFileArgs; 199 } else { 200 if ($options & $PSTAMP_REQUIRE_UNCENSORED) { 201 my_die( "unable to restore uncensored images", $job_id, $PSTAMP_NOT_AVAILABLE); 202 } 203 # just make stamps from the censored images 204 print "Unable to restore uncensored images, will extract stamps from censored images\n"; 205 # these files won't be used so zap them 206 ($tmpImage, $tmpMask, $tmpVariance, $tmproot) = (undef, undef, undef, undef); 207 } 208 } 209 } 210 211 my $command = "$ppstamp $outputBase $argString $fileArgs"; 118 212 $command .= " -dbname $dbname" if $dbname; 119 213 $command .= " -dbserver $dbserver" if $dbserver; 120 $command .= " -stage $ params->{stage}" if $params->{stage};214 $command .= " -stage $stage"; 121 215 $command .= " -no_censor_masked" unless $nan_masked; 122 216 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 131 225 } 132 226 227 if (!$save_temps) { 228 unlink $tmpImage if $tmpImage; 229 unlink $tmpMask if $tmpMask; 230 unlink $tmpVariance if $tmpVariance; 231 rmdir $tmproot if $tmproot; 232 } 233 133 234 if ($exitStatus == 0) { 134 my $dir = dirname($outputBase); 135 136 my $reglist = "$dir/reglist$job_id"; 235 my $reglist = "$outdir/reglist$job_id"; 137 236 138 237 my $F; … … 363 462 364 463 sub check_files { 464 my $error_code = shift; 465 my $return_code = 1; 365 466 foreach my $f (@_) { 366 467 if (!$ipprc->file_exists($f)) { 367 my_die( "file $f does not exist:", $job_id, $PSTAMP_GONE, 'stop'); 368 } 369 } 468 if ($error_code) { 469 my_die( "file $f does not exist:", $job_id, $error_code, 'stop'); 470 } else { 471 print STDERR "file $f does not exist\n"; 472 $return_code = 0; 473 } 474 } 475 } 476 return $return_code; 477 } 478 479 sub check_for_backups { 480 my $params = shift; 481 my $r_fileArgs = shift; 482 483 my $command = "$magicdstool -destreakedfile -stage $params->{stage} -stage_id $params->{stage_id} -component $params->{component} -dbname $params->{imagedb}"; 484 my $results = runToolAndParse($command, $verbose); 485 my $dsComponent = $results->[0]; 486 487 if ($dsComponent and ($dsComponent->{data_state} eq 'full')) { 488 489 print "magicDSFile state is full. Backup images should exist\n"; 490 491 # replace the file names with the backup paths 492 # fileArgs has the form: -file imagename [-mask maskname] [-weight weightname] 493 my @args = split " ", $$r_fileArgs; 494 495 my $newFileArgs; 496 while (@args) { 497 my $a = shift @args; 498 my $f = shift @args; 499 my_die( "unexpected fileArg list $$r_fileArgs", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$a or !$f; 500 501 my $backup_image_name = $ipprc->destreaked_filename($f); 502 my_die( "failed to extract backup image name from $f", $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$backup_image_name; 503 $newFileArgs .= " $a $backup_image_name"; 504 } 505 $$r_fileArgs = $newFileArgs; 506 507 return 1; 508 } 509 510 return 0; 370 511 } 371 512 -
trunk/pstamp/scripts/pstamp_parser_run.pl
r29576 r30317 31 31 my $outdir; 32 32 my $label; 33 my $need_magic; 33 34 my $verbose; 34 35 my $dbname; … … 41 42 'outdir=s' => \$outdir, 42 43 'label=s' => \$label, 44 'need_magic' => \$need_magic, 43 45 'redirect-output' => \$redirect_output, 44 46 'verbose' => \$verbose, … … 160 162 $parse_cmd = "$pstampparse"; 161 163 $parse_cmd .= " --label $label" if $label; 164 $parse_cmd .= " --need_magic" if $need_magic; 162 165 $request_fault = 0; 163 166 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { -
trunk/pstamp/scripts/pstamp_server_status
r29572 r30317 44 44 chdir $rundir or die "failed to cd to $rundir"; 45 45 46 47 my $down = 0; 48 if ($down) { 49 print "Postage Stamp Server will be down for maintenance it will back at approximately 00:00 2010-12-11 UTC\n"; 50 exit 0; 51 } 46 52 47 53 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps); -
trunk/pstamp/scripts/pstampparse.pl
r30016 r30317 30 30 my $save_temps; 31 31 my $no_update; 32 my $dest_requires_magic; 32 33 33 34 GetOptions( … … 38 39 'label=s' => \$label, 39 40 'mode=s' => \$mode, 41 'need_magic'=> \$dest_requires_magic, 40 42 'dbname=s' => \$dbname, 41 43 'dbserver=s'=> \$dbserver, … … 126 128 } 127 129 128 # Adjust the label for requests coming in over the web interaface 130 131 # Adjust the label for requests coming in over the web interface 129 132 130 133 my $label_changed = 0; … … 384 387 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver); 385 388 if (!$proj_hash) { 386 foreach $row(@$rowList) {387 insertFakeJobForRow($r ow, 1, $PSTAMP_UNKNOWN_PRODUCT);389 foreach my $r (@$rowList) { 390 insertFakeJobForRow($r, 1, $PSTAMP_UNKNOWN_PRODUCT); 388 391 $num_jobs++; 389 392 } … … 409 412 $need_magic = $proj_hash->{need_magic}; 410 413 411 # Temporary hack so that IFA can get at non-magicked data412 my $allow_mops_unmagicked = 1;413 if ($allow_mops_unmagicked) {414 if ($product and (($product eq "mops-pstamp-results") or415 ($product eq "mops-pstamp-results2") or416 ($product eq "ifa-pstamp-results"))) {417 $need_magic = 0;418 }419 }420 421 414 $need_magic = 0 if $stage eq 'stack'; 415 416 if ($need_magic) { 417 418 # this project requires that postage stamps be extracted from destreaked images 419 420 if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) { 421 # The user has requested uncensored stamps 422 423 if (!$dest_requires_magic) { 424 # and this user's data store destination is allowed uncensored stamps, so accept the request 425 $need_magic = 0; 426 } else { 427 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n"; 428 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) { 429 # user required uncensored stamps. Can't do it so fail. 430 foreach my $r (@$rowList) { 431 insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED); 432 $num_jobs++; 433 } 434 return $num_jobs; 435 } 436 437 # user will accept censored stamps. alter OPTION_MASK and continue 438 439 print STDERR " Will attempt to make destreaked stamps\n"; 440 # zap the offending bit in the option mask 441 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED); 442 foreach my $r (@$rowList) { 443 $r->{OPTION_MASK} = $option_mask; 444 } 445 } 446 } 447 } 422 448 423 449 my $numRows = scalar @$rowList;
Note:
See TracChangeset
for help on using the changeset viewer.
