IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30321


Ignore:
Timestamp:
Jan 20, 2011, 11:11:01 AM (15 years ago)
Author:
bills
Message:

Merge in changes to support saving pixels excised by magic and making uncensored postage stamps
for authorized users

Location:
tags/ipp-20101215
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20101215/PS-IPP-Config

  • tags/ipp-20101215/PS-IPP-Config/lib/PS/IPP/Config.pm

    r29891 r30321  
    10481048}
    10491049
     1050sub magic_filename
     1051{
     1052    my $file = shift;
     1053    my $prefix = shift;
     1054    my $dirname = dirname($file);
     1055    my $base = basename($file);
     1056
     1057    return "$dirname/$prefix$base";
     1058}
     1059
     1060sub destreaked_filename
     1061{
     1062    my $self  = shift;
     1063    my $file  = shift;
     1064
     1065    return magic_filename($file, "SR_");
     1066}
     1067sub recovery_filename
     1068{
     1069    my $self  = shift;
     1070    my $file  = shift;
     1071
     1072    return magic_filename($file, "REC_");
     1073}
     1074
    10501075# Return an EXTNAME From the EXTNAME.RULE table in the camera configuration
    10511076sub extname_rule
     
    11071132    }
    11081133
    1109     if (file_scheme($output) ne 'neb') {
     1134    my $scheme = file_scheme($output);
     1135    if (!$scheme or ($scheme ne 'neb')) {
    11101136        # non-nebulous file we're done
    1111         if ($delete_existing) {
     1137        if ($delete_existing and $self->file_exists($output)) {
    11121138            if (!$self->file_delete($output)) {
    11131139                carp "failed to delete $output";
     
    11811207    my $copies = shift;
    11821208
    1183     if (file_scheme($file) ne 'neb') {
     1209    my $scheme = file_scheme($file);
     1210    if (!$scheme or ($scheme ne 'neb')) {
    11841211        carp "cannot replicate non-neulous file: $file";
    11851212        return 0;
  • tags/ipp-20101215/PS-IPP-PStamp

  • tags/ipp-20101215/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r29424 r30321  
    1717                    resolve_project
    1818                    getCamRunByCamID
     19                    runToolAndParse
    1920                    parse_md_fast
    2021                    );
  • tags/ipp-20101215/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r28048 r30321  
    2929                    $PSTAMP_SELECT_INVERSE
    3030                    $PSTAMP_SELECT_UNCONV
     31                    $PSTAMP_REQUEST_UNCENSORED
     32                    $PSTAMP_REQUIRE_UNCENSORED
    3133                    $PSTAMP_USE_IMFILE_ID
    3234                    $PSTAMP_NO_WAIT_FOR_UPDATE
     
    4446                    $PSTAMP_NO_JOBS_QUEUED
    4547                    $PSTAMP_NO_OVERLAP
     48                    $PSTAMP_NOT_AUTHORIZED
    4649                    );
    4750our %EXPORT_TAGS = (standard => [@EXPORT_OK]);
     
    6467our $PSTAMP_USE_IMFILE_ID    = 16384;
    6568
    66 our $PSTAMP_NO_WAIT_FOR_UPDATE  = 32768;
     69our $PSTAMP_NO_WAIT_FOR_UPDATE = 32768;
     70our $PSTAMP_REQUEST_UNCENSORED = 1 << 16;
     71our $PSTAMP_REQUIRE_UNCENSORED = 1 << 17;
    6772
    6873# job and result codes
     
    8287our $PSTAMP_NO_JOBS_QUEUED   = 27;
    8388our $PSTAMP_NO_OVERLAP       = 28;
     89our $PSTAMP_NOT_AUTHORIZED   = 29;
    8490
    8591
     
    119125PSTAMP_NO_JOBS_QUEUED
    120126PSTAMP_NO_OVERLAP
     127PSTAMP_NOT_AUTHORIZED
    121128);
    122129
  • tags/ipp-20101215/dbconfig/pstamp.md

    r29287 r30321  
    88    uri         STR         255
    99    pollInterval S32        0
     10    need_magic  S32         0
    1011END
    1112
  • tags/ipp-20101215/ippScripts/scripts/ipp_cleanup.pl

    r29892 r30321  
    167167#            addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id);
    168168#            addFilename (\@files, "PPIMAGE.OUTPUT.VARIANCE", $path_base, $class_id);
    169             addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id);
    170             addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id);
    171             addFilename (\@files, "PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
     169            addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id, 1);
     170            addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id, 1);
     171            addFilename (\@files, "PPIMAGE.CHIP.VARIANCE", $path_base, $class_id, 1);
    172172            if ($mode eq "goto_purged") {
    173173                # additional files to remove for 'purge' mode
     
    429429
    430430                # delete the temporary image datafiles
    431                 addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id );
    432                 addFilename(\@files, "PSWARP.OUTPUT.MASK", $path_base, $skycell_id);
    433                 addFilename(\@files, "PSWARP.OUTPUT.VARIANCE", $path_base, $skycell_id);
     431                addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id, 1);
     432                addFilename(\@files, "PSWARP.OUTPUT.MASK", $path_base, $skycell_id, 1);
     433                addFilename(\@files, "PSWARP.OUTPUT.VARIANCE", $path_base, $skycell_id, 1);
    434434#            addFilename(\@files, "PSWARP.OUTPUT.SOURCES", $path_base, $skycell_id);
    435435                if ($mode eq "goto_purged") {
     
    706706            my @files = ();
    707707            # delete the temporary image datafiles
    708             addFilename(\@files, "PPSUB.OUTPUT", $path_base, $skycell_id);
    709             addFilename(\@files, "PPSUB.OUTPUT.MASK", $path_base, $skycell_id);
    710             addFilename(\@files, "PPSUB.OUTPUT.VARIANCE", $path_base, $skycell_id);
    711 
    712             addFilename(\@files, "PPSUB.INVERSE", $path_base, $skycell_id);
    713             addFilename(\@files, "PPSUB.INVERSE.MASK", $path_base, $skycell_id);
    714             addFilename(\@files, "PPSUB.INVERSE.VARIANCE", $path_base, $skycell_id);
     708            addFilename(\@files, "PPSUB.OUTPUT", $path_base, $skycell_id, 1);
     709            addFilename(\@files, "PPSUB.OUTPUT.MASK", $path_base, $skycell_id, 1);
     710            addFilename(\@files, "PPSUB.OUTPUT.VARIANCE", $path_base, $skycell_id, 1);
     711
     712            addFilename(\@files, "PPSUB.INVERSE", $path_base, $skycell_id, 1);
     713            addFilename(\@files, "PPSUB.INVERSE.MASK", $path_base, $skycell_id, 1);
     714            addFilename(\@files, "PPSUB.INVERSE.VARIANCE", $path_base, $skycell_id, 1);
    715715
    716716            addFilename(\@files, "PPSUB.INPUT.CONV", $path_base, $skycell_id);
     
    20482048    my $path_base  = shift; # base filename
    20492049    my $class_id   = shift; # class_id, if needed
     2050    my $recovery   = shift; # is there is a recovery file to clean?
    20502051
    20512052    my $file = $ipprc->filename($filerule, $path_base, $class_id);
    20522053
    20532054    push @$files, $file;
     2055   
     2056    if ($recovery) {
     2057        # need to clean up the recovery file (the pixels censored by streaksremove)
     2058        $file = $ipprc->recovery_filename($file);
     2059        push @$files, $file;
     2060    }
    20542061    return 1;
    20552062}
  • tags/ipp-20101215/ippScripts/scripts/magic_destreak.pl

    r29995 r30321  
    6565           'cam_reduction=s'=> \$cam_reduction,  # reduction class from camera stage (for chip and raw)
    6666           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    67            'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     67           'recoveryroot=s' => \$recoveryroot,# "prefix" for saving the images of excised pixels
    6868           'replace=s'      => \$replace,    # replace the input images with the results.
    6969           'magicked=s'     => \$magicked,   # magicked state of the run
     
    190190my $recovery_path_base;
    191191if ($recoveryroot) {
    192     if (!inNebulous($recoveryroot)) {
    193         if (! -e $recoveryroot ) {
    194             my $code = system "mkdir -p $recoveryroot";
    195             &my_die("cannot create output directory $recoveryroot", $magic_ds_id, $component,
    196                     $code >> 8) if $code;
    197         }
    198     }
    199     # note: trailing / is necessary
    200     $recovery_path_base = "$recoveryroot/$basename/";
     192    # recoveryroot is a path to prepend to the basenames of the input files
     193    if (inNebulous($recoveryroot)) {
     194        # if recoveryroot is a nebulous path we ignore the actual path and put the files in the
     195        # the same "directory" as the input files
     196        $recoveryroot = $dirname;
     197    } else {
     198        # otherwise we put the files in recoveryroot. Regardless, we prefix the basename with 'REC_'
     199        $ipprc->outroot_prepare($recoveryroot);
     200    }
     201    $recovery_path_base = "$recoveryroot/REC_$basename";
    201202}
    202203
     
    601602    $command   .= " -magic_ds_id $magic_ds_id";
    602603    $command   .= " -component $component";
     604    $command .= " -backup_path_base $backup_path_base" if $backup_path_base;
     605    $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;
    603606    $command   .= " -fault $exit_code";
    604607    $command   .= " -dbname $dbname" if defined $dbname;
  • tags/ipp-20101215/ippScripts/scripts/magic_destreak_defineruns.pl

    r29981 r30321  
    4242
    4343# Parse the command-line arguments
    44 my ($stage, $stage_limit, $workdir);
     44my ($stage, $stage_limit, $workdir, $recoveryroot);
    4545my ($dbname, $save_temps, $verbose, $no_update, $logfile);
    4646my @labels;
     
    5151           'stage_limit=s'  => \$stage_limit,# maximum number of runs queued for each stage
    5252           'workdir=s'      => \$workdir,    # output destination
     53           'recoveryroot=s' => \$recoveryroot, # recovery pixels destination
    5354           'dbname=s'       => \$dbname,     # Database name
    5455           'verbose'        => \$verbose,    # Print stuff?
     
    7879    foreach my $label (@labels) {
    7980        my $command = "$magicdstool -definebyquery -stage $stage -workdir $workdir -label $label";
     81        $command .= " -recoveryroot $recoveryroot" if $recoveryroot;
    8082        $command .= " -pretend" if $no_update;
    8183        $command .= " -limit $stage_limit" if $stage_limit;
  • tags/ipp-20101215/ippScripts/scripts/magic_destreak_revert.pl

    r29983 r30321  
    3939# Parse the command-line arguments
    4040my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state);
    41 my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum);
     41my ($outroot, $recovery_path_base, $replace, $release, $bytes, $md5sum);
    4242my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4343
     
    5353           'cam_reduction=s'=> \$cam_reduction,  # reduction class of the associated camera run
    5454           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    55            'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     55           'recovery_path_base=s' => \$recovery_path_base,# "directory" for saving the images of excised pixels
    5656           'replace=s'      => \$replace,    # replace the input images with the results.
    5757           'bothways=s'     => \$bothways,   # run has inverse files (bothways diff)
     
    130130
    131131# default value is "NULL" do not use it
    132 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) {
    133     $recoveryroot = undef;
     132if (defined($recovery_path_base) and ($recovery_path_base eq "NULL")) {
     133    $recovery_path_base = undef;
    134134}
    135135
     
    149149}
    150150
    151 my $recovery_path_base;
    152 if ($recoveryroot) {
    153     # note: trailing / is necessary
    154     $recovery_path_base = "$recoveryroot/$basename/";
    155 }
    156 
    157151
    158152my ($image, $mask, $ch_mask, $weight, $sources, $astrom);
    159153my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom);
     154my ($rimage, $rmask, $rch_mask, $rweight);
    160155
    161156if ($stage eq "raw") {
     
    214209    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id);
    215210    $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id);
     211
     212    $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $class_id);
     213    # This is somewhat kludgey but it works whether the mask is camera mask or chip mask
     214    $rmask   = dirname($recovery_path_base) . "/REC_" . basename($mask);
     215    $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $class_id);
     216    $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $class_id);
    216217} elsif ($stage eq "camera") {
    217218    $astrom =  $ipprc->filename("PSASTRO.OUTPUT", $path_base);
     
    226227    $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base);
    227228    $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base);
     229    $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
     230    $rmask   = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base);
     231    $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
    228232} elsif ($stage eq "diff") {
    229233    my $name = "PPSUB.OUTPUT";
     
    236240    $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base);
    237241    $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
     242    if ($recovery_path_base) {
     243        $rimage  = $ipprc->filename($name, $recovery_path_base);
     244        $rmask   = $ipprc->filename("$name.MASK", $recovery_path_base);
     245        $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base);
     246    }
    238247}
    239248
    240249revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom);
     250if ($recovery_path_base) {
     251    delete_recovery_files($rimage, $rmask, $rweight, $rch_mask);
     252}
    241253
    242254if ($stage eq "diff" and $bothways) {
     
    251263    $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
    252264    revert_files($replace, $image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef);
     265    if ($recovery_path_base) {
     266        $rimage  = $ipprc->filename($name, $recovery_path_base);
     267        $rmask   = $ipprc->filename("$name.MASK", $recovery_path_base);
     268        $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base);
     269        delete_recovery_files($rimage, $rmask, $rweight);
     270    }
    253271}
    254272
     
    426444
    427445
    428 sub file_check
    429 {
    430     my $file = shift;           # Name of file
    431     &my_die("Unable to find output file: $file", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless
    432         $ipprc->file_exists($file);
     446sub delete_recovery_files
     447{
     448    foreach my $file (@_) {
     449        if ($ipprc->file_exists($file)) {
     450            if (!$ipprc->file_delete($file)) {
     451                &my_die("failed to delete recovery file $file", $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR);
     452            }
     453        }
     454    }
    433455}
    434456
  • tags/ipp-20101215/ippTasks/pstamp.pro

    r29719 r30321  
    258258        book getword pstampRequest $pageName ds_outProduct -var PRODUCT
    259259        book getword pstampRequest $pageName outdir -var OUTDIR
     260        book getword pstampRequest $pageName need_magic -var NEED_MAGIC
    260261        book getword pstampRequest $pageName label -var LABEL
    261262
     
    263264
    264265        $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --outdir $OUTDIR --label $LABEL --redirect-output
     266
     267        if ($NEED_MAGIC != 0)
     268            $run = $run --need_magic
     269        end
    265270
    266271        add_standard_args run
  • tags/ipp-20101215/ippTasks/survey.pro

    r29768 r30321  
    259259# user functions to manipulate destreak labels
    260260macro survey.add.destreak
    261   if ($0 != 3)
    262     echo "USAGE: survey.add.destreak (label) (workdir base)"
     261  if ($0 != 4)
     262    echo "USAGE: survey.add.destreak (label) (workdir base) (recovery root)"
    263263    break
    264264  end
    265265  book newpage SURVEY_DESTREAK $1
    266266  book setword SURVEY_DESTREAK $1 WORKDIR $2
     267  book setword SURVEY_DESTREAK $1 RECOVERYROOT $3
    267268  book setword SURVEY_DESTREAK $1 STATE PENDING
    268269end
     
    821822    book setword SURVEY_DESTREAK $label STATE DONE
    822823    book getword SURVEY_DESTREAK $label WORKDIR -var workdir
     824    book getword SURVEY_DESTREAK $label RECOVERYROOT -var recoveryroot
    823825 
    824826    $run = magic_destreak_defineruns.pl --label $label --workdir $workdir/$label
     827    if ("$recoveryroot" != "NULL")
     828        $run = $run --recoveryroot $recoveryroot/$label
     829    end
    825830
    826831    if ($DB:n == 0)
  • tags/ipp-20101215/ippTools/share

  • tags/ipp-20101215/ippTools/share/disttool_pending_camera.sql

    • Property svn:mergeinfo deleted
  • tags/ipp-20101215/ippTools/share/disttool_revertrun.sql

    r26266 r30321  
    11UPDATE distRun
    22SET distRun.fault = 0
    3 WHERE distRun.state = 'new'
     3WHERE (distRun.state = 'new' OR distRun.state = 'goto_cleaned')
    44    AND distRun.fault != 0
  • tags/ipp-20101215/ippTools/share/magicdstool_todestreak_camera.sql

    • Property svn:mergeinfo deleted
  • tags/ipp-20101215/ippTools/share/magicdstool_torevert_diff.sql

    r27945 r30321  
    1010    outroot,
    1111    diffSkyfile.path_base,
     12    magicDSFile.backup_path_base,
     13    magicDSFile.recovery_path_base,
    1214    "NULL" AS cam_path_base,
    1315    CAST(diffRun.bothways AS SIGNED) AS bothways,
  • tags/ipp-20101215/ippTools/share/pstamptool_pendingreq.sql

    r27874 r30321  
    33    pstampRequest.*,
    44    pstampDataStore.outProduct AS ds_outProduct,
     5    IFNULL(pstampDataStore.need_magic, 1) AS need_magic,
    56    IFNULL(Label.priority, 10000) AS priority
    67FROM pstampRequest
  • tags/ipp-20101215/ippTools/share/pxadmin_create_tables.sql

    r30049 r30321  
    13911391        uri VARCHAR(255),
    13921392        pollInterval INTEGER DEFAULT 60,
     1393        need_magic TINYINT,
    13931394        PRIMARY KEY(ds_id),
    13941395        KEY(ds_id)
  • tags/ipp-20101215/ippTools/src/magicdstool.c

    r30235 r30321  
    17241724    PXOPT_LOOKUP_STR(component, config->args, "-component", false, false);
    17251725    PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
     1726    PXOPT_LOOKUP_STR(recoveryroot, config->args, "-set_recoveryroot", false, false);
    17261727
    17271728    psString query = pxDataGet("magicdstool_setfiletoupdate.sql");
     
    17341735    if (label) {
    17351736        psStringAppend(&setHook, "\n , magicDSRun.label = '%s'", label);
     1737    }
     1738    if (recoveryroot) {
     1739        psStringAppend(&setHook, "\n , magicDSRun.recoveryroot = '%s'", recoveryroot);
    17361740    }
    17371741
  • tags/ipp-20101215/ippTools/src/magicdstoolConfig.c

    r29994 r30321  
    230230    psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-component", 0, "define component", NULL);
    231231    psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-set_label", 0, "set new label", NULL);
     232    psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-set_recoveryroot", 0, "define new recovery directory", NULL);
    232233
    233234    // -destreakedfile
  • tags/ipp-20101215/ippTools/src/pstamptool.c

    r29993 r30321  
    134134    PXOPT_LOOKUP_STR(label,       config->args, "-set_label",         false, false);
    135135    PXOPT_LOOKUP_S32(pollInterval, config->args, "-set_poll_interval",false, false);
     136    PXOPT_LOOKUP_BOOL(no_magic, config->args, "-set_no_magic", false);
     137
     138    bool need_magic = ! no_magic;
    136139
    137140    if (!pstampDataStoreInsert(config->dbh,
     
    143146            outProduct,
    144147            uri,
    145             pollInterval
     148            pollInterval,
     149            need_magic
    146150        )) {
    147151        psError(PS_ERR_UNKNOWN, false, "database error");
  • tags/ipp-20101215/ippTools/src/pstamptoolConfig.c

    r29993 r30321  
    5151    psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-set_label",        0, "define datastore label", NULL);
    5252    psMetadataAddS32(adddatastoreArgs, PS_LIST_TAIL, "-set_poll_interval", 0, "define datastore poll interval (seconds)", 60);
     53    psMetadataAddBool(adddatastoreArgs,PS_LIST_TAIL, "-set_no_magic",   0, "set magic not required", true);
    5354
    5455    // -datastore
  • tags/ipp-20101215/magic/remove

  • tags/ipp-20101215/magic/remove/src/streaksVersion.c

    r28043 r30321  
    5858    psString source = streaksSource();   // Software source
    5959
    60     psMetadataAddStr(header, PS_LIST_TAIL, "STREAK_V", 0, NULL, source);
     60    psMetadataAddStr(header, PS_LIST_TAIL, "STREAK_V", PS_META_REPLACE, NULL, source);
    6161   
    6262    psStringPrepend(&version, "%s version: ", streaksProgram);
  • tags/ipp-20101215/magic/remove/src/streakscompare.c

    r26477 r30321  
    1818    ippStage stage = psMetadataLookupS32(&status, config->arguments, "STAGE");
    1919
    20     sFile *file1 = sFileOpen(config, stage, "INPUT1", NULL, true);
    21     sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true);
     20    sFile *file1 = sFileOpen(config, stage, "INPUT1", NULL, true, false);
     21    sFile *file2 = sFileOpen(config, stage, "INPUT2", NULL, true, false);
    2222
    2323    int ncomponents;
  • tags/ipp-20101215/magic/remove/src/streaksio.c

    r29392 r30321  
    4242    sf->class_id = psMetadataLookupStr(&status, config->arguments, "CLASS_ID");
    4343
    44     sf->inImage = sFileOpen(config, stage, "INPUT", NULL, true);
     44    sf->inImage = sFileOpen(config, stage, "INPUT", NULL, true, false);
    4545    sf->nHDU = sf->inImage->nHDU;
    4646
     
    4848    // The names of the temporary and recovery files are taken from the input
    4949    char *inputBasename = basename(sf->inImage->name);
    50     sf->outImage = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     50    sf->outImage = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true);
    5151
    5252    if (remove) {
    5353        // XXX: the recovery file should be required if stage is raw and the replace flag is set
    5454        // that is if the input raw image is to be destroyed
    55         sf->recImage = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
    56     } else {
    57         sf->recImage = sFileOpen(config, stage, "RECOVERY.IMAGE", NULL, true);
    58     }
    59 
    60     sf->inMask = sFileOpen(config, stage, "INPUT.MASK", NULL, false);
     55        sf->recImage = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false);
     56    } else {
     57        sf->recImage = sFileOpen(config, stage, "RECOVERY.IMAGE", NULL, true, false);
     58    }
     59
     60    sf->inMask = sFileOpen(config, stage, "INPUT.MASK", NULL, false, false);
    6161    if (sf->inMask && (sf->stage != IPP_STAGE_RAW)) {
    6262        inputBasename = basename(sf->inMask->name);
    63         sf->outMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     63        sf->outMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true);
    6464        if (remove) {
    65             sf->recMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
     65            sf->recMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false);
    6666        } else {
    67             sf->recMask = sFileOpen(config, stage, "RECOVERY.MASK", NULL, true);
     67            sf->recMask = sFileOpen(config, stage, "RECOVERY.MASK", NULL, true, false);
    6868        }
    6969    }
     
    7373    // If it doesn't exist, we didn't have a camera mask
    7474    if (remove && sf->inMask && (stage == IPP_STAGE_CHIP)) {
    75         sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, false);
     75        sf->inChMask = sFileOpen(config, stage, "INPUT.CHMASK", NULL, false, false);
    7676        if (sf->inChMask) {
    7777            inputBasename = basename(sf->inChMask->name);
    78             sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
    79             sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
    80         }
    81     }
    82 
    83     sf->inWeight = sFileOpen(config, stage, "INPUT.WEIGHT", NULL, false);
     78            sf->outChMask = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true);
     79            sf->recChMask = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false);
     80        }
     81    }
     82
     83    sf->inWeight = sFileOpen(config, stage, "INPUT.WEIGHT", NULL, false, false);
    8484    if (sf->inWeight) {
    8585        inputBasename = basename(sf->inWeight->name);
    86         sf->outWeight = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     86        sf->outWeight = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true);
    8787        if (remove) {
    88             sf->recWeight = sFileOpen(config, stage, "RECOVERY", inputBasename, false);
     88            sf->recWeight = sFileOpen(config, stage, "RECOVERY", inputBasename, false, false);
    8989        } else {
    90             sf->recWeight = sFileOpen(config, stage, "RECOVERY.WEIGHT", NULL, true);
     90            sf->recWeight = sFileOpen(config, stage, "RECOVERY.WEIGHT", NULL, true, false);
    9191        }
    9292    }
    9393    if (remove) {
    94         sf->inSources = sFileOpen(config, stage, "SOURCES", NULL, false);
     94        sf->inSources = sFileOpen(config, stage, "SOURCES", NULL, false, false);
    9595        if (sf->inSources) {
    9696            inputBasename = basename(sf->inSources->name);
    97             sf->outSources = sFileOpen(config, stage, "OUTPUT", inputBasename, true);
     97            sf->outSources = sFileOpen(config, stage, "OUTPUT", inputBasename, true, true);
    9898        }
    9999    }
     
    121121    sf->transparentStreaks = psMetadataLookupF64(&status, config->arguments, "TRANSPARENT_STREAKS");
    122122
    123     sf->stats = psMetadataAlloc();
    124     psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS");
    125     if (statsFileName) {
    126         sf->statsFile = fopen(statsFileName, "w");
    127         if (!sf->statsFile) {
    128             psError(PS_ERR_IO, true, "failed to open stats file %s", statsFileName);
    129             streaksExit("", PS_EXIT_CONFIG_ERROR);
    130         }
    131     }
    132 
    133123    return sf;
    134124}
     
    138128{
    139129    freeImages(sf);
     130    psFree(sf->stats);
    140131    psFree(sf->diffedPixels);
    141132    psFree(sf->tiles);
     
    221212
    222213static psString
    223 resolveFilename(pmConfig *config, sFile *sfile, bool create)
     214resolveFilename(pmConfig *config, sFile *sfile, bool create, bool checkIfDestreaked)
    224215{
    225216    sfile->inNebulous = IN_NEBULOUS(sfile->name);
     
    232223            // instance. It will get created below in pmConfigConvertFilename
    233224            if ((sfile->resolved_name = nebFind(server, sfile->name)) != NULL) {
    234                 if (!nebFileIsDestreaked(sfile)) {
     225                if (checkIfDestreaked && !nebFileIsDestreaked(sfile)) {
    235226                    psError(PS_ERR_IO, false, "attempting to delete file that has not been destreaked %s", sfile->name);
    236227                    return NULL;
     
    247238
    248239sFile *sFileOpen(pmConfig *config, ippStage stage, psString fileSelect,
    249     psString outputFilename, bool required)
     240    psString outputFilename, bool required, bool checkIfDestreaked)
    250241{
    251242    bool status;
     
    322313    // and the file is to be opened for writing
    323314    if (outputFilename) {
     315        sfile->write = true;
    324316        psStringAppend(&sfile->name, "%s%s", name, outputFilename);
    325         sfile->resolved_name = resolveFilename(config, sfile, true);
     317        sfile->resolved_name = resolveFilename(config, sfile, true, checkIfDestreaked);
    326318        if (!sfile->resolved_name) {
    327319            psError(PS_ERR_IO, false, "Failed to resolve filename for %s", sfile->name);
     
    335327    } else {
    336328        sfile->name = psStringCopy(name);
    337         sfile->resolved_name = resolveFilename(config, sfile, false);
     329        sfile->resolved_name = resolveFilename(config, sfile, false, false);
    338330        if (!sfile->resolved_name) {
    339331            psError(PS_ERR_IO, false, "Failed to resolve name for %s", sfile->name);
     
    402394
    403395void
    404 addDestreakKeyword(psMetadata *header)
     396addDestreakKeyword(psMetadata *header, bool value)
    405397{
    406398    psMetadataAddBool(header, PS_LIST_TAIL, "PSDESTRK", PS_META_REPLACE,
    407         "Have streaks been removed from image?", true);
     399        "Have streaks been removed from image?", value);
    408400}
    409401
     
    416408
    417409void
    418 copyPHU(streakFiles *sfiles, bool remove)
     410copyPHU(streakFiles *sfiles, bool remove, bool destreak)
    419411{
    420412    psAssert(sfiles->stage == IPP_STAGE_RAW, "copyPHU should only be used for raw stage");
     
    433425
    434426    // add keyword indicating that streaks have been removed
    435     addDestreakKeyword(imageHeader);
     427    addDestreakKeyword(imageHeader, destreak);
    436428
    437429    if (!psFitsWriteBlank(sfiles->outImage->fits, imageHeader, NULL)) {
     
    463455        }
    464456        // add keyword indicating that streaks have been removed
    465         addDestreakKeyword(maskHeader);
     457        addDestreakKeyword(maskHeader, destreak);
    466458        if (!psFitsWriteBlank(sfiles->outMask->fits, maskHeader, NULL)) {
    467459            psError(PS_ERR_IO, false, "failed to write primary header to %s",
     
    493485
    494486        // add keyword indicating that streaks have been removed
    495         addDestreakKeyword(weightHeader);
     487        addDestreakKeyword(weightHeader, destreak);
    496488        if (!psFitsWriteBlank(sfiles->outWeight->fits, weightHeader, NULL)) {
    497489            psError(PS_ERR_IO, false, "failed to write primary header to %s",
     
    683675    psVector *tiles)
    684676{
    685     if (!sfile) {
     677    if (!sfile || !sfile->write) {
    686678        return;
    687679    }
     
    861853        streaksExit("", PS_EXIT_DATA_ERROR);
    862854    }
     855    sfile->fits = NULL;
    863856    psFree(sfile->header);
    864857    sfile->header = NULL;
     
    12501243    } else if (in->image->type.type == PS_TYPE_F32) {
    12511244        in->exciseValue = NAN;
     1245    } else if (in->image->type.type == PS_TYPE_F64) {
     1246        in->exciseValue = NAN;
    12521247    } else {
    12531248        psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type);
  • tags/ipp-20101215/magic/remove/src/streaksio.h

    r26408 r30321  
    55
    66sFile *sFileOpen(pmConfig *config, ippStage stage, psString fileSelect,
    7     psString outputFilename, bool required);
     7    psString outputFilename, bool required, bool checkIfDestreaked);
    88
    99void closeImages(streakFiles *sfiles);
     
    1212
    1313void readImage(sFile *sfile, int extnum, ippStage stage, bool isMask);
    14 void copyPHU(streakFiles *sfiles, bool remove);
     14void copyPHU(streakFiles *sfiles, bool remove, bool destreaked);
    1515void copyTable(sFile *out, sFile *in, int extnum);
    1616void copyFitsOptions(sFile *out, sFile *rec, sFile *in, psVector *tiles);
     
    2424void readImageFrom_pmFile(streakFiles *sf);
    2525
    26 void addDestreakKeyword(psMetadata *);
     26void addDestreakKeyword(psMetadata *, bool value);
    2727void addRecoveryKeyword(psMetadata *);
    2828
  • tags/ipp-20101215/magic/remove/src/streaksrelease.c

    r27468 r30321  
    2424    if (sfiles->stage == IPP_STAGE_RAW) {
    2525        // copy PHU to output files
    26         copyPHU(sfiles, true);
     26        copyPHU(sfiles, false, true);
    2727
    2828        // advance to the first image extension
  • tags/ipp-20101215/magic/remove/src/streaksremove.c

    r29806 r30321  
    9393        // Raw files have a phu and multiple extensions, one per chip
    9494        // Since this is a raw file, copy it's PHU to output files
    95         copyPHU(sfiles, true);
     95        copyPHU(sfiles, true, true);
    9696
    9797        // advance to the first image extension
     
    275275    psLogMsg("streaksremove", PS_LOG_INFO, "time to run streaksremove: %f\n", total_time);
    276276
    277     if (sfiles->statsFile) {
    278         const char *statsMDC = psMetadataConfigFormat(sfiles->stats);
    279         if (!statsMDC || strlen(statsMDC) == 0) {
    280             psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
    281         } else {
    282             fprintf(sfiles->statsFile, "%s", statsMDC);
    283             psFree(statsMDC);
    284             fclose(sfiles->statsFile);
    285             sfiles->statsFile = NULL;
    286             psFree(sfiles->stats);
    287             sfiles->stats = NULL;
    288         }
    289     }
     277    psString statsFileName= psMetadataLookupStr(&status, config->arguments, "STATS");
     278
     279    if (statsFileName) {
     280    // Write out
     281        psString resolved = pmConfigConvertFilename(statsFileName, config, true, true); // Resolved filename
     282        if (!resolved) {
     283            psError(psErrorCodeLast(), false, "Unable to resolve statistics file name");
     284            return false;
     285        }
     286        if (!psMetadataConfigWrite(sfiles->stats, resolved, NULL)) {
     287            psError(psErrorCodeLast(), false, "Unable to serialize stats metadata.\n");
     288            psFree(resolved);
     289            return false;
     290        }
     291        psFree(resolved);
     292    }
     293
    290294    // all done. Clean up to look for memory leaks.
    291295
     
    613617        addRecoveryKeyword(sf->recImage->header);
    614618    }
    615     addDestreakKeyword(sf->outImage->header);
     619    addDestreakKeyword(sf->outImage->header, true);
    616620
    617621    if (!SFILE_IS_IMAGE(sf->inImage)) {
     
    639643                addRecoveryKeyword(sf->recMask->header);
    640644            }
    641             addDestreakKeyword(sf->outMask->header);
     645            addDestreakKeyword(sf->outMask->header, true);
    642646            // Note: we don't excise the mask pixels even if exciseAll is true.
    643647            setupImageRefs(sf->outMask, sf->recMask, sf->inMask, sf->extnum, false);
     
    671675            addRecoveryKeyword(sf->recWeight->header);
    672676        }
    673         addDestreakKeyword(sf->outWeight->header);
     677        addDestreakKeyword(sf->outWeight->header, true);
    674678        setupImageRefs(sf->outWeight, sf->recWeight, sf->inWeight, sf->extnum, exciseAll);
    675679
     
    912916            streaksExit("", PS_EXIT_DATA_ERROR);
    913917        }
    914         addDestreakKeyword(header);
     918        addDestreakKeyword(header, true);
    915919
    916920        if (!psFitsWriteBlank(out->fits, header, extname)) {
     
    973977        psArrayRealloc(outTable, j);
    974978
    975         addDestreakKeyword(header);
     979        addDestreakKeyword(header, true);
    976980        if (psArrayLength(outTable) > 0) {
    977981            printf("Censored %d sources\n", numCensored);
  • tags/ipp-20101215/magic/remove/src/streaksremove.h

    r27752 r30321  
    1818    psString    name;
    1919    bool        inNebulous;
     20    bool        write;
    2021    psFits      *fits;
    2122    int         nHDU;
  • tags/ipp-20101215/magic/remove/src/streaksreplace.c

    r26477 r30321  
    3636    if (sfiles->stage == IPP_STAGE_RAW) {
    3737        // copy PHU to output files
    38         copyPHU(sfiles, false);
     38        copyPHU(sfiles, false, false);
    3939
    4040        // advance to the first image extension
     
    296296
    297297    sf->outImage->header = (psMetadata*) psMemIncrRefCounter(sf->inImage->header);
     298    addDestreakKeyword(sf->outImage->header, false);
    298299
    299300    if (!SFILE_IS_IMAGE(sf->inImage)) {
     
    317318        readImage(sf->recMask, sf->extnum, sf->stage, true);
    318319        sf->outMask->header = (psMetadata*) psMemIncrRefCounter(sf->inMask->header);
     320       
     321        addDestreakKeyword(sf->outMask->header, false);
    319322
    320323        // XXX: TODO
     
    329332
    330333        sf->outWeight->header = (psMetadata*) psMemIncrRefCounter(sf->inWeight->header);
     334        addDestreakKeyword(sf->outWeight->header, false);
    331335        setupImageRefs(sf->outMask, NULL, sf->inMask, sf->extnum, false);
    332336
  • tags/ipp-20101215/pstamp/scripts

  • tags/ipp-20101215/pstamp/scripts/pstamp_checkdependent.pl

    r29624 r30321  
    680680            foreach my $c (@$components) {
    681681                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";
    682684                my $dsfile = runToolAndParseExpectOne($command, $verbose);
    683685                if (!$dsfile) {
  • tags/ipp-20101215/pstamp/scripts/pstamp_job_run.pl

    r30001 r30321  
    1414use File::Basename;
    1515use File::Copy;
     16use File::Temp qw(tempfile);
    1617use Digest::MD5::File qw( file_md5_hex );
    1718use PS::IPP::PStamp::RequestFile qw( :standard );
     19use PS::IPP::PStamp::Job qw( :standard );
    1820use IPC::Cmd 0.36 qw( can_run run );
    1921use POSIX;
     
    2628
    2729my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options);
    28 my ($verbose, $dbname, $dbserver, $no_update);
     30my ($verbose, $dbname, $dbserver, $no_update, $save_temps);
    2931
    3032GetOptions(
     
    3941    'verbose'           =>  \$verbose,
    4042    'no-update'         =>  \$no_update,
     43    'save-temps'        =>  \$save_temps,
    4144);
    4245
     
    7578my $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);
    7679my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1);
     80my $streaksreplace = can_run('streaksreplace')  or (warn "Can't find streaksreplace"  and $missing_tools = 1);
     81my $magicdstool = can_run('magicdstool')  or (warn "Can't find magicdstool"  and $missing_tools = 1);
    7782
    7883if ($missing_tools) {
     
    8893    my $argString;
    8994    $argString = $params->{job_args};
     95    my $stage = $params->{stage};
    9096
    9197    # XXX: should we do any other sanity checking?
    9298    my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString;
    9399
    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}";
    95114    my @file_list = ($params->{image});
    96115   
    97     my $nan_masked = 1;
    98     if (!$params->{magicked}) {
    99         $nan_masked = 0;
    100     }
    101116    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;
    104120    }
    105121    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;
    108125    }
    109126
     
    113130    }
    114131
    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";
    118212    $command .= " -dbname $dbname" if $dbname;
    119213    $command .= " -dbserver $dbserver" if $dbserver;
    120     $command .= " -stage $params->{stage}" if $params->{stage};
     214    $command .= " -stage $stage";
    121215    $command .= " -no_censor_masked" unless $nan_masked;
    122216    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    131225    }
    132226
     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
    133234    if ($exitStatus == 0) {
    134         my $dir = dirname($outputBase);
    135 
    136         my $reglist = "$dir/reglist$job_id";
     235        my $reglist = "$outdir/reglist$job_id";
    137236
    138237        my $F;
     
    363462
    364463sub check_files {
     464    my $error_code = shift;
     465    my $return_code = 1;
    365466    foreach my $f (@_) {
    366467        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
     479sub 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;
    370511}
    371512
  • tags/ipp-20101215/pstamp/scripts/pstamp_parser_run.pl

    r29576 r30321  
    3131my $outdir;
    3232my $label;
     33my $need_magic;
    3334my $verbose;
    3435my $dbname;
     
    4142    'outdir=s'          =>  \$outdir,
    4243    'label=s'           =>  \$label,
     44    'need_magic'        =>  \$need_magic,
    4345    'redirect-output'   =>  \$redirect_output,
    4446    'verbose'           =>  \$verbose,
     
    160162            $parse_cmd = "$pstampparse";
    161163            $parse_cmd .= " --label $label" if $label;
     164            $parse_cmd .= " --need_magic" if $need_magic;
    162165            $request_fault = 0;
    163166        } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") {
  • tags/ipp-20101215/pstamp/scripts/pstamp_server_status

    r29572 r30321  
    4444chdir $rundir or die "failed to cd to $rundir";
    4545
     46
     47my $down = 0;
     48if ($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}
    4652
    4753my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
  • tags/ipp-20101215/pstamp/scripts/pstampparse.pl

    r30016 r30321  
    3030my $save_temps;
    3131my $no_update;
     32my $dest_requires_magic;
    3233
    3334GetOptions(
     
    3839    'label=s'   =>  \$label,
    3940    'mode=s'    =>  \$mode,
     41    'need_magic'=>  \$dest_requires_magic,
    4042    'dbname=s'  =>  \$dbname,
    4143    'dbserver=s'=>  \$dbserver,
     
    126128}
    127129
    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
    129132
    130133my $label_changed = 0;
     
    384387    my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);
    385388    if (!$proj_hash) {
    386         foreach $row (@$rowList) {
    387             insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT);
     389        foreach my $r (@$rowList) {
     390            insertFakeJobForRow($r, 1, $PSTAMP_UNKNOWN_PRODUCT);
    388391            $num_jobs++;
    389392        }
     
    409412    $need_magic    = $proj_hash->{need_magic};
    410413
    411     # Temporary hack so that IFA can get at non-magicked data
    412     my $allow_mops_unmagicked = 1;
    413     if ($allow_mops_unmagicked) {
    414         if ($product and (($product eq "mops-pstamp-results") or
    415                           ($product eq "mops-pstamp-results2") or
    416                           ($product eq "ifa-pstamp-results"))) {
    417             $need_magic = 0;
    418         }
    419     }
    420 
    421414    $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    }
    422448   
    423449    my $numRows = scalar @$rowList;
Note: See TracChangeset for help on using the changeset viewer.