- Timestamp:
- Mar 8, 2009, 4:29:34 PM (17 years ago)
- Location:
- branches/eam_branches/eam_branch_20090303
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/eam_branch_20090303
-
branches/eam_branches/eam_branch_20090303/ippScripts/scripts/ipp_cleanup.pl
r23176 r23225 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; 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 46 47 47 # $mode must be one of "goto_cleaned", "goto_scrubbed", or … … 50 50 # to be cleaned; they cannot be recovered, but the small data is left 51 51 # behind). XXX make 'scrubbed' a data_state? 52 53 52 unless (($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"; 55 54 } 56 55 … … 66 65 } 67 66 68 $ipprc->define_camera($camera);69 70 67 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 71 68 72 69 # choice of files to delete depends on the stage 73 70 if ($stage eq "chip") { 74 71 75 72 die "--stage_id required for stage chip\n" if !$stage_id; 76 73 ### select the imfiles for this entry … … 98 95 # loop over all of the imfiles, determine the path_base and class_id for each 99 96 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}; 102 99 my $status = 1; 103 100 104 101 # 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-existent102 # modes goto_purged and goto_scrubbed will remove files even if the config is non-existent 106 103 if ($mode eq "goto_cleaned") { 107 104 my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id); … … 136 133 addFilename (\@files, "PPIMAGE.CONFIG", $path_base, $class_id); 137 134 } 138 135 139 136 # actual command to delete the files 140 137 $status = &delete_files (\@files); 141 138 } 142 139 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"; 145 142 if ($mode eq "goto_purged") { 146 143 $command .= " -topurgedimfile"; 147 144 } elsif ($mode eq "goto_scrubbed") { 148 145 $command .= " -tocleanedimfile_from_scrubbed"; 149 } else {146 } else { 150 147 $command .= " -tocleanedimfile"; 151 148 } 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 ) = 155 152 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 } 160 157 } 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_*) 162 160 my $command = "$chiptool -updateprocessedimfile -chip_id $stage_id -class_id $class_id -set_state $error_state"; 163 161 $command .= " -dbname $dbname" if defined $dbname; 164 162 165 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =163 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 166 164 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 } 172 170 } 173 171 exit 0; 174 } 172 } 175 173 176 174 if ($stage eq "camera") { … … 258 256 } 259 257 exit 0; 260 } 258 } 261 259 262 260 if ($stage eq "warp") { … … 319 317 } 320 318 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"; 323 321 if ($mode eq "goto_purged") { 324 322 $command .= " -topurgedskyfile"; … … 326 324 $command .= " -tocleanedskyfile"; 327 325 } 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 ) = 331 329 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 } 336 334 } else { 337 335 my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state"; … … 340 338 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 341 339 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 } 346 344 exit $PS_EXIT_UNKNOWN_ERROR; 347 }345 } 348 346 } 349 347 exit 0; … … 357 355 die "ipp_cleanup.pl -stage $stage not yet implemented\n"; 358 356 359 sub delete_files 357 sub delete_files 360 358 { 361 359 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. 364 362 foreach my $file (@$files) { 365 print STDERR "unlinking $file\n";363 print STDERR "unlinking $file\n"; 366 364 $ipprc->file_delete($file); 367 365 } … … 369 367 } 370 368 371 sub addFilename 369 sub addFilename 372 370 { 373 371 my $files = shift; # reference to a list of files to unlink
Note:
See TracChangeset
for help on using the changeset viewer.
