Index: trunk/ippScripts/scripts/camera_exp.pl
===================================================================
--- trunk/ippScripts/scripts/camera_exp.pl	(revision 14140)
+++ trunk/ippScripts/scripts/camera_exp.pl	(revision 14158)
@@ -63,8 +63,8 @@
 
 my $recipe1 = $ipprc->reduction($reduction, 'JPEG_BIN1'); # Recipe to use
-&my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_PROG_ERROR) unless defined $recipe1;
+&my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe1;
 
 my $recipe2 = $ipprc->reduction($reduction, 'JPEG_BIN2'); # Recipe to use
-&my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_PROG_ERROR) unless defined $recipe2;
+&my_die("Unrecognised JPEG recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe2;
 
 # values to extract from output metadata and the stats to calculate
@@ -173,4 +173,30 @@
 
 unless ($no_op) {
+
+    ## build the output JPEG images first so we get them even if the astrometry fails
+
+    # Make the jpeg for binning 1
+    {
+	my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run(command => $command, verbose => 1);
+	unless ($success) {
+	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);
+    }
+
+    # Make the jpeg for binning 2
+    {
+	my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run(command => $command, verbose => 1);
+	unless ($success) {
+	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
+	}
+	&my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2);
+    }
 
     # only run psastro / addstar if any of the output chip astrometry files exist
@@ -196,11 +222,11 @@
 	# XXX this construct requires the user to have a valid .ptolemyrc 
 	# XXX which in turn points at ippconfig/dvo.site
-	{
+	
+	# require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default)
+	# XXX this needs to be converted to addstar_client...
+	if (defined $dvodbReal) {
 	    my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar
 	    my $command = "addstar -D CAMERA $camdir " . $ipprc->file_resolve($fpaObjects);
-	    
-	    if (defined $dvodbReal) {
-		$command .= " -D CATDIR $dvodbReal";
-	    }
+	    $command .= " -D CATDIR $dvodbReal";
 
 	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -213,27 +239,4 @@
     }
     
-    # Make the jpeg for binning 1
-    {
-	my $command = "$ppImage -list $list1Name $outputRoot -recipe PPIMAGE $recipe1"; # Command to run
-	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	    run(command => $command, verbose => 1);
-	unless ($success) {
-	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
-	}
-	&my_die("Unable to find expected output file: $jpeg1", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg1);
-    }
-
-    # Make the jpeg for binning 2
-    {
-	my $command = "$ppImage -list $list2Name $outputRoot -recipe PPIMAGE $recipe2"; # Command to run
-	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	    run(command => $command, verbose => 1);
-	unless ($success) {
-	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform ppImage: $error_code", $cam_id, $error_code);
-	}
-	&my_die("Unable to find expected output file: $jpeg2", $cam_id, $PS_EXIT_PROG_ERROR) unless -f $ipprc->file_resolve($jpeg2);
-    }
 }
 
@@ -269,5 +272,5 @@
 	my $command = "$camtool -addprocessedexp -cam_id $cam_id -code $exit_code";
 	$command .= " -dbname $dbname" if defined $dbname;
-###        system ($command);
+        system ($command);
     }
     exit $exit_code;
