- Timestamp:
- Mar 5, 2009, 11:24:29 AM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090215
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090215
- Property svn:mergeinfo changed
/trunk merged: 22727-22752,23115-23126,23128,23137-23157,23159-23174,23182-23195,23198
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090215/ippScripts/scripts/ipp_cleanup.pl
r21371 r23199 18 18 use Pod::Usage qw( pod2usage ); 19 19 20 my $ipprc = PS::IPP::Config->new(); # this is used for PATH, NEB filename conversions21 22 20 # Parse the command-line arguments 23 21 my ($stage, $camera, $stage_id, $mode, $path_base, $dbname, $verbose, $no_op, $helplist); 24 22 GetOptions('stage=s' => \$stage, # which analysis stage to clean? 25 'camera|i=s' => \$camera, # user-supplied camera name26 '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 files29 'dbname|d=s' => \$dbname, # Database name23 '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 30 28 'verbose' => \$verbose, # Print to stdout 31 'no-op' => \$no_op, # pretend but don't actually inject32 'helplist' => \$helplist # give help listing33 ) 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 33 pod2usage( -msg => "remove temporary / all data files for an IPP analysis stage", 34 -exitval => 2) if defined $helplist; 35 36 pod2usage( -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; 40 38 41 39 pod2usage( -msg => "Required options:--camera (name) --stage (stage) --mode (mode)", 42 -exitval => 3) unless 40 -exitval => 3) unless 43 41 defined $camera and 44 42 defined $stage and 45 43 defined $mode; 46 44 47 # $mode must be one of "goto_cleaned" or "goto_purged" 48 unless (($mode eq "goto_cleaned") || ($mode eq "goto_purged")) { 49 die "invalid cleanup mode $mode\n"; 45 my $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 46 47 # $mode must be one of "goto_cleaned", "goto_scrubbed", or "goto_purged" 48 # goto_cleaned and goto_scrubbed both result in 'cleaned': scrubbed allows chips without config files to 49 # be cleaned (they cannot be recovered, but the small data is left behind) 50 unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) { 51 die "invalid cleanup mode $mode\n"; 50 52 } 51 53 … … 55 57 } 56 58 57 $ipprc->define_camera($camera);58 59 59 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 60 60 61 61 # choice of files to delete depends on the stage 62 62 if ($stage eq "chip") { 63 63 64 64 die "--stage_id required for stage chip\n" if !$stage_id; 65 65 ### select the imfiles for this entry … … 87 87 # loop over all of the imfiles, determine the path_base and class_id for each 88 88 foreach my $imfile (@$imfiles) { 89 my $class_id = $imfile->{class_id};90 my $path_base = $imfile->{path_base};89 my $class_id = $imfile->{class_id}; 90 my $path_base = $imfile->{path_base}; 91 91 my $status = 1; 92 92 93 93 # don't clean up unless the data needed to update is available 94 # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent 94 95 if ($mode eq "goto_cleaned") { 95 96 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); … … 124 125 addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id); 125 126 } 126 127 127 128 # actual command to delete the files 128 129 $status = &delete_files (\@files); 129 130 } 130 131 131 if ($status) {132 my $command = "$chiptool -chip_id $stage_id -class_id $class_id";132 if ($status) { 133 my $command = "$chiptool -chip_id $stage_id -class_id $class_id"; 133 134 if ($mode eq "goto_purged") { 134 135 $command .= " -topurgedimfile"; 136 } elsif ($mode eq "goto_scrubbed") { 137 $command .= " -tocleanedimfile_from_scrubbed"; 135 138 } else { 136 139 $command .= " -tocleanedimfile"; 137 140 } 138 $command .= " -dbname $dbname" if defined $dbname;139 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =141 $command .= " -dbname $dbname" if defined $dbname; 142 143 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 144 run(command => $command, verbose => $verbose); 142 unless ($success) {143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);144 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);145 }145 unless ($success) { 146 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 147 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 148 } 146 149 } else { 147 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1"; 148 $command .= " -dbname $dbname" if defined $dbname; 149 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will stop be run 151 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1"; 152 $command .= " -dbname $dbname" if defined $dbname; 153 154 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 151 155 run(command => $command, verbose => $verbose); 152 unless ($success) { 153 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 154 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code); 155 } 156 } 157 } 158 159 } elsif ($stage eq "camera") { 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 } 160 } 161 } 162 exit 0; 163 } 164 165 if ($stage eq "camera") { 160 166 die "--stage_id required for stage camera\n" if !$stage_id; 161 167 # this stage uses 'camtool' … … 236 242 } 237 243 exit 0; 238 } elsif ($stage eq "warp") { 244 } 245 246 if ($stage eq "warp") { 239 247 die "--stage_id required for stage warp\n" if !$stage_id; 240 248 # this stage uses 'warptool' … … 295 303 } 296 304 297 if ($status) {298 my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id";305 if ($status) { 306 my $command = "$warptool -warp_id $stage_id -skycell_id $skycell_id"; 299 307 if ($mode eq "goto_purged") { 300 308 $command .= " -topurgedskyfile"; … … 302 310 $command .= " -tocleanedskyfile"; 303 311 } 304 $command .= " -dbname $dbname" if defined $dbname;305 306 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =312 $command .= " -dbname $dbname" if defined $dbname; 313 314 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 307 315 run(command => $command, verbose => $verbose); 308 unless ($success) {309 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);310 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);311 }316 unless ($success) { 317 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 318 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 319 } 312 320 } else { 313 321 # XXX: -updateskyfile mode does not exist, need to add it 314 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";315 $command .= " -dbname $dbname" if defined $dbname;322 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1"; 323 $command .= " -dbname $dbname" if defined $dbname; 316 324 317 325 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 318 326 run(command => $command, verbose => $verbose); 319 unless ($success) {320 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);321 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);322 }327 unless ($success) { 328 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 329 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code); 330 } 323 331 exit $PS_EXIT_UNKNOWN_ERROR; 324 }332 } 325 333 } 326 334 exit 0; … … 334 342 die "ipp_cleanup.pl -stage $stage not yet implemented\n"; 335 343 336 sub delete_files 344 sub delete_files 337 345 { 338 346 my $files = shift; # reference to a list of files to unlink 339 340 # this script is, of course, very dangerous. 347 348 # this script is, of course, very dangerous. 341 349 foreach my $file (@$files) { 342 print STDERR "unlinking $file\n";350 print STDERR "unlinking $file\n"; 343 351 $ipprc->file_delete($file); 344 352 } … … 346 354 } 347 355 348 sub addFilename 356 sub addFilename 349 357 { 350 358 my $files = shift; # reference to a list of files to unlink
Note:
See TracChangeset
for help on using the changeset viewer.
