Changeset 33141 for trunk/pstamp/scripts/detectability_respond.pl
- Timestamp:
- Jan 24, 2012, 4:40:12 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/detectability_respond.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/detectability_respond.pl
r33126 r33141 41 41 my $EXTVER = 1.0; 42 42 my $EXTNAME = 'MOPS_DETECTABILITY_RESPONSE'; 43 my ($req_id,$ req_name,$product,$need_magic,$missing_tools,$project);43 my ($req_id,$job_id,$req_name,$product,$need_magic,$missing_tools,$project); 44 44 my ($request_file,$output,$workdir,$dbname,$dbserver,$verbose,$save_temps,$ignore_wisdom); 45 45 GetOptions( … … 47 47 'output=s' => \$output, 48 48 'workdir=s' => \$workdir, 49 'job_id=s' => \$job_id, 49 50 'dbname=s' => \$dbname, 50 51 'dbserver=s' => \$dbserver, … … 298 299 $query{$fpa_id}{FAULT}[$valid_index] = $PSTAMP_GONE; 299 300 } 300 elsif ($need_magic and ($query{$fpa_id}{MAGICKED}[$valid_index] =0)) {301 elsif ($need_magic and ($query{$fpa_id}{MAGICKED}[$valid_index] eq 0)) { 301 302 $query{$fpa_id}{FAULT}[$valid_index] = $PSTAMP_NOT_DESTREAKED; 302 303 } … … 324 325 my %processing_request; 325 326 326 open(WISDOM,">$wisdom_file") or my_die("failed to open wisdom file $wisdom_file"); 327 foreach my $fpa_id (keys %query) { 328 for (my $i = 0; $i <= $#{ $query{$fpa_id}{ROWNUM} }; $i++) { 329 print WISDOM "$fpa_id\t"; 330 foreach my $key (keys %{ $query{$fpa_id} }) { 331 print WISDOM "$key $query{$fpa_id}{$key}[$i]\t"; 332 } 333 print WISDOM "\n"; 334 my $data_state = $query{$fpa_id}{DATA_STATE}[$i]; 335 if ($query{$fpa_id}{BAD_COMPONENT}[$i] == 0) { 336 if ($data_state ne 'full') { 337 338 @{ $update_request{$query{$fpa_id}{IMAGE}[$i]}{$query{$fpa_id}{FAULT}[$i]} } = 339 ($query{$fpa_id}{STATE}[$i],$query{$fpa_id}{STAGE}[$i],$query{$fpa_id}{STAGE_ID}[$i], 340 $query{$fpa_id}{COMPONENT_ID}[$i],$query{$fpa_id}{NEED_MAGIC}[$i],$query{$fpa_id}{IMAGE_DB}[$i]); 327 if (!$job_id) { 328 open(WISDOM,">$wisdom_file") or my_die("failed to open wisdom file $wisdom_file"); 329 foreach my $fpa_id (keys %query) { 330 for (my $i = 0; $i <= $#{ $query{$fpa_id}{ROWNUM} }; $i++) { 331 print WISDOM "$fpa_id\t"; 332 foreach my $key (keys %{ $query{$fpa_id} }) { 333 print WISDOM "$key $query{$fpa_id}{$key}[$i]\t"; 341 334 } 342 push @{ $processing_request{$fpa_id}{$query{$fpa_id}{IMAGE}[$i]} }, $i; 343 } 344 } 345 } 346 close(WISDOM); 347 348 # If there is anything that needs to be updated, create the update request list, and then exit the program. 349 my $exit_code = 0; 350 my $update_request_file = "${workdir}/update_request.dat"; 351 open(UPDATE_REQUEST,">$update_request_file") or my_die("failed to open update request_file $update_request_file"); 352 foreach my $images (keys %update_request) { 353 foreach my $fault (keys %{ $update_request{$images} }) { 354 if ($fault == 25) { 355 $exit_code = 25; 356 } 357 elsif ($fault != 0) { 358 $exit_code = 21; 359 } 360 my $update_request = join ' ', @{ $update_request{$images}{$fault} }; 361 print UPDATE_REQUEST "$update_request\n"; 362 } 363 } 364 close(UPDATE_REQUEST); 365 if ($exit_code != 0) { 366 exit($exit_code); 335 print WISDOM "\n"; 336 my $data_state = $query{$fpa_id}{DATA_STATE}[$i]; 337 if ($query{$fpa_id}{BAD_COMPONENT}[$i] == 0) { 338 if ($data_state ne 'full') { 339 340 @{ $update_request{$query{$fpa_id}{IMAGE}[$i]}{$query{$fpa_id}{FAULT}[$i]} } = 341 ($query{$fpa_id}{STATE}[$i],$query{$fpa_id}{STAGE}[$i],$query{$fpa_id}{STAGE_ID}[$i], 342 $query{$fpa_id}{COMPONENT_ID}[$i],$query{$fpa_id}{NEED_MAGIC}[$i],$query{$fpa_id}{IMAGE_DB}[$i]); 343 } 344 push @{ $processing_request{$fpa_id}{$query{$fpa_id}{IMAGE}[$i]} }, $i; 345 } 346 } 347 } 348 close(WISDOM); 349 350 # If there is anything that needs to be updated, create the update request list, and then exit the program. 351 my $exit_code = 0; 352 my $update_request_file = "${workdir}/update_request.dat"; 353 open(UPDATE_REQUEST,">$update_request_file") or my_die("failed to open update request_file $update_request_file"); 354 foreach my $images (keys %update_request) { 355 foreach my $fault (keys %{ $update_request{$images} }) { 356 if ($fault == 25) { 357 $exit_code = 25; 358 } 359 elsif ($fault != 0) { 360 $exit_code = 21; 361 } 362 my $update_request = join ' ', @{ $update_request{$images}{$fault} }; 363 print UPDATE_REQUEST "$update_request\n"; 364 } 365 } 366 close(UPDATE_REQUEST); 367 if ($exit_code != 0) { 368 exit($exit_code); 369 } 367 370 } 368 371 … … 714 717 $status = 0; 715 718 # print "$output\n"; 719 if (-e $output) { 720 unlink $output or die "failed to unlink existing response file $output\n"; 721 } 716 722 my $outFits = Astro::FITS::CFITSIO::create_file( $output, $status ); 717 723 check_fitsio( $status );
Note:
See TracChangeset
for help on using the changeset viewer.
