Changeset 36061
- Timestamp:
- Aug 30, 2013, 3:20:12 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstampparse.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstampparse.pl
r36048 r36061 51 51 52 52 die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job"); 53 die "--file is required" if !defined($request_file_name);53 die "--file is required" unless defined($request_file_name); 54 54 55 55 if ($mode ne "list_uri") { 56 die "req_id is required" if !$req_id;56 die "req_id is required" if !$req_id; 57 57 die "outdir is required" if !$outdir; 58 die "product is required" if !$product;58 die "product is required" if !$product; 59 59 } else { 60 $req_id = 0; 61 $outdir = "nowhere"; 60 # mode eq 'list_uri' (used for parser testing) 61 # these values won't be used for anything but should be defined to avoid errors 62 $req_id = 0; 63 $outdir = "nowhere"; 62 64 $product = "dummy"; 63 65 } … … 76 78 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 77 79 my $pstampdump = can_run('pstampdump') or (warn "Can't find pstampdump" and $missing_tools = 1); 78 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1);80 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1); 79 81 80 82 if ($missing_tools) { … … 116 118 if ($extver >= 2) { 117 119 # We have a version 2 file. Require that the new keywords be supplied. 118 my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless defined $action; 119 120 my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW'); 121 122 my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) unless $email; 120 my_die("action not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) 121 unless defined $action; 122 123 my_die("invalid action: $action supplied in version $extver request file $request_file_name\n", 124 $PSTAMP_INVALID_REQUEST) 125 unless (uc($action) eq 'PROCESS' or uc($action) eq 'PREVIEW'); 126 127 my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) 128 unless $email; 129 123 130 # XXX check for "valid" $email 124 131 } else { 125 132 # for version 1 file the action is process and email is not used 126 133 $action = 'PROCESS'; 127 $email = 'null';134 $email = 'null'; 128 135 } 129 136 … … 175 182 176 183 177 if ($req_id and !$no_update){184 { 178 185 # update the database with the request name. This will be used as the 179 # the output data store's product name186 # the fileset name in the output data store 180 187 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name"; 181 188 $command .= " -set_username $email" if $email ne 'null'; 182 189 $command .= " -set_outProduct $product"; 183 190 $command .= " -set_label $label" if $label_changed; 184 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 185 run(command => $command, verbose => $verbose); 186 unless ($success) { 187 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 188 } 189 } 191 unless ($no_update) { 192 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 193 run(command => $command, verbose => $verbose); 194 unless ($success) { 195 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); 196 } 197 } else { 198 print "skipping $command\n"; 199 } 200 } 201 190 202 if ($duplicate_req_name) { 191 203 exit 0; … … 212 224 } 213 225 214 if (!$rows) { 226 my $nRows = $rows ? scalar @$rows : 0; 227 print "\n$nRows rows read from request file\n"; 228 229 unless ($nRows) { 215 230 # pstamp_job_run was invoked so the request file must have contained a valid header 216 # We can only assume that the file is invalid or more likely empty. The print above will let the 217 # log file know. Insert a faulted fake job and exit successfully. 231 # a request file with no rows is invalid. 232 # The print above will let the log file know a bit more. 233 # Insert a faulted fake job and exit this program successfully. 218 234 print STDERR "Invalid request file.\n"; 219 235 insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST); … … 222 238 223 239 224 my $nRows = scalar @$rows;225 print "\n$nRows rows read from request file\n";226 227 240 228 241 my $num_jobs = 0; 229 242 my $imageList; 230 243 my $stage; 244 my $big_limit = 100; # XXX: this should be in a configuration file some where 231 245 foreach my $row (@$rows) { 232 246 233 if (($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > 200 or $num_jobs > 200) and $req_id and !$no_update) { 234 # this is a big request and it came from one of the "high priority" channels 235 # upload page and doesn't have a specific label assigned 236 # change it to a generic one that runs with lower priority 247 248 if (!($label =~ /BIG/) and ($label =~ /PSI/ or $label =~ /WEB/) and ($nRows > $big_limit or $num_jobs > $big_limit) 249 and $req_id and !$no_update) { 250 251 # This is a "big" request and it came from one of the "high priority" channels 252 # and doesn't have a specific label assigned. 253 # Change the label to a value that its jobs run with lower priority. 254 255 my $old_label = $label; 237 256 $label = ($label =~ /WEB/) ? 'WEB.BIG' : 'PSI.BIG'; 238 print "\nChanging label for big WEB.UPrequest to $label\n";257 print "\nChanging label for big $old_label request to $label\n"; 239 258 240 259 my $command = "$pstamptool -updatereq -req_id $req_id -set_label $label"; … … 260 279 261 280 if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) { 262 print STDERR "no jobs created for $req_name\n" if $verbose; 263 insertFakeJobForRow(undef, 0, $PSTAMP_INVALID_REQUEST); 281 # this should not happen. The function above is required to insert a fake job for any 282 # rows that did not yield any jobs. 283 print STDERR "ERROR: zero jobs created for $req_name\n"; 284 insertFakeJobForRow(undef, 0, $PS_EXIT_PROG_ERROR); 264 285 } 265 286 … … 535 556 my $image_db = $proj_hash->{dbname}; 536 557 my $camera = $proj_hash->{camera}; 537 my $need_magic = $proj_hash->{need_magic};558 my $need_magic = $proj_hash->{need_magic}; 538 559 # Since user can get unmagicked data "by coordinate" requests can go back in time 539 560 # to dredge unusable data from the "dark days"... … … 546 567 $need_magic = 0 if $stage eq 'stack'; 547 568 548 if ($need_magic) { 549 550 # this project requires that postage stamps be extracted from destreaked images 551 552 if ($option_mask & ($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED)) { 553 # The user has requested uncensored stamps 554 555 if (!$dest_requires_magic) { 556 # and this user's data store destination is allowed uncensored stamps, so accept the request 557 $need_magic = 0; 558 } else { 559 print STDERR "Error row $rownum: User not authorized to to request uncensored stamps.\n"; 560 if ($option_mask & $PSTAMP_REQUIRE_UNCENSORED) { 561 # user required uncensored stamps. Can't do it so fail. 562 foreach my $r (@$rowList) { 563 insertFakeJobForRow($r, 1, $PSTAMP_NOT_AUTHORIZED); 564 $num_jobs++; 565 } 566 return $num_jobs; 567 } 568 569 # user will accept censored stamps. alter OPTION_MASK and continue 570 571 print STDERR " Will attempt to make destreaked stamps\n"; 572 # zap the offending bit in the option mask 573 $option_mask = $option_mask ^ ($PSTAMP_REQUEST_UNCENSORED); 574 foreach my $r (@$rowList) { 575 $r->{OPTION_MASK} = $option_mask; 576 } 577 } 578 } 579 } 580 569 # XXX: magic is dead 570 $need_magic = 0; 571 581 572 my $numRows = scalar @$rowList; 582 573 … … 715 706 } 716 707 $base =~ s/.fits$//; 708 709 my $filter = $image->{filter}; 710 if (!$filter) { 711 if ($stage eq 'diff') { 712 $filter = $image->{filter_1}; 713 } 714 if (!$filter) { 715 # XXX: perhaps this should be a programming error... 716 print STDERR "missing filter using 'X'\n"; 717 $filter = 'X'; 718 } 719 } 720 # use first character of filter 721 $filter = substr($filter, 0, 1); 717 722 718 my $output_base = "$outdir/${rownum}_${job_num}_${ base}";723 my $output_base = "$outdir/${rownum}_${job_num}_${filter}_${base}"; 719 724 write_params($output_base, $image); 720 725
Note:
See TracChangeset
for help on using the changeset viewer.
