Changeset 16977
- Timestamp:
- Mar 13, 2008, 11:43:12 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/web/request.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/web/request.php
r16960 r16977 32 32 $list_checked = ""; 33 33 $pstamp_checked = ""; 34 $get_checked = ""; 34 35 35 36 $command_line = ""; … … 37 38 $command_status = ""; 38 39 40 $outFileset = ""; 39 41 40 42 // Initialize the request variables that we depend upon … … 61 63 62 64 $rvar_cmd_mode = ""; 65 $rvar_last_cmd_mode = ""; 63 66 $rvar_request_id = 0; 64 67 $rvar_last_request_id = 0; … … 95 98 96 99 // is the center is specified in Pixels or sky coordinates 97 if ($rvar_center_type == "Pixels") { 100 if ($rvar_center_type == "Sky") { 101 $sky_checked="checked"; 102 $pix_checked=""; 103 } else { 98 104 $sky_checked=""; 99 105 $pix_checked="checked"; 100 } else {101 $sky_checked="checked";102 $pix_checked="";103 106 } 104 107 105 108 // is the range is specified in Pixels or sky coordinates 106 if ($rvar_range_type == "Pixels") { 107 $rsky_checked=""; 108 $rpix_checked="checked"; 109 } else { 109 if ($rvar_range_type == "Sky") { 110 110 $rsky_checked="checked"; 111 111 $rpix_checked=""; 112 } else { 113 $rpix_checked="checked"; 114 $rsky_checked=""; 112 115 } 113 116 … … 117 120 $last_request_id = $rvar_last_request_id; 118 121 119 120 // default to list mode, unless we are waiting for a request to finish 121 if (($rvar_cmd_mode == "Make Stamps") || ($request_id != 0)) { 122 // during request the page doesn't have cmd_mode set. So we remember the lat real value 123 // and use that 124 if (!$rvar_cmd_mode) { 125 $rvar_cmd_mode = "$rvar_last_cmd_mode"; 126 } 127 128 if ($rvar_cmd_mode == "Make Stamps") { 122 129 $pstamp_checked = "checked"; 123 130 $list_checked = ""; 131 $get_checked = ""; 132 } else if ($rvar_cmd_mode == "Get Images") { 133 $get_checked = "checked"; 134 $list_checked = ""; 135 $pstamp_checked = ""; 124 136 } else { 125 137 $list_checked = "checked"; 138 $get_checked = ""; 126 139 $pstamp_checked = ""; 127 140 } … … 138 151 if ($rvar_img_type) { 139 152 153 $jobFinished = 0; 140 154 if ($request_id == 0) { 141 155 try { 142 $command_line = build_ command_line();156 $command_line = build_request_cmd(); 143 157 $error_line = ""; 144 158 run_command($command_line); … … 155 169 $jobRunning = getRequestStatus(); 156 170 if (!$jobRunning) { 171 $jobFinished = 1; 157 172 $request_id = 0; 158 173 } … … 169 184 170 185 if (!$jobRunning) { 186 $jobFinished = 1; 171 187 $request_id = 0; 172 188 } 173 189 174 190 } catch (Exception $e) { 191 echo "Got Exception $request_id $e\n"; 175 192 $error_line = $e->getMessage(); 176 193 } 177 194 } 178 listJobs($last_request_id); 179 } 180 181 function build_command_line() 195 if ($last_request_id) { 196 // This doesn't work for get_image 197 listJobs($last_request_id, $jobFinished); 198 } 199 } 200 201 function build_request_cmd() 182 202 { 183 203 global $rvar_project, $rvar_user_tag; 184 204 global $sky_checked, $rsky_checked; 185 205 global $list_checked; 206 global $get_checked; 186 207 global $rvar_RA, $rvar_DEC; 187 208 global $rvar_dRA, $rvar_dDEC; … … 194 215 195 216 $cmd = "pstamp_runcommand.sh pstamp_webrequest.pl"; 217 218 $making_stamps = 1; 196 219 197 220 if ($list_checked) { 198 221 $cmd .= " -list"; 222 $making_stamps = 0; 223 } else if ($get_checked) { 224 $making_stamps = 0; 225 $cmd .= " -get_image"; 199 226 } 200 227 … … 203 230 } 204 231 $cmd .= " -project $rvar_project"; 205 if (! $rvar_user_tag ) { 206 throw new Exception('Stamp Name must be specified.'); 207 } 208 $cmd .= " -user_tag $rvar_user_tag"; 209 210 // Set up the ROI parameters 211 if ($sky_checked) { 212 if (! $rvar_RA || ! $rvar_DEC) { 213 throw new Exception('RA and DEC must be specified.'); 214 } 215 $cmd .= " -skycenter $rvar_RA $rvar_DEC"; 216 } else { 217 if (! $rvar_X || ! $rvar_Y) { 218 throw new Exception('X and Y must be specified.'); 219 } 220 $cmd .= " -pixcenter $rvar_X $rvar_Y"; 221 } 222 223 if ($rsky_checked) { 224 if (! $rvar_dRA || ! $rvar_dDEC) { 225 throw new Exception('dRA and dDEC must be specified.'); 226 } 227 $cmd .= " -arcrange $rvar_dRA $rvar_dDEC"; 228 } else { 229 if (! $rvar_W || ! $rvar_H) { 230 throw new Exception('width and height must be specified.'); 231 } 232 $cmd .= " -pixrange $rvar_W $rvar_H"; 233 } 234 235 236 // Note: in the following block we assume that image type has been 237 // which is true since it comes from the menu 232 233 if ($making_stamps) { 234 if (!$rvar_user_tag) { 235 throw new Exception('Stamp Name must be specified.'); 236 } 237 $cmd .= " -user_tag $rvar_user_tag"; 238 } 239 240 if ($making_stamps || $coord_checked) { 241 // Set up the ROI parameters 242 if ($sky_checked) { 243 if (! $rvar_RA || ! $rvar_DEC) { 244 throw new Exception('RA and DEC must be specified.'); 245 } 246 $cmd .= " -skycenter $rvar_RA $rvar_DEC"; 247 } else { 248 if (! $rvar_X || ! $rvar_Y) { 249 throw new Exception('X and Y must be specified.'); 250 } 251 $cmd .= " -pixcenter $rvar_X $rvar_Y"; 252 } 253 254 if ($rsky_checked) { 255 if (! $rvar_dRA || ! $rvar_dDEC) { 256 throw new Exception('dRA and dDEC must be specified.'); 257 } 258 $cmd .= " -arcrange $rvar_dRA $rvar_dDEC"; 259 } else { 260 if (! $rvar_W || ! $rvar_H) { 261 throw new Exception('width and height must be specified.'); 262 } 263 $cmd .= " -pixrange $rvar_W $rvar_H"; 264 } 265 } 266 267 268 if (! $rvar_img_type) { 269 // this actually can't happen 270 throw new Exception('Must set image type.'); 271 } 272 238 273 if ($exp_checked) { 239 274 if (! $rvar_id ) { … … 243 278 } else if ($file_checked) { 244 279 if (! $rvar_id ) { 245 throw new Exception('Must set ID specified.');280 throw new Exception('Must set ID.'); 246 281 } 247 282 $cmd .= " -byid $rvar_img_type $rvar_id"; … … 270 305 global $COMMAND_DIR; 271 306 307 // echo "running $command_line\n"; 272 308 273 309 exec ("$COMMAND_DIR/$command_line", $output_array, $command_status); … … 349 385 } 350 386 351 function listJobs($request_id )387 function listJobs($request_id, $jobFinished) 352 388 { 389 353 390 $command_line = "pstamp_runcommand.sh pstamp_listjobs.pl $request_id"; 354 391 run_command($command_line); 392 if ($jobFinished) { 393 global $outFileset; 394 $parse_error = "/var/www/html/ds/dsroot/$outFileset/parse_error"; 395 #echo "reading $parse_error\n"; 396 // readfile( $parse_error ); 397 $fhandle = fopen($parse_error, "r"); 398 if ($fhandle) { 399 $contents = fread($fhandle, 1024); 400 if ($contents) { 401 global $last_request_id; 402 global $error_line; 403 $error_line = "Request $last_request_id: $contents\n"; 404 } 405 } 406 } 355 407 } 356 408 … … 360 412 global $command_status; 361 413 global $output_array; 414 global $outFileset; 362 415 363 416 $command_line = "pstamp_runcommand.sh pstamptool -listreq -req_id $request_id -simple"; … … 368 421 for ($i = 0; $i < $size; $i++) { 369 422 $elements = explode(" ", $output_array[$i]); 370 if (count($elements) >= 3) {423 if (count($elements) >= 4) { 371 424 $state = $elements[2]; 425 $outFileset = $elements[4]; 372 426 if ($state != "stop") { 373 427 $runningReq++; … … 601 655 <td><b>Mode:</b> 602 656 <input type=radio name="cmd_mode" value="Make Stamps"<?php echo $pstamp_checked; ?> >Make Stamps 657 <input type=radio name="cmd_mode" value="Get Images" <?php echo $get_checked; ?> >Get Images 603 658 <input type=radio name="cmd_mode" value="List Images" <?php echo $list_checked; ?> >List Images 604 659 </td> … … 686 741 <input type="hidden" name="last_request_id" value=<?php echo $last_request_id ?> > 687 742 </td> 743 <td> 744 <input type="hidden" name="last_cmd_mode" value=<?php echo "\"$rvar_cmd_mode\"" ?> > 745 </td> 688 746 </tr> 689 747 </table>
Note:
See TracChangeset
for help on using the changeset viewer.
