Index: /tags/ipp-pv3-20140717/ippScripts/scripts/sc_retry_return.pl
===================================================================
--- /tags/ipp-pv3-20140717/ippScripts/scripts/sc_retry_return.pl	(revision 37265)
+++ /tags/ipp-pv3-20140717/ippScripts/scripts/sc_retry_return.pl	(revision 37266)
@@ -33,10 +33,9 @@
 
 # Options
-my ($remote_id,$path_base,$job_id,$dbname,$verbose,$no_update,$camera);
+my ($remote_id,$path_base,$dbname,$verbose,$no_update,$camera);
 $force = 0;
 $verbose = 0;
 GetOptions(
     'remote_id=s'   => \$remote_id,
-    'job_id=s'      => \$job_id,
     'path_base=s'   => \$path_base,
     'camera=s'      => \$camera,
@@ -47,8 +46,7 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --remote_id --path_base --job_id", -exitval => 3) unless
+pod2usage( -msg => "Required options: --remote_id --path_base", -exitval => 3) unless
     defined($path_base) and
-    defined($remote_id) and
-    defined($job_id);
+    defined($remote_id);
 
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id);
@@ -79,29 +77,22 @@
 my $runData = ${ $rrData2 }[0]; # There should be only one
 
-# Poll the job status?
+# my job ID : 
+my $job_id = $runData->{job_id};
+print "remote job ID: $job_id\n";
+
+# Poll the job status? (check status at LANL)
 my $poll_response = 0;
 my $poll_word  = "nothing";
-
-if ($force) {
-    $poll_response = 1;
-    $poll_word     = "Completed";
-}
-
 ($poll_response, $poll_word) = poll_job($job_id);
 
 if ($poll_response == -1) { # This job has an error
-    warn("The job exited incorrectly: $remote_id $job_id $poll_word.");
+    print "The job exited incorrectly: $remote_id $job_id $poll_word $poll_response.\n";
+    # warn("The job exited incorrectly: $remote_id $job_id $poll_word.");
     exit (2);
 }
 
 if ($poll_response != 1) { # This job has NOT completed
-
-}
-if ($verbose) {
-    print "Stopped Polling code.  $poll_count of $poll_max $poll_response\n";
-}
-if ($poll_response != 1) {
-    warn("Job hasn't completed: $remote_id $job_id $poll_response $poll_word");
-    exit (1);
+    print "The job has not exited at LANL: $remote_id $job_id $poll_word $poll_response.\n";
+    exit (2);
 }
 
@@ -126,5 +117,5 @@
 
 # Feed the return list into the transfer tool
-# If this fails, we should go to an auth wait point.
+# If this fails, we should exit : do not update gpc1 database until all files are back
 {
     my $offset = 0;  # Offset to start from.
@@ -143,4 +134,5 @@
     if (!$transfer_success) &my_die ("failed to get all return files");
 }
+print STDERR "rsync of all files is complete, updating gpc1 database\n";
 
 foreach my $file (@dbinfo_files) {
@@ -169,4 +161,7 @@
 	    next;
 	}
+    } else {
+	print STDERR "do not know how to handle stage $runData->{stage}\n";
+	exit (3);
     }
 
@@ -191,5 +186,6 @@
         warn("The command that shouldn't fail has failed: $file $cmd $remote_id $error_code");
         if ($poll_word ne 'Completed') {  # If the job claims it completed, then we're fighting the network.
-            drop_component($remote_id,$cmd,$file);
+            # drop_component($remote_id,$cmd,$file);
+	    print STDERR "we should drop this component: $cmd\n";
         }
     }
