Index: trunk/ippToPsps/perl/exposureSummary.pl
===================================================================
--- trunk/ippToPsps/perl/exposureSummary.pl	(revision 32144)
+++ 	(revision )
@@ -1,236 +1,0 @@
-#!/usr/bin/env perl
-
-# script to provide a summary of loading status given an upper and lower exposure ID limit
-
-use warnings;
-use strict;
-
-use LWP::UserAgent;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use File::Temp qw(tempfile);
-use ippToPsps::IppToPspsDb;
-use ippToPsps::Gpc1Db;
-use ippToPsps::DetectionBatch;
-
-my $dvoDb = undef;
-my $beginExp = undef;
-my $endExp = undef;
-my $verbose = undef;
-my $checkNeb = undef;
-my $save_temps = undef;
-
-GetOptions(
-        'startexp|b=s' => \$beginExp,
-        'endexpi|e=s' => \$endExp,
-        'dvodb|d=s' => \$dvoDb,
-        'checkNeb|n' => \$checkNeb,
-        'verbose|v' => \$verbose,
-        'save_temps|s' => \$save_temps
-        );
-
-
-my $quit = 0;
-print "\n*******************************************************************************\n";
-print "* \n";
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if (!defined $beginExp) {
-    $quit = 1;
-    print "* REQUIRED: a begin exp_id                              -b <name>\n";
-}
-if (!defined $endExp) {
-    $quit = 1;
-    print "* REQUIRED: an end exp_id                               -e <name>\n";
-}
-if (!defined $dvoDb) {
-    $quit = 1;
-    print "* REQUIRED: a dvo Db name                               -d <name>\n";
-}
-if (!defined $checkNeb) {
-    $checkNeb = 0;
-    print "* OPTIONAL: check nebulous for unprocessed exposures    -n      (default = $checkNeb)\n";
-}
-if (!defined $verbose) {
-    $verbose = 0;
-    print "* OPTIONAL: run in verbose mode                         -v      (default = $verbose)\n";
-}
-if (!defined $save_temps) {
-    $save_temps = 0;
-    print "* OPTIONAL: keep temp files                             -t      (default = $save_temps)\n";
-}
-print "*\n*******************************************************************************\n";
-
-if ($quit) { exit; }
-
-my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps);
-my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
-
-my $exposures;
-#if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures, 0)) {exit;}
-
-my $totalExposures = $ippToPspsDb->countExposures($beginExp, $endExp, "PSPS_test", "P2", $dvoDb);
-my $totalMerged = $ippToPspsDb->countMergedExposures($beginExp, $endExp, "PSPS_test", "P2", $dvoDb);
-
-if(!$ippToPspsDb->getUnmergedExposures(\$exposures, $beginExp, $endExp, "PSPS_test", "P2", $dvoDb)) {
-
-    print "No unmerged exposures\n";
-    exit;
-}
-
-my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
-my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec;
-
-my $exposure;
-my $totalUnmerged = 0;
-my $totalMergeWorthy = 0;
-my $totalNotMergeWorthy = 0;
-my $totalProcessed = 0;
-my $totalOnDatastore = 0;
-my $totalLoadedToOdm = 0;
-my $totalLoadFailed = 0;
-my $totalMergeWorthy = 0;
-my $totalUnderObjIdLimit = 0;
-my $totalUnprocessed = 0;
-my $totalUnprocessedAvailableSmfs = 0;
-my $remainingOdmFailures = 0;
-my $totalUnprocessedMissingSmfs = 0;
-my $totalProcessedNotOnDatastore = 0;
-
-
-open (UNPRO, ">unprocessedExposures.txt") or print "* Problem opening data file for unprocessed exposures\n";
-open (ODMFAIL, ">odmFailures.txt") or print "* Problem opening data file for ODM failures\n";
-open (NOTONDATASTORE, ">notOnDatastore.txt") or print "* Problem opening data file for exposures not on datastore\n";
-
-if ($checkNeb) {
-
-    open (MISSSMF, ">missingSmfs.txt") or print "* Problem opening data file for missing smfs\n";
-    open (NOTMISSSMF, ">notMissingSmfs.txt") or print "* Problem opening data file for missing smfs\n";
-}
-
-foreach $exposure ( @{$exposures} ) {
-    my ($batchId, $expId) = @{$exposure};
-
-    if ($ippToPspsDb->isExposureMerged($expId)) {next;}
-
-    $totalUnmerged++;
-    if ($verbose) {print "$totalUnmerged | $expId \n"; }
-
-    # processed stuff
-    if ($ippToPspsDb->isExposureProcessed($expId)) {
-
-        $totalProcessed++;
-
-        if (!$ippToPspsDb->isExposureAlreadyPublished($expId)) {
-
-            $totalProcessedNotOnDatastore++;
-            print NOTONDATASTORE "$expId\n";
-        }
-        else {
-
-            $totalOnDatastore++;
-
-            if ($ippToPspsDb->isExposureLoadedToOdm($expId)) {
-
-                $totalLoadedToOdm++;
-
-                if ($ippToPspsDb->isMergeWorthy($expId)) {
-
-                    $totalMergeWorthy++;
-                }
-                # not mergeworthy
-                else {
-
-                    $totalNotMergeWorthy++;
-
-                    #if ($ippToPspsDb->didLoadFail($expId)) {
-
-                    #    $totalLoadFailed++;
-                    #}
-                    if ($ippToPspsDb->isMinObjIdUnderLimit($expId)) {
-
-                        $totalUnderObjIdLimit++;
-                    }
-                    else {
-
-                        $remainingOdmFailures++;
-                        print ODMFAIL "$expId\n";
-                    }
-                }
-            }
-        }
-    }
-    # unprocessed stuff
-    else {
-
-
-        $totalUnprocessed++;
-        print UNPRO "$expId\n";
-
-        # if flag is set, then attempt to get smf file from nebulous for this unprocessed exposure
-        if ($checkNeb) {
-
-            my $detectionBatch = ippToPsps::DetectionBatch->existing(
-                    "GPC1",
-                    $gpc1Db,
-                    $batchId,
-                    $ippToPspsDb,
-                    ".",
-                    $verbose,
-                    $save_temps);
-
-
-            my $path = $detectionBatch->getSmfFile();
-            if (!$path) {
-                print "no smf file for $expId\n";
-
-                $totalUnprocessedMissingSmfs++;
-                print MISSSMF "$expId\n";
-            }
-            else {
-
-                $totalUnprocessedAvailableSmfs++;
-                print NOTMISSSMF "$expId\n";
-
-            }
-        }
-
-    }
-}
-
-close(UNPRO);
-close(ODMFAIL);
-close(NOTONDATASTORE);
-if ($checkNeb) {
-
-    close(MISSSMF);
-    close(NOTMISSSMF);
-}
-my $totalOnDatastoreNotLoaded = $totalOnDatastore - $totalLoadedToOdm;
-print "***********************************************************\n";
-print "*    Summary of IPP->PSPS loading as of $timeStamp\n"; 
-print "*    DVO Db = '$dvoDb'\n";
-print "*    Exposures between $beginExp and $endExp\n";
-print "*\n";
-print "* Total Exposures                            = $totalExposures\n";
-print "*   Merged into PSPS                         = $totalMerged\n";
-print "*   Un-merged                                = $totalUnmerged\n";
-print "*     Unprocessed by ippToPsps               = $totalUnprocessed\n";
-if ($checkNeb) {
-    print "*       Missing SMF files                    = $totalUnprocessedMissingSmfs\n";
-    print "*       Available SMF files                  = $totalUnprocessedAvailableSmfs\n";
-}
-print "*     Processed by ippToPsps                 = $totalProcessed\n";
-print "*       Not on datastore                     = $totalProcessedNotOnDatastore\n";
-print "*       On datastore                         = $totalOnDatastore\n";
-print "*         Not loaded to ODM                  = $totalOnDatastoreNotLoaded\n";
-print "*         Loaded to ODM                      = $totalLoadedToOdm\n";
-print "*           MergeWorthy                      = $totalMergeWorthy\n";
-print "*           Not MergeWorthy                  = $totalNotMergeWorthy\n";
-print "*             Under -30 dec limit            = $totalUnderObjIdLimit\n";
-print "*             Remaining failures             = $remainingOdmFailures\n";
-print "*\n";
-print "***********************************************************\n";
-
-
Index: trunk/ippToPsps/perl/ippToPsps_run.pl
===================================================================
--- trunk/ippToPsps/perl/ippToPsps_run.pl	(revision 32144)
+++ 	(revision )
@@ -1,554 +1,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-
-use PS::IPP::Config 1.01 qw( :standard );
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use IPC::Cmd 0.36 qw( can_run run );
-use File::Temp qw(tempfile);
-use XML::LibXML;
-use File::Basename;
-
-# local classes
-use ippToPsps::Gpc1Db;
-use ippToPsps::IppToPspsDb;
-use ippToPsps::Datastore;
-#use ippToPsps::BatchManager;
-
-# globals
-my $camera = undef;
-my $batchType = undef;
-my $dvoLocation = undef;
-my $dvoDb = undef;
-my $fullDvoPath = undef;
-my $verbose = undef;
-my $save_temps = undef; 
-my $output = undef;
-my $singleExpId = undef;
-my $datastoreProduct = undef;
-my $force = undef;
-my $initBatch = undef;
-my $dontTarNZip = undef;
-
-# get user args
-GetOptions(
-        'camera|c' => \$camera,
-        'output|o=s' => \$output,
-        'batch|b=s' => \$batchType,
-        'dvo|d=s' => \$fullDvoPath,
-        'expid|e=s' => \$singleExpId,
-        'product|p=s' => \$datastoreProduct,
-        'verbose|v' => \$verbose,
-        'save_temps|t' => \$save_temps,
-        'force|f' => \$force,
-        'tarnzip|z' => \$dontTarNZip,
-        );
-
-my $quit = 0;
-print "\n*******************************************************************************\n";
-print "* \n";
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if (!defined $output) {
-    $quit=1;
-    print "* REQUIRED: need to provide an output path  -o <path>\n";
-}
-if (!defined $batchType) {
-    $quit=1;
-    print "* REQUIRED: need to define a batch type     -b <init|det|diff|stack>\n";
-}
-if (!defined $fullDvoPath) {
-    $quit=1;
-    print "* REQUIRED: need to provide a DVO Db        -d <pathToDVO>\n";
-}
-if (!defined $camera) {
-    $camera = "GPC1";
-    print "* OPTIONAL: select a camera                 -c                   (default = $camera)\n";
-}
-if (!defined $singleExpId) {
-
-    print "* OPTIONAL: a single exposure ID            -e <expID>           (default = none)\n";
-}
-if (!defined $datastoreProduct) {
-
-    print "* OPTIONAL: datastore product               -p <product>         (default = none, i.e. data will not be published)\n";
-}
-if (!defined $verbose) {
-    $verbose = 0;
-    print "* OPTIONAL: run in verbose mode             -v                   (default = $verbose)\n";
-}
-if (!defined $save_temps) {
-    $save_temps = 0;
-    print "* OPTIONAL: keep temp files                 -t                   (default = $save_temps)\n";
-}
-if (!defined $force) {
-    $force = 0;
-    print "* OPTIONAL: force if already processed      -f                   (default = $force)\n";
-}
-if (!defined $dontTarNZip) {
-    $dontTarNZip = 0;
-    print "* OPTIONAL: don't tar and zip output        -z                   (default = $dontTarNZip)\n";
-}
-print "*\n*******************************************************************************\n";
-
-if ($quit) { exit; }
-
-# determine PSPS batch 'type'
-my $pspsBatchType;
-if ($batchType eq 'init') {$pspsBatchType = "IN";}
-elsif ($batchType eq 'det') {$pspsBatchType = "P2";}
-elsif ($batchType eq 'stack') {$pspsBatchType = "ST";}
-elsif ($batchType eq 'diff') {$pspsBatchType = "OB";}
-else {$pspsBatchType = "UNKNOWN";}
-
-# spilt full DVO path into Db and path
-$fullDvoPath =~ s/\/$//; # strip off trailing '\'
-($dvoDb, $dvoLocation) = fileparse($fullDvoPath);
-
-my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps);
-my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
-my $datastore = undef;
-if ($datastoreProduct) {$datastore = new ippToPsps::Datastore($datastoreProduct, $verbose, $save_temps);}
-#my $batchManager = new ippToPsps::BatchManager($ippToPspsDb, $output, $verbose, $save_temps);
-
-# check we can run programs and get camera config
-my $ippToPsps = can_run('ippToPsps') or (warn "Can't find 'ippToPsps' program" and exit($PS_EXIT_CONFIG_ERROR));
-my $ipprc = PS::IPP::Config->new($camera) or (warn "Can't get camera configuration" and exit($PS_EXIT_CONFIG_ERROR)); 
-
-if ($batchType eq "init") {$initBatch = 1;}
-else {$initBatch = 0;}
-
-if (!process()) {print "* Finished unsuccessfully\n";}
-else {print "* Finished successfully\n";}
-
-#######################################################################################
-# 
-# Generates a PSPS-suitable survey 'type' from the IPP distribution group
-#
-#######################################################################################
-sub getSurveyTypeFromDistGroup {
-    my ($distGroup) = @_;
-
-    if ($distGroup =~ m/^MD([0-1][0-9])$/i) {return "MD$1";}
-    if ($distGroup =~ m/^M31$/i) {return "M31";}
-    if ($distGroup =~ m/^sts$/i) {return "STS1";}
-    if ($distGroup =~ m/^SweetSpot$/i) {return "SSS";}
-    if ($distGroup =~ m/^(3PI)|(ThreePi)|(SAS)$/i) {return "3PI";}
-
-    print "* Unknown distribution group: '$distGroup'\n";
-    return undef;
-}
-
-#######################################################################################
-# 
-# Finds all exposures for the provided TODO and generates PSPS FITS data for them
-#
-#######################################################################################
-sub process {
-
-    my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
-    my $lastExpId = $ippToPspsDb->getLastExpId();
-    my $exposures;
-
-    my $query;
-    if ($initBatch) {
-
-        my @exposure = (0, 'NULL', 'ThreePi');
-        @{$exposures} = (\@exposure);
-    }
-    # get single exposure
-    elsif ($singleExpId) {
-       
-        if (!$gpc1Db->getSingleExposureFromDvoDb($dvoDb, $singleExpId, \$exposures)) {return 0;}
-    }
-    # get all exposures in this DVO Db
-    else {
-        
-        if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures)) {return 0;}
-    }
-
-    my $batchId = 0;
-    my $batchesPerJob = 1;
-    my $published = 0;
-
-    #my $batchId = -1;
-    my $exposure;
-    foreach $exposure ( @{$exposures} ) {
-        my ($expId, $expName, $distGroup) = @{$exposure};
-
-        if (!$initBatch && $ippToPspsDb->isExposureAlreadyProcessed($expId)) {
-
-            if ($force) {print "* Already processed '$expId', but forcing....\n";} 
-            else {
-            
-                print "* Exposure ID '$expId' has already been processed\n";
-                next
-            };
-        }
-
-        my $surveyType = getSurveyTypeFromDistGroup($distGroup);
-        if (!$surveyType) {next;}
-
-        $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastore) ? $datastoreProduct : "NONE");
-
-        # TODO quit here if no sensible batch ID
-
-        # generate batch path from batch IDs
-        my $batch = sprintf("B%08d", $batchId);
-        my $dvoDir = "$output/$dvoDb";
-        my $batchDir = "$dvoDir/$batch";
-
-        # make directories
-        unless(-d $dvoDir) {mkdir($dvoDir, 0777);}
-        mkdir($batchDir, 0777);
-
-        $published = 0;
-
-        print "* Preparing exposure $expId as batch '$batch'...\n";
-
-        # run IppToPsps program
-        if (runIppToPsps($expId, $expName, $surveyType, $batchDir, $batchType, $resultsFilePath)) {
-
-            my ($filename, $minObjId, $maxObjId, $totalDetections);
-            parseResults($resultsFilePath, \$filename, \$minObjId, \$maxObjId, \$totalDetections);
-
-            # write batch manifest and tar and zip up
-            if (writeBatchManifest($batchDir, $batch, $batchType, $surveyType, $filename, $minObjId, $maxObjId)) {
-
-                # tar n' zip
-                if (!$dontTarNZip) {
-                    my $tarball = tarAndZipBatch($dvoDir, $batch);
-
-                    # and publish
-                    if ($tarball && defined $datastore ) {
-                        
-                        $published = $datastore->register($batch, $dvoDir, $tarball, "IPP_PSPS", "tgz");
-                    }
-                }
-            }
-
-            $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId);
-        }
-
-        if ($initBatch) {print "* Wrote initialisation batch\n";}
-
-        print "*\n*******************************************************************************\n\n";
-    }
-
-    close $resultsFile;
-
-    return 1;
-}
-
-#######################################################################################
-#
-# run IppToPsps 
-#
-#######################################################################################
-sub runIppToPsps {
-    my ($expId, $expName, $surveyType, $batchDir, $batchType, $resultsFilePath) = @_;
-
-    my $success = 0;
-
-    if ($batchType =~ /init/) {
-        $success = produceInit($batchDir, $resultsFilePath);
-    }
-    elsif ($batchType =~ /det/) {
-        $success = produceDetections($expId, $expName, $surveyType, $batchDir, $resultsFilePath);
-    }
-    elsif ($batchType =~ /diff/) {
-        $success = produceDiffs($expId, $expName, $surveyType, $batchDir, $resultsFilePath);
-    }
-    elsif ($batchType =~ /test/) {
-        $success = produceDetections($expId, $expName, $surveyType, $batchDir, $resultsFilePath);
-    }
-
-    return $success;
-}
-
-#######################################################################################
-#
-# tar 'n zip a batch TODO handle errors
-#
-#######################################################################################
-sub tarAndZipBatch {
-    my ($path,$batch) = @_;
-
-    my $batchDir = "$path/$batch";
-    my $tar = "$batch.tar";
-    my $tarball = "$tar.gz";
-    my $batchTar = "$path/$tar";
-    my $batchZip = "$path/$tarball";
-
-    # tar
-    my $command = "tar -cvf $batchTar -C $path $batch";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    if (!$success) { print "* Unable to tar up contents of dir: $batchDir\n" and return undef; }
-
-    # zip
-    $command = "gzip -c $batchTar  > $batchZip";
-    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    if (!$success) { print "* Unable to gzip: $batchTar\n" and return undef; }
-
-    # remove tar file
-    $command = "rm $batchTar";
-    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    if (!$success) { print "* Unable to remove: $batchTar\n" };
-
-    # remove batch dir
-    $command = "rm -r $batchDir";
-    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-    if (!$success) { print "* Unable to remove: $batch\n"};
-
-    return $tarball;
-}
-
-#######################################################################################
-#
-# zip a file then delete it 
-#
-#######################################################################################
-sub zipFile {
-    my ($path,$origFile) = @_;
-
-    my $file;
-
-    # zip
-    my $zippedName =  "$origFile.gz";
-    my $command = "gzip -c $path/$origFile  > $path/$zippedName";
-    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
-        run(command => $command, verbose => $verbose);
-
-    if (!$success) { 
-
-        $file = $origFile;
-        print "* Unable to gzip: $path/$origFile\n"; 
-    }
-    else {
-
-        $file = $zippedName;
-
-        # now delete original
-        $command = "rm -r $path/$origFile";
-        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-            run(command => $command, verbose => $verbose);
-
-        if (!$success) { print "* Unable to remove: $path/$origFile\n"};
-    }
-
-    return $file;
-}
-
-
-#######################################################################################
-#
-# parse results XML
-#
-#######################################################################################
-sub parseResults {
-    my ($resultsFilePath, $filename, $minObjId, $maxObjId, $totalDetections) = @_;
-
-    my $parser = XML::LibXML->new;
-    my $doc = $parser->parse_file($resultsFilePath);
-    ${$filename} = $doc->findvalue('//filename');
-    ${$minObjId} = $doc->findvalue('//minObjID');
-    ${$maxObjId} = $doc->findvalue('//maxObjID');
-    ${$totalDetections} = $doc->findvalue('//totalDetections');
-}
-
-
-#######################################################################################
-#
-# writes a batch manifest file for the one FITS file that should be in the path passed in
-#
-#######################################################################################
-sub writeBatchManifest {
-    my ($path,$batch,$batchType,$surveyType,$filename,$minObjId,$maxObjId) = @_;
-
-    use XML::Writer;
-    use Digest::MD5::File qw( file_md5_hex );
-
-    # sort out paths
-    my $outputPath = "$path/BatchManifest.xml";
-    my $output = new IO::File(">$outputPath");
-
-    # create a timestamp
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
-    my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec;
-
-    # create XML file
-    my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);
-    $writer->xmlDecl('UTF-8');
-    $writer->doctype('manifest', "", "psps-manifest.dtd");
-
-    # open directory to hunt for FITS files
-    opendir(DIR, $path) or print "* Cannot open '$path' to write batch manifest\n" and return 0;
-    my @thefiles= readdir(DIR);
-    closedir(DIR);
-
-    my $foundFits = 0;
-    foreach my $f (@thefiles) {
-
-        if ($f =~ /\.FITS/) {
-
-            if ($foundFits) { print "* More than one FITS file found for this batch\n"; return 0;}
-
-            # my $file = zipFile($path, $f); 
-
-            # get md5sum of file
-            my $md5sum  = file_md5_hex("$path/$f");
-
-            # get size of file in bytes
-            my $filesize = -s "$path/$f";
-
-            # write manifest element TODO untidy
-            if($batchType eq 'det' && $filename eq $f) {
-
-                my $pspsSurvey = undef;
-                if ($surveyType =~ m/^MD[0-1][0-9]$/i) {$pspsSurvey = "MDF";}
-                else {$pspsSurvey = $surveyType;}
-
-                $writer->startTag('manifest',
-                        "name" => "$batch",
-                        "type" => $pspsBatchType,
-                        "survey" => $pspsSurvey,
-                        "timestamp" => "$timeStamp",
-                        "minObjId" => $minObjId,
-                        "maxObjId" => $maxObjId);
-            }
-            else {
-
-                $writer->startTag('manifest',
-                        "name" => "$batch",
-                        "type" => $pspsBatchType,
-                        "timestamp" => "$timeStamp");
-            }
-            # write the tag for this batch
-            $writer->startTag("file", 
-                    "name" => $f,
-                    "bytes" => $filesize,
-                    "md5" => $md5sum);
-
-            $writer->endTag();
-            $writer->endTag();
-            $writer->end();
-            $foundFits = 1;
-        }
-
-    }
-
-    if (!$foundFits) { print "* Could not find any FITS files for this batch\n"; return 0;}
-    return 1;
-}
-
-#######################################################################################
-# 
-# runs ippToPsps to produce init batch 
-#
-#######################################################################################
-sub produceInit {
-    my ($outputPath, $resultsFilePath) = @_;
-
-    my $success = runProgram("NULL", $outputPath, 0, "NULL", "NULL", $batchType, $resultsFilePath);
-    return $success;
-}
-
-#######################################################################################
-# 
-# runs ippToPsps for detections for this exposure 
-#
-#######################################################################################
-sub produceDetections {
-    my ($expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_;
-
-    my $nebPath = $gpc1Db->getCameraStageSmfForThisDvoDb($dvoDb, $expId);
-    if (!$nebPath) { return 0; }
-
-    my $success = 0;
-
-    # get real filename from neb 'key'
-    my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT",$nebPath) or return 0;
-    my $realFile = $ipprc->file_resolve($fpaObjects) or return 0;
-
-    # now write the path to this file out to temp file
-    my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps);
-    print $tempFile $realFile . "\n";
-    close $tempFile;
-
-    $success = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType, $resultsFilePath);
-    return $success;
-}
-
-#######################################################################################
-# 
-# runs ippToPsps for diffs for this exposure 
-#
-#######################################################################################
-sub produceDiffs {
-    my ($expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_;
-
-    my $rows = $gpc1Db->getDiffStageCmfs($expId);
-
-    my $size = @{$rows};
-    if ($size < 1) {print "* No cmf files found for this exposure\n"; return 0;}
-
-    my ($tempFile, $tempName) = tempfile( "inputFileList.XXXX", UNLINK => !$save_temps);
-
-    # loop round db results should be one file per skycell
-    my $success = 0;
-
-    my $row;
-    foreach $row ( @{$rows} ) {
-        my ($nebPath) = @{$row};
-
-        print "NEB PATH $nebPath\n";
-
-        # get real filename from neb 'key'
-        my $fpaObjects = $ipprc->filename("PPSUB.OUTPUT.SOURCES",$nebPath) or return 0;
-        my $realFile = $ipprc->file_resolve($fpaObjects) or return 0;
-        #print "REALFILE $realFile\n";
-
-        # now write the path to this file out to temp file
-        print $tempFile $realFile . "\n";
-    }
-
-    my $ret = runProgram($tempName, $outputPath, $expId, $expName, $surveyType, $batchType, $resultsFilePath);
-
-    close $tempFile;
-
-    return $ret;
-}
-
-#######################################################################################
-#
-# runs the ippToPsps program
-#
-#######################################################################################
-sub runProgram {
-    my ($input, $output, $expid, $expName, $surveyType, $batchType, $resultsFilePath) = @_;
-
-    # build command
-    my $command = "$ippToPsps"; 
-    $command .= " -input $input";
-    $command .= " -output $output";
-    $command .= " -D CATDIR $fullDvoPath";
-    $command .= " -config ../config"; # TODO
-        $command .= " -expid $expid";
-    $command .= " -expname $expName";
-    $command .= " -survey $surveyType";
-    $command .= " -batch $batchType";
-    $command .= " -results $resultsFilePath";
-
-    # run command
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf )
-        = run(command => $command, verbose => $verbose);
-
-    return $success;
-}
Index: trunk/ippToPsps/perl/removeFromDatastore.pl
===================================================================
--- trunk/ippToPsps/perl/removeFromDatastore.pl	(revision 32144)
+++ 	(revision )
@@ -1,56 +1,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-
-use ippToPsps::Datastore;
-
-my $start = undef;
-my $end = undef;
-my $product = undef;
-
-GetOptions( 
-        'start|s=s' => \$start,
-        'end|e=s' => \$end,
-        'product|p=s' => \$product,
-        );
-
-my $quit = 0;
-print "\n*******************************************************************************\n";
-print "* \n";
-if (@ARGV) {
-    $quit=1;
-    print "* UNKNKOWN: option                          @ARGV\n";
-}
-if (!defined $product) {
-    $quit=1;
-    print "* REQUIRED: a datastore product name          -p <name>\n";
-}
-if (!defined $start) {
-    $quit=1;
-    print "* REQUIRED: starting batch number             -s <number>\n";
-}
-if (!defined $end) {
-    $end=99999999999;
-    print "* OPTIONAL: ending batch number               -e <number>    (default=$end)\n";
-}
-print "*\n*******************************************************************************\n";
-
-if ($quit) { exit; }
-
-my $datastore = new ippToPsps::Datastore($product, 0, 0);
-
-my $i;
-
-for ($i=$start; $i<$end+1; $i++) {
-
-    my $name = sprintf("B%08d", $i);
-    if ($datastore->remove($name)) {
-        print "* Successfully removed $name from datastore\n";
-    }
-    else {
-        print "* Unable to remove $name from datastore\n";
-    }
-}
