Index: branches/pap/ippScripts/scripts/ipp_cleanup.pl
===================================================================
--- branches/pap/ippScripts/scripts/ipp_cleanup.pl	(revision 27708)
+++ branches/pap/ippScripts/scripts/ipp_cleanup.pl	(revision 28003)
@@ -14,5 +14,4 @@
 use File::Spec;
 use PS::IPP::Config 1.01 qw( :standard );
-use PS::IPP::Metadata::List qw( parse_md_list );
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
@@ -108,10 +107,7 @@
     }
 
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    # extract the metadata for the files into a hash list
+    $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "chip", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    # extract the metadata for the files into a hash list
-    $imfiles = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "chip", $stage_id, $PS_EXIT_PROG_ERROR);
 
     # loop over all of the imfiles, determine the path_base and class_id for each
@@ -196,5 +192,5 @@
             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
-            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -state full";
+            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
             $command .= " -dbname $dbname" if defined $dbname;
             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -249,9 +245,6 @@
         &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code);
     }
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "camera", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $exps = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "camera", $stage_id, $PS_EXIT_PROG_ERROR);
 
     my $n_exps = @$exps;
@@ -316,5 +309,5 @@
         # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
         my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
-        $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -state full";
+        $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
         $command .= " -dbname $dbname" if defined $dbname;
         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -375,9 +368,6 @@
         exit(0);
     }
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    $skyfiles = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "warp", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $skyfiles = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "warp", $stage_id, $PS_EXIT_PROG_ERROR);
 
     my @files = ();
@@ -457,5 +447,5 @@
             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
-            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -state full";
+            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
             $command .= " -dbname $dbname" if defined $dbname;
             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -515,9 +505,6 @@
     }
 
-    my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or
+    $skyfiles = $mdcParser->parse_list(join "", @{ $stdout_buf }) or
         &my_die("Unable to parse metadata config doc", "stack", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $skyfiles = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "stack", $stage_id, $PS_EXIT_PROG_ERROR);
 
     my @files = ();
@@ -594,5 +581,5 @@
             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
-            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -state full";
+            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
             $command .= " -dbname $dbname" if defined $dbname;
             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -652,9 +639,6 @@
     }
 
-    my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or
+    $skyfiles = $mdcParser->parse_list(join "", @{ $stdout_buf }) or
         &my_die("Unable to parse metadata config doc", "diff", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $skyfiles = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "diff", $stage_id, $PS_EXIT_PROG_ERROR);
 
     my @files = ();
@@ -747,5 +731,5 @@
             # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
             my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
-            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -state full";
+            $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned";
             $command .= " -dbname $dbname" if defined $dbname;
             ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
@@ -806,10 +790,7 @@
     }
 
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    # extract the metadata for the files into a hash list
+    $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "fake", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    # extract the metadata for the files into a hash list
-    $imfiles = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "fake", $stage_id, $PS_EXIT_PROG_ERROR);
 
     # loop over all of the imfiles, determine the path_base and class_id for each
@@ -927,10 +908,7 @@
 
 
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        # extract the metadata for the files into a hash list
+        $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-        # extract the metadata for the files into a hash list
-        $imfiles = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
     }
     # loop over all of the imfiles, determine the path_base and class_id for each
@@ -1013,8 +991,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detProcessedExp)", $stage_id, $PS_EXIT_PROG_ERROR);
-        my $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detProcessedExp)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
@@ -1068,10 +1044,7 @@
     # if there are no detResidImfiles (@$stdout_buf == 0), then silently exit.
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        # extract the metadata for the files into a hash list
+        $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-        # extract the metadata for the files into a hash list
-        $imfiles = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
     }
     # loop over all of the imfiles, determine the path_base and class_id for each
@@ -1156,8 +1129,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detResidExp)", $stage_id, $PS_EXIT_PROG_ERROR);
-        my $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detResidExp)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
@@ -1202,9 +1173,6 @@
         &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code);
     }
-    my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or
+    $stacks = $mdcParser->parse_list(join "", @{ $stdout_buf }) or
         &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $stacks = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
 
     my @files = ();
@@ -1286,8 +1254,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
-        my $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
@@ -1327,9 +1293,6 @@
         &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code);
     }
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    my $exps = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
 
     foreach my $exp (@$exps) {
@@ -1380,8 +1343,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
-        $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
@@ -1425,9 +1386,6 @@
         &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code);
     }
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $exps = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
 
     foreach my $exp (@$exps) {
@@ -1511,8 +1469,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
-        $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
@@ -1559,9 +1515,6 @@
         exit 0;
     }
-    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+    $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
         &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
-
-    $exps = parse_md_list($metadata) or
-        &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);
 
     foreach my $exp (@$exps) {
@@ -1643,8 +1596,6 @@
     }
     if (@$stdout_buf != 0) {
-        $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+        $exps = $mdcParser->parse_list(join "", @$stdout_buf) or
             &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
-        $exps = parse_md_list($metadata) or
-            &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);
 
         foreach my $exp (@$exps) {
