Index: trunk/ippScripts/scripts/warp_overlap.pl
===================================================================
--- trunk/ippScripts/scripts/warp_overlap.pl	(revision 13176)
+++ trunk/ippScripts/scripts/warp_overlap.pl	(revision 13275)
@@ -17,15 +17,16 @@
 use PS::IPP::Metadata::Stats;
 use PS::IPP::Metadata::List qw( parse_md_list );
-
-use PS::IPP::Config qw(
-    $PS_EXIT_SUCCESS
-    $PS_EXIT_UNKNOWN_ERROR
-    $PS_EXIT_SYS_ERROR
-    $PS_EXIT_CONFIG_ERROR
-    $PS_EXIT_PROG_ERROR
-    $PS_EXIT_DATA_ERROR
-    $PS_EXIT_TIMEOUT_ERROR
-    metadataLookupStr
-    );
+use File::Temp qw( tempfile );
+
+use PS::IPP::Config qw($PS_EXIT_SUCCESS
+		       $PS_EXIT_UNKNOWN_ERROR
+		       $PS_EXIT_SYS_ERROR
+		       $PS_EXIT_CONFIG_ERROR
+		       $PS_EXIT_PROG_ERROR
+		       $PS_EXIT_DATA_ERROR
+		       $PS_EXIT_TIMEOUT_ERROR
+		       metadataLookupStr
+		       caturi
+		       );
 my $ipprc = PS::IPP::Config->new(); # IPP configuration
 use File::Spec;
@@ -82,25 +83,4 @@
 }
 
-# Make sure everything is from the same exposure, and get the exposure tag
-my $exp_tag;			# Exposure tag
-foreach my $imfile ( @$imfiles ) {
-    unless (defined $exp_tag) {
-	$exp_tag = $imfile->{exp_tag};
-    } elsif ($exp_tag ne $imfile->{exp_tag}) {
-	&my_die("Multiple exposures in the same warp.", $warp_id, $PS_EXIT_SYS_ERROR);
-    }
-}
-
-# Set output directory
-if (defined $workdir) {
-    $workdir = $ipprc->convert_filename_absolute( $workdir );
-} else {
-    my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
-    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
-    $workdir = $dir;
-}
-system "mkdir -p $workdir" unless -d $workdir;
-
-
 # Determine the imfile/skycell overlaps
 my @overlaps = ();
@@ -111,9 +91,15 @@
     my $tessellations = $ipprc->tessellations(); # Hash of defined tessellations
     foreach my $tess_id ( keys %$tessellations ) {
+	### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check
+	my $uri = URI->new( $$tessellations{$tess_id} );
+	if (defined $uri->scheme() and $uri->scheme() eq 'neb') {
+	    &my_die("Tessellation $tess_id refers to a Nebulous path: $$tessellations{$tess_id}", $warp_id, $PS_EXIT_CONFIG_ERROR);
+	}		    
+	
 	my $tess_dir = $ipprc->convert_filename_absolute( $$tessellations{$tess_id} ); # Catdir for DVO
 	print STDERR "tessellation: $tess_id, $tess_dir\n";
 
 	my $imfile = $imfiles->[0];
-	my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} );
+	my $camRoot = $imfile->{cam_path_base};
 	my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output
 	
@@ -123,5 +109,5 @@
 	
 	# run the dvoImageOverlaps program to get the overlaps with this image 
-	my $command = "$dvoImageOverlaps -D CATDIR $tess_dir $psastroFile";
+	my $command = "$dvoImageOverlaps -D CATDIR $tess_dir " . $ipprc->file_resolve($psastroFile);
 	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	    run(command => $command, verbose => 1);
@@ -145,5 +131,5 @@
 	    if ($fileLevel eq "chip") {
 		my $class_id = $imfile->{class_id};
-		my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} );
+		my $chipRoot = $ipprc->file_resolve( $imfile->{chip_path_base} );
 		my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output
 		
@@ -176,13 +162,15 @@
 	# Extract the skycells to images, used as warp templates.
 	foreach my $skycell_id (@unique_skycells) {
-	    my $skyDir = File::Spec->catdir($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
-	    system "mkdir -p $skyDir" unless -d $skyDir;
-	    my $skyFile = File::Spec->catfile( $skyDir , $skycell_id );
-	    my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFile";
-	    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 dvoImageExtract: $error_code", $warp_id, $error_code);
+	    my $skyDir = caturi($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
+	    my $skyFile = $ipprc->file_prepare( $skycell_id, $skyDir );
+	    unless ($ipprc->file_exists( $skyFile )) {
+		my $skyFileResolved = $ipprc->file_create( $skyFile ); # Resolved filename, for Nebulous
+		my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFileResolved";
+		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 dvoImageExtract: $error_code", $warp_id, $error_code);
+		}
 	    }
 	}
@@ -202,6 +190,5 @@
 
 # Generate a MDC file with the overlaps
-my $overlapName = File::Spec->catfile( $workdir, 'overlaps.wrp' . $warp_id . '.mdc' );
-open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName";
+my ($overlapFile, $overlapName) = tempfile( 'overlaps.wrp' . $warp_id . '.mdc.XXXX', UNLINK => 1 );
 print $overlapFile "warpSkyCellMap MULTI\n\n";
 foreach my $overlap (@overlaps) {
@@ -229,6 +216,4 @@
 	exit($error_code);
     }
-
-    unlink $overlapName;
 }
 
