Changeset 23777 for trunk/ippScripts/scripts/dist_component.pl
- Timestamp:
- Apr 9, 2009, 1:56:50 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/dist_component.pl (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/dist_component.pl
r23743 r23777 58 58 # Parse the command-line arguments 59 59 my ($dist_id, $camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $clean); 60 my ($out root, $run_state, $data_state, $magicked, $no_magic, $poor_quality);60 my ($outdir, $run_state, $data_state, $magicked, $no_magic, $poor_quality); 61 61 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 62 62 … … 71 71 'state=s' => \$run_state, # state of the run 72 72 'data_state=s' => \$data_state, # data_state for this component 73 'poor_quality' => \$poor_quality, # the processing for this component did not produced images73 'poor_quality' => \$poor_quality, # the processing for this component did not produced images 74 74 'no_magic' => \$no_magic, # magic is not required for this distribution run 75 75 'magicked' => \$magicked, # magicked state for this component 76 'out root=s' => \$outroot,# "directory" for outputs76 'outdir=s' => \$outdir, # "directory" for outputs 77 77 'clean' => \$clean, # create clean distribution 78 78 'save-temps' => \$save_temps, # Save temporary files? … … 84 84 85 85 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 86 pod2usage( -msg => "Required options: --dist_id --camera --stage --stage_id --component --path_base --out root",86 pod2usage( -msg => "Required options: --dist_id --camera --stage --stage_id --component --path_base --outdir", 87 87 -exitval => 3) unless 88 88 defined $dist_id and … … 92 92 defined $component and 93 93 defined $path_base and 94 defined $out root;94 defined $outdir; 95 95 96 96 $ipprc->redirect_output($logfile) if $logfile; 97 97 98 if (($stage eq 'raw') and ! defined $chip_path_base) {98 if (($stage eq 'raw') and !$clean and !defined $chip_path_base) { 99 99 pod2usage( -msg => "Required options: --chip_path_base for raw stage", -exitval => 3); 100 100 } … … 105 105 106 106 # making a clean bundle of raw images doesn't make sense 107 if (($stage eq "raw") and $clean) {108 # well I suppose we could ship the registration log file. naw.109 &my_die("cannot create clean run at raw stage", $dist_id, $component, $PS_EXIT_CONFIG_ERROR);110 }111 107 112 108 # create the output directories if it is not a nebulous path and it doesn't exist 113 if (index($out root, "neb://") != 0) {114 if (! -e $out root) {115 my $code = system "mkdir -p $out root";116 &my_die("cannot create output directory $out root", $dist_id, $component,109 if (index($outdir, "neb://") != 0) { 110 if (! -e $outdir ) { 111 my $code = system "mkdir -p $outdir"; 112 &my_die("cannot create output directory $outdir", $dist_id, $component, 117 113 $code >> 8) if $code; 118 114 } … … 122 118 # note: We my_die in get_file_list if something goes wrong. 123 119 124 my $file_list = get_file_list($stage, $component, $path_base );125 126 if ( $stage ne 'fake') {120 my $file_list = get_file_list($stage, $component, $path_base, $clean); 121 122 if (($stage ne 'raw') and ($stage ne 'fake')) { 127 123 # If the file list is empty it is an error because we should at least get a config dump file 128 124 # except for fake stage which doesn't do anything yet … … 132 128 # set up directory for temporary files 133 129 134 my $tmpdir = "$out root/tmpdir.$dist_id.$component";130 my $tmpdir = "$outdir/tmpdir.$dist_id.$component"; 135 131 if (-e $tmpdir) { 136 132 if (-d $tmpdir) { … … 155 151 156 152 # foreach my $file_rule (keys %$file_list) { 153 my $num_files = 0; 157 154 foreach my $file (@$file_list) { 158 155 # check whether this file rule refers to an image, mask, or variance fits image … … 188 185 # we need to pre-process the image before adding to the bundle. Save the path names. 189 186 # the images will be created below 187 $num_files++; 190 188 if ($image_type && $nan_masked_pixels) { 191 189 # save the … … 251 249 my $bytes; 252 250 my $md5sum; 253 if ($stage eq 'fake') { 251 if (0) { 252 if (($stage eq 'fake') or (($stage eq 'raw') and $clean)) { 254 253 open DUMMY, ">$tmpdir/fake.$component" or &my_die("Unable to create placeholder for fake component", 255 254 $dist_id, $component, $PS_EXIT_CONFIG_ERROR); … … 257 256 close DUMMY; 258 257 } 259 # create the tarfile 260 { 258 } 259 if ($num_files) { 260 # create the tarfile 261 261 # XXX TODO: create a file rule for the tar file name 262 262 my $tbase = basename($path_base); 263 263 $tbase .= ".$component" if $component; 264 264 $file_name = "$tbase.tgz"; 265 my $tarfile = "$out root/$file_name";265 my $tarfile = "$outdir/$file_name"; 266 266 267 267 my $command = "tar -C $tmpdir --owner=ipp --group=users -czhf $tarfile ."; … … 279 279 &my_die("unable to compute md5sum for $tarfile", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR) if !$md5sum; 280 280 281 my @finfo = stat($tarfile); 282 &my_die("unable to stat $tarfile", $dist_id, $component, $PS_EXIT_UNKNOWN_ERROR) if !@finfo; 283 $bytes = $finfo[7]; 281 $bytes = -s $tarfile; 284 282 285 283 delete_tmpdir($tmpdir); 284 } else { 285 # no files for this component 286 $file_name = "none"; 287 $bytes = 0; 288 $md5sum = "0"; 286 289 } 287 290 { … … 360 363 my $component = shift; 361 364 my $path_base = shift; 365 my $clean = shift; 362 366 363 367 my @file_list; … … 366 370 # eventually rawImfile will have a path_base that we'll need to add '.fits' 367 371 # XXX do we want to distribute the registration log files? 368 my %file; 369 $file{file_rule} = "RAW.IMAGE"; 370 $file{name} = $path_base; 371 push @file_list, \%file; 372 if (!$clean) { 373 my %file; 374 $file{file_rule} = "RAW.IMAGE"; 375 $file{name} = $path_base; 376 push @file_list, \%file; 377 } 372 378 return \@file_list; 373 379 }
Note:
See TracChangeset
for help on using the changeset viewer.
