Changeset 23186 for trunk/ippScripts/scripts/ipp_cleanup.pl
- Timestamp:
- Mar 4, 2009, 4:17:15 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ipp_cleanup.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_cleanup.pl
r22750 r23186 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 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 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 48 # goto_cleaned and goto_scrubbed both result in 'cleaned': scrubbed allows chips without config files to 49 49 # be cleaned (they cannot be recovered, but the small data is left behind) 50 50 unless (($mode eq "goto_cleaned") || ($mode eq "goto_scrubbed") || ($mode eq "goto_purged")) { 51 die "invalid cleanup mode $mode\n"; 51 die "invalid cleanup mode $mode\n"; 52 52 } 53 53 … … 57 57 } 58 58 59 $ipprc->define_camera($camera);60 61 59 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 62 60 63 61 # choice of files to delete depends on the stage 64 62 if ($stage eq "chip") { 65 63 66 64 die "--stage_id required for stage chip\n" if !$stage_id; 67 65 ### select the imfiles for this entry … … 89 87 # loop over all of the imfiles, determine the path_base and class_id for each 90 88 foreach my $imfile (@$imfiles) { 91 my $class_id = $imfile->{class_id};92 my $path_base = $imfile->{path_base};89 my $class_id = $imfile->{class_id}; 90 my $path_base = $imfile->{path_base}; 93 91 my $status = 1; 94 92 95 93 # don't clean up unless the data needed to update is available 96 # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent94 # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent 97 95 if ($mode eq "goto_cleaned") { 98 96 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); … … 127 125 addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id); 128 126 } 129 127 130 128 # actual command to delete the files 131 129 $status = &delete_files (\@files); 132 130 } 133 131 134 if ($status) {135 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"; 136 134 if ($mode eq "goto_purged") { 137 135 $command .= " -topurgedimfile"; 138 136 } elsif ($mode eq "goto_scrubbed") { 139 137 $command .= " -tocleanedimfile_from_scrubbed"; 140 } else {138 } else { 141 139 $command .= " -tocleanedimfile"; 142 140 } 143 $command .= " -dbname $dbname" if defined $dbname;144 145 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 ) = 146 144 run(command => $command, verbose => $verbose); 147 unless ($success) {148 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);149 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);150 }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 } 151 149 } else { 152 # if an error happens for one chip, the chipRun will stay in goto_*, but the chips will stop be run153 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -code 1";154 $command .= " -dbname $dbname" if defined $dbname;155 156 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 ) = 157 155 run(command => $command, verbose => $verbose); 158 unless ($success) {159 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);160 &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);161 }162 }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 } 163 161 } 164 162 exit 0; 165 } 163 } 166 164 167 165 if ($stage eq "camera") { … … 244 242 } 245 243 exit 0; 246 } 244 } 247 245 248 246 if ($stage eq "warp") { … … 305 303 } 306 304 307 if ($status) {308 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"; 309 307 if ($mode eq "goto_purged") { 310 308 $command .= " -topurgedskyfile"; … … 312 310 $command .= " -tocleanedskyfile"; 313 311 } 314 $command .= " -dbname $dbname" if defined $dbname;315 316 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 ) = 317 315 run(command => $command, verbose => $verbose); 318 unless ($success) {319 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);320 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);321 }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 } 322 320 } else { 323 321 # XXX: -updateskyfile mode does not exist, need to add it 324 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -code 1";325 $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; 326 324 327 325 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 328 326 run(command => $command, verbose => $verbose); 329 unless ($success) {330 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);331 &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);332 }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 } 333 331 exit $PS_EXIT_UNKNOWN_ERROR; 334 }332 } 335 333 } 336 334 exit 0; … … 344 342 die "ipp_cleanup.pl -stage $stage not yet implemented\n"; 345 343 346 sub delete_files 344 sub delete_files 347 345 { 348 346 my $files = shift; # reference to a list of files to unlink 349 350 # this script is, of course, very dangerous. 347 348 # this script is, of course, very dangerous. 351 349 foreach my $file (@$files) { 352 print STDERR "unlinking $file\n";350 print STDERR "unlinking $file\n"; 353 351 $ipprc->file_delete($file); 354 352 } … … 356 354 } 357 355 358 sub addFilename 356 sub addFilename 359 357 { 360 358 my $files = shift; # reference to a list of files to unlink
Note:
See TracChangeset
for help on using the changeset viewer.
