IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 8, 2009, 4:29:34 PM (17 years ago)
Author:
eugene
Message:

merging changes from head into my branch

Location:
branches/eam_branches/eam_branch_20090303
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/eam_branch_20090303

  • branches/eam_branches/eam_branch_20090303/ippScripts/scripts/ipp_cleanup.pl

    r23176 r23225  
    1818use Pod::Usage qw( pod2usage );
    1919
    20 my $ipprc = PS::IPP::Config->new(); # this is used for PATH, NEB filename conversions
    21 
    2220# Parse the command-line arguments
    2321my ($stage, $camera, $stage_id, $mode, $path_base, $dbname, $verbose, $no_op, $helplist);
    2422GetOptions('stage=s'        => \$stage,     # which analysis stage to clean?
    25            'camera|i=s'     => \$camera,    # user-supplied camera name
    26            'stage_id=s'     => \$stage_id,  # id for this stage (only needed for certain stages)
    27            'mode|m=s'       => \$mode,      # cleanup mode (clean / purge)
    28            'path_base=s'    => \$path_base, # basename for files
    29            'dbname|d=s'     => \$dbname,    # Database name
     23           'camera|i=s'     => \$camera,    # user-supplied camera name
     24           'stage_id=s'     => \$stage_id,  # id for this stage (only needed for certain stages)
     25           'mode|m=s'       => \$mode,      # cleanup mode (clean / purge)
     26           'path_base=s'    => \$path_base, # basename for files
     27           'dbname|d=s'     => \$dbname,    # Database name
    3028           'verbose'        => \$verbose,   # Print to stdout
    31            'no-op'          => \$no_op,     # pretend but don't actually inject
    32            'helplist'       => \$helplist   # give help listing
    33            ) or pod2usage( 2 );
    34 
    35 pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage", 
    36            -exitval => 2) if defined $helplist;
    37 
    38 pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]", 
    39            -exitval => 2 ) if scalar @ARGV;
     29           'no-op'          => \$no_op,     # pretend but don't actually inject
     30           'helplist'       => \$helplist   # give help listing
     31           ) or pod2usage( 2 );
     32
     33pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage",
     34           -exitval => 2) if defined $helplist;
     35
     36pod2usage( -msg => "Usage: $0 --camera (name) --stage (stage) --stage_id (stage_id) --mode (mode) [--path_base (path)] [--dbname dbname] [--no-op] [--help]",
     37           -exitval => 2 ) if scalar @ARGV;
    4038
    4139pod2usage( -msg => "Required options:--camera (name) --stage (stage) --mode (mode)",
    42            -exitval => 3) unless
     40           -exitval => 3) unless
    4341    defined $camera and
    4442    defined $stage and
    4543    defined $mode;
     44
     45my $ipprc = PS::IPP::Config->new( $camera ) or my_die("Unable to set up", $stage_id, $PS_EXIT_CONFIG_ERROR); # this is used for PATH, NEB filename conversions
    4646
    4747# $mode must be one of "goto_cleaned", "goto_scrubbed", or
     
    5050# to be cleaned; they cannot be recovered, but the small data is left
    5151# behind). XXX make 'scrubbed' a data_state?
    52 
    5352unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) {
    54     die "invalid cleanup mode $mode\n";   
     53    die "invalid cleanup mode $mode\n";
    5554}
    5655
     
    6665}
    6766
    68 $ipprc->define_camera($camera);
    69 
    7067my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    7168
    7269# choice of files to delete depends on the stage
    7370if ($stage eq "chip") {
    74    
     71
    7572    die "--stage_id required for stage chip\n" if !$stage_id;
    7673    ### select the imfiles for this entry
     
    9895    # loop over all of the imfiles, determine the path_base and class_id for each
    9996    foreach my $imfile (@$imfiles) {
    100         my $class_id = $imfile->{class_id};
    101         my $path_base = $imfile->{path_base};
     97        my $class_id = $imfile->{class_id};
     98        my $path_base = $imfile->{path_base};
    10299        my $status = 1;
    103100
    104101        # don't clean up unless the data needed to update is available
    105         # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
     102        # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent
    106103        if ($mode eq "goto_cleaned") {
    107104            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
     
    136133                addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id);
    137134            }
    138        
     135
    139136            # actual command to delete the files
    140137            $status = &delete_files (\@files);
    141138        }
    142139
    143         if ($status)  {
    144             my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
     140        if ($status)  {
     141            my $command = "$chiptool -chip_id $stage_id -class_id $class_id";
    145142            if ($mode eq "goto_purged") {
    146143                $command .= " -topurgedimfile";
    147144            } elsif ($mode eq "goto_scrubbed") {
    148145                $command .= " -tocleanedimfile_from_scrubbed";
    149             } else {
     146            } else {
    150147                $command .= " -tocleanedimfile";
    151148            }
    152             $command .= " -dbname $dbname" if defined $dbname;
    153 
    154             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     149            $command .= " -dbname $dbname" if defined $dbname;
     150
     151            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    155152                    run(command => $command, verbose => $verbose);
    156             unless ($success) {
    157                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    158                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    159             }
     153            unless ($success) {
     154                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     155                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     156            }
    160157        } else {
    161             # if an error happens for a chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
     158
     159            # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will go to error_* (matching the goto_*)
    162160            my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state";
    163161            $command .= " -dbname $dbname" if defined $dbname;
    164162
    165             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     163            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    166164                    run(command => $command, verbose => $verbose);
    167             unless ($success) {
    168                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    169                 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    170             }
    171         }
     165            unless ($success) {
     166                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     167                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     168            }
     169        }
    172170    }
    173171    exit 0;
    174 } 
     172}
    175173
    176174if ($stage eq "camera") {
     
    258256    }
    259257    exit 0;
    260 } 
     258}
    261259
    262260if ($stage eq "warp") {
     
    319317        }
    320318
    321         if ($status)  {
    322             my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
     319        if ($status)  {
     320            my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";
    323321            if ($mode eq "goto_purged") {
    324322                $command .= " -topurgedskyfile";
     
    326324                $command .= " -tocleanedskyfile";
    327325            }
    328             $command .= " -dbname $dbname" if defined $dbname;
    329 
    330             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     326            $command .= " -dbname $dbname" if defined $dbname;
     327
     328            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    331329                    run(command => $command, verbose => $verbose);
    332             unless ($success) {
    333                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    334                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    335             }
     330            unless ($success) {
     331                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     332                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     333            }
    336334         } else {
    337335            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
     
    340338            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    341339                run(command => $command, verbose => $verbose);
    342             unless ($success) {
    343                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    344                 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    345             }
     340            unless ($success) {
     341                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     342                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     343            }
    346344            exit $PS_EXIT_UNKNOWN_ERROR;
    347         }
     345        }
    348346    }
    349347    exit 0;
     
    357355die "ipp_cleanup.pl -stage $stage not yet implemented\n";
    358356
    359 sub delete_files 
     357sub delete_files
    360358{
    361359    my $files = shift; # reference to a list of files to unlink
    362    
    363     # this script is, of course, very dangerous. 
     360
     361    # this script is, of course, very dangerous.
    364362    foreach my $file (@$files) {
    365         print STDERR "unlinking $file\n";
     363        print STDERR "unlinking $file\n";
    366364        $ipprc->file_delete($file);
    367365    }
     
    369367}
    370368
    371 sub addFilename 
     369sub addFilename
    372370{
    373371    my $files      = shift; # reference to a list of files to unlink
Note: See TracChangeset for help on using the changeset viewer.