Index: trunk/ippToPsps/scripts/convertPhotCodesToXml.pl
===================================================================
--- trunk/ippToPsps/scripts/convertPhotCodesToXml.pl	(revision 28889)
+++ 	(revision )
@@ -1,85 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use IPC::Cmd 0.36 qw( can_run run );
-use XML::Writer;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-
-my $inputPath = undef;
-my $outputPath = "photcodes.xml";
-
-# get user args
-GetOptions(
-        'input|i=s' => \$inputPath,
-        ) or pod2usage( 2 );
-
-pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-
-# tell off user for not providing proper args
-pod2usage(
-        -msg => "\n   Required options:\n\n".
-        "--input <path to dvo.photcodes files>\n".
-        -exitval => 3
-        ) unless
-defined $inputPath;
-
-
-
-my $output = new IO::File(">$outputPath");
-my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);
-$writer->xmlDecl('UTF-8');
-
-$writer->startTag('table', "name" => "PhotoCal");
-
-open (PHOTCODES, $inputPath);
-my $photCode;
-my $zeroPoint;
-my $filter;
-my $description;
-
-while (<PHOTCODES>) {
-
-    chomp;
-
-    if ($_ =~ m/\s+([0-9]+)\s+GPC1.*/) {
-
-        my @columns = split(/\s+/, $_);
-
-        my $filter = $columns[11];
-        my $description = $columns[2];
-        my $photCode = $columns[1];
-        my $zeroPoint = $columns[4];
-        my $extinction = $columns[5];
-
-        $writer->startTag('row',
-                "photoCalID" => $photCode,
-                "filterID" => $filter,
-                "photoCodeDesc" => $description,
-                "AB" => "0.0", # TODO
-                "zeropoint" => $zeroPoint,
-                "extinction" => $extinction,
-                "colorterm" => "0.0", # TODO
-                "colorExtn" => "0.0", # TODO
-                "orphanCalColor" => "0.0", # TODO
-                "orphanCalColorErr" => "0.0", # TODO
-                "startDate" => "54000.");
-
-        $writer->endTag();
-
-
-
-    }
-}
-
-$writer->endTag();
-
-
-close PHOTCODES;
-
-# finish up XML
-#$writer->endTag();
-$writer->end();
-
-
Index: trunk/ippToPsps/scripts/createDb.pl
===================================================================
--- trunk/ippToPsps/scripts/createDb.pl	(revision 28889)
+++ 	(revision )
@@ -1,183 +1,0 @@
-#!/usr/bin/env perl
-
-use warnings;
-use strict;
-
-use DBI;
-use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock';
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-
-my $dbname = 'ippToPsps';
-my $dbserver = 'ippdb01';
-my $dbuser = 'ipp';
-my $dbpass = 'ipp';
-GetOptions( 'dbname|d=s' => \$dbname);
-
-# connect to database
-my $db = DBI->connect("DBI:mysql:database=${dbname};host=${dbserver};" .
-        "mysql_socket=" . DB_SOCKET(),
-        ${dbuser},${dbpass},
-        { RaiseError => 1, AutoCommit => 1}
-        ) or die "Unable to connect to database $DBI::errstr\n";
-
-print "\n*******************************************************************************\n*\n";
-
-print "* Connected to '$dbname' on 'dbserver'\n";
-
-my $currentRevision = -1;
-
-my $latestRevision = 3;
-    print "* Latest revision = $latestRevision\n";
-
-while ($currentRevision != $latestRevision) {
-
-    $currentRevision = getRevision();
-    print "* Current revision = $currentRevision\n";
-
-    if ($currentRevision == 0) {createRevision_1();}
-    elsif ($currentRevision == 1) {createRevision_2();}
-    elsif ($currentRevision == 2) {createRevision_3();}
-
-}
-$db->disconnect();
-print "* Disconnected from '$dbname' on 'dbserver'\n";
-print "*\n*******************************************************************************\n\n";
-
-
-#######################################################################################
-# 
-# Create revision 1 of the database 
-#
-#######################################################################################
-sub createRevision_1 {
-
-    print "* Creating revision 1 of '$dbname'\n";
-
-    my $query = $db->prepare(<<SQL);
-    CREATE TABLE revision (
-            revision INT, 
-            created TIMESTAMP DEFAULT NOW(),
-            primary key (revision)
-            );
-SQL
-        $query->execute;
-
-    $query = $db->prepare(<<SQL);
-
-    CREATE TABLE batches (
-            batch_id BIGINT NOT NULL, 
-            exp_id BIGINT NOT NULL, 
-            survey_id VARCHAR(30) DEFAULT "NONE",
-            processed TINYINT DEFAULT 0,
-            on_datastore TINYINT DEFAULT 0,
-            loaded_to_ODM TINYINT DEFAULT 0,
-            merge_worthy TINYINT DEFAULT 0,
-            deleted TINYINT DEFAULT 0,
-            created TIMESTAMP DEFAULT NOW(),
-            primary key (batch_id, exp_id)
-            );
-
-SQL
-    $query->execute;
-
-setRevision(1);
-
-}
-
-#######################################################################################
-# 
-# Create revision 2 of the database 
-#
-#######################################################################################
-sub createRevision_2 {
-
-    print "* Creating revision 2 of '$dbname'\n";
-
-        my $query = $db->prepare(<<SQL);
-
-        ALTER TABLE batches 
-        ADD COLUMN merged TINYINT DEFAULT 0
-SQL
-    $query->execute;
-
-setRevision(2);
-}
-
-#######################################################################################
-# 
-# Create revision 3 of the database 
-#
-#######################################################################################
-sub createRevision_3 {
-
-    print "* Creating revision 3 of '$dbname'\n";
-
-        my $query = $db->prepare(<<SQL);
-
-        ALTER TABLE batches 
-        ADD COLUMN total_detections BIGINT DEFAULT 0
-SQL
-    $query->execute;
-
-setRevision(3);
-}
-
-
-#######################################################################################
-# 
-# Sets current revision of ippToPsps database
-#
-#######################################################################################
-sub setRevision {
-    my ($revision) = @_;
-
-    my $query = $db->prepare(<<SQL);
-    INSERT INTO revision (revision) VALUES ($revision);
-SQL
-        $query->execute;
-}
-
-#######################################################################################
-# 
-# Gets current revision of ippToPsps database
-#
-#######################################################################################
-sub getRevision {
-
-    if (!doesTableExist("revision")) {return 0;}
-
-    my $query = $db->prepare(<<SQL);
-
-    SELECT revision
-        FROM revision
-        ORDER BY revision DESC LIMIT 1;
-SQL
-   $query->execute;
-   my @row = $query->fetchrow_array();
-
-   return $row[0];
-}
-
-#######################################################################################
-# 
-# Checks whether a certain table exists 
-#
-#######################################################################################
-sub doesTableExist {
-    my ($table) = @_;
-
-    my $query = $db->prepare(<<SQL);
-
-    SELECT COUNT(*) 
-        FROM information_schema.tables 
-        WHERE table_schema = '$dbname'  
-        AND table_name = '$table';
-SQL
-
-        $query->execute;
-
-    my $count = $query->fetchrow_array();
-
-    return $count;
-}
-
Index: trunk/ippToPsps/scripts/getExpIdFromJob.pl
===================================================================
--- trunk/ippToPsps/scripts/getExpIdFromJob.pl	(revision 28889)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-use IPC::Cmd 0.36 qw( can_run run );
-
-my $path = undef;
-my $list = undef;
-my $job = undef;
-
-GetOptions(
-        'path|p=s' => \$path,
-        'list|l=s' => \$list,
-        'job|j=s' => \$job,
-        ) or pod2usage( 2 );
-
-
-pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage(
-        -msg => "\n   Required options:\n\n".
-        "--path <pathToJobsDir>\n".
-        "--list <listOfJobNames> | --job <job>\n\n",
-        -exitval => 3
-        ) unless
-defined $path and
-(defined $list || defined $job);
-
-if (defined $job) {getExpId($job);}
-else {
-
-    open (LIST, "$list") || die "couldn't open the file at '$list'";
-
-    while ($job = <LIST>) {
-
-        getExpId($job);
-
-    }
-
-close(LIST);
-}
-#################################################################
-#
-#
-#################################################################
-sub getExpId {
-    my ($job) = @_;
-
-    chomp($job);
-
-    my @cmdOut = `tar -ztf $path/$job/B000.tar.gz`;
-
-    my $line;
-    foreach $line (@cmdOut) {
-
-        if ($line =~ m/.*B000\/(\d+)\.FITS/) {
-
-            print "$1\n";
-
-        }
-
-    }
-}
-
Index: trunk/ippToPsps/scripts/pspsSchema2xml.pl
===================================================================
--- trunk/ippToPsps/scripts/pspsSchema2xml.pl	(revision 28889)
+++ 	(revision )
@@ -1,337 +1,0 @@
-#!/usr/bin/perl -w
-
-#######################################################################################
-#
-# Script that searches a dir containing PSPS schema files, finds those that comtain the 
-# tables on interest then parses them into an XML format. Also generates C-header files 
-# containing enums that detail table column names and numbers.
-#
-#######################################################################################
-
-use warnings;
-use strict;
-use IPC::Cmd 0.36 qw( can_run run );
-use XML::Writer;
-use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
-use Pod::Usage qw( pod2usage );
-
-my $schemaPath = undef;
-my $type = undef;
-
-# get user args
-GetOptions(
-        'schema|s=s' => \$schemaPath,
-        'type|t=s' => \$type,
-        ) or pod2usage( 2 );
-
-pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-
-# tell off user for not providing proper args
-pod2usage(
-        -msg => "\n   Required options:\n\n".
-        "--schema <path to PSPS schema>\n".
-        "--type <init|det|diff|stack|object>\n".
-        -exitval => 3
-        ) unless
-defined $schemaPath and
-defined $type;
-
-if ($type ne "init" && $type ne "det" && $type ne "diff" && $type ne "stack" && $type ne "object" ) {
-
-    print "Don't understand type '$type'\n"; 
-    die;
-}
-
-my $enumsHeader = "ippToPsps".ucfirst($type)."Enums";
-open(OUT, ">".$enumsHeader.".h") or die("Error");
-
-print OUT "#ifndef ".uc($enumsHeader)."_H\n";
-print OUT "#define ".uc($enumsHeader)."_H\n\n";
-
-
-my $output = new IO::File(">tables.xml");
-my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2);
-$writer->xmlDecl('UTF-8');
-#    $writer->doctype('manifest', "", "psps-manifest.dtd");
-$writer->startTag('tableDescriptions', "type" => "$type");
-
-if ($type eq "init") {createInit();}
-elsif ($type eq "det") {createDetections();}
-elsif ($type eq "diff") {createDiffs();}
-elsif ($type eq "stack") {createStacks();}
-elsif ($type eq "object") {createObjects();}
-
-# finish up XML
-$writer->endTag();
-$writer->end();
-
-print OUT "\n#endif";
-close OUT;
-
-
-#######################################################################################
-#
-# Finds the schema file containing the table name passed in
-#
-#######################################################################################
-sub findSchemaFile {
-    my ($tableName) = @_;
-
-    opendir(DIR, $schemaPath) or print "Cannot open '$schemaPath'\n" and return "";
-    my @files= readdir(DIR);
-    closedir(DIR);
-
-    foreach my $f (@files) {
-
-        if ($f =~ m/.*\.sql$/) {
-            #print "....$f\n";
-
-            open FILE, "<$schemaPath/$f" or next;
-
-            while (<FILE>) {
-                if ($_ =~ m/.*CREATE TABLE\s+dbo\.$tableName\s*\(/i) {
-
-                    close (FILE);
-                    return "$schemaPath/$f";
-                }
-            }
-
-            close (FILE);
-
-        }
-    }
-
-    print "Could not find table '$tableName'\n";
-    return "";
-}
-
-#######################################################################################
-#
-# Creates detection batch tables
-#
-#######################################################################################
-sub createInit {
-
-    parseTable("Filter");
-    parseTable("FitModel");
-    parseTable("PhotozRecipe");
-    parseTable("Survey");
-    parseTable("CameraConfig");
-    parseTable("PhotoCal");
-    parseTable("SkyCell");
-    parseTable("ProjectionCell");
-    parseTable("Region");
-    parseTable("StackType");
-    parseTable("ImageFlags");
-    parseTable("DetectionFlags");
-}
-
-#######################################################################################
-#
-# Creates initialisation batch tables
-#
-#######################################################################################
-sub createDetections {
-
-    parseTable("FrameMeta");
-    parseTable("ImageMeta");
-    parseTable("Detection");
-    parseTable("SkinnyObject");
-    parseTable("ObjectCalColor");
-}
-
-#######################################################################################
-#
-# Creates difference batch tables
-#
-#######################################################################################
-sub createDiffs {
-
-    parseTable("StackMeta");
-    parseTable("StackToImage");
-    parseTable("StackLowSigDelta");
-    parseTable("StackHighSigDelta");
-    parseTable("ObjectCalColor");
-}
-
-#######################################################################################
-#
-# Creates stack batch tables
-#
-#######################################################################################
-sub createStacks {
-
-    parseTable("StackMeta");
-    parseTable("StackDetection");
-    parseTable("SkinnyObject");
-    parseTable("StackOrphan");
-    parseTable("ObjectCalColor");
-}
-
-#######################################################################################
-#
-# Creates object batch tables
-#
-#######################################################################################
-sub createObjects {
-
-    parseTable("Object");
-}
-
-#######################################################################################
-#
-# Parses a particular table from the SQL file and converts it to an XML description 
-#
-#######################################################################################
-sub parseTable {
-    my ($tableName, $newName) = @_;
-
-    my $path =  findSchemaFile($tableName);
-
-    if ($path eq "") {return;}
-
-    # sort out table name, either same as in schema or as defined
-    my $tableNameOut; 
-    if ($newName) { $tableNameOut = $newName;}
-    else {$tableNameOut = $tableName}
-
-    print OUT "\ntypedef enum {\n";
-    $writer->startTag('table', "name" => $tableNameOut);
-
-    open (SCHEMA, $path);
-
-    my $reading = 0;
-    my $found = 0;
-    my $colNum = 0;
-    my $table;
-
-    while (<SCHEMA>) {
-        chomp;
-
-        if ($_ =~ m/.*CREATE TABLE\s+dbo\.([a-zA-Z0-9.]+)\s*\(/i) {
-
-            $table = $1;
-
-            if ($table eq $tableName) {
-
-                $reading = 1;
-                $found = 1;
-                $colNum = 0;
-                next;
-            }
-        }
-
-        if($reading && $_ =~ m/^\s*\)\s*/) {$reading = 0;}
-
-        if(!$reading) {next;}
-
-        my $line = $_;
-        $line =~ s/[\s]*$//;
-
-        if (!$line) {next;}
-        if (length($line) < 5) {next;}
-        if ($line =~ m/^\s*--/) {next;}
-        if ($line =~ m/\/\*/) {next;}
-        if ($line =~ m/\*\//) {next;}
-
-        $colNum = processLine($line, $tableName, $colNum);
-
-    }
-
-    if (!$found) {print "Could not find table '$tableName'\n";}
-    $writer->endTag();
-    print OUT "} ".$tableNameOut.";\n";
-
-    close SCHEMA;
-}
-
-#######################################################################################
-#
-# Processes a line from the PSPS schema table description and converts to XML
-#
-#######################################################################################
-sub processLine {
-    my ($line, $tableName, $colNum) = @_;
-
-    my $name;
-    my $typeStr;
-    my $type;
-    my $comment;
-    my $default;
-
-    # parse line
-    if ($line =~ m/\s*([a-zA-Z0-9()-\[\]]+)\s+(.*)\s*--\/(.*)/) {
-
-        $name = $1;
-        $typeStr = $2;
-        $comment = $3;
-
-        # neaten up the comment
-        $comment =~ s/<[\/]{0,1}column>//g;
-        $comment =~ s/^[\s]*//;
-        $comment =~ s/[\s]*$//;
-        if ($comment =~ m/<column unit="(.*)">(.*)/ ) {$comment = "$2 (unit = $1)"}
-    }
-    # no comment case
-    elsif ($line =~ m/\s*([a-zA-Z0-9()-\[\]]+)\s+(.*)/) {
-
-        $name = $1;
-        $typeStr = $2;
-        $comment = "No comment";
-    }
-    else {
-
-        print "In '$tableName', can't process: '$line'\n";
-        return $colNum
-    }
-
-    my $ISBINARY = 0;
-
-    # remove [] from name
-    $name =~ s/[\[\]]//g;
-
-    # sort out type
-    if ($typeStr =~ m/([a-zA-Z0-9()-]*)[ \t]+.*/) {
-
-        $type = $1; 
-        $type =~ s/BIGINT/TLONGLONG/;
-        $type =~ s/SMALLINT/TSHORT/;
-        $type =~ s/TINYINT/TBYTE/;
-        $type =~ s/INT/TLONG/;
-        $type =~ s/FLOAT/TDOUBLE/;
-        $type =~ s/REAL/TFLOAT/;
-        $type =~ s/DATE/TSTRING/;
-        if ($type =~ m/^VARCHAR.*/) {$type = "TSTRING";}
-        if ($type =~ m/^VARBINARY.*/) {$type = "TSTRING"; $ISBINARY = 1;}
-    }
-
-    # get default value
-    if ($typeStr =~ m/.*DEFAULT[ \t]*(.*)/i) {
-
-        $default = $1;
-        $default =~ s/,//;
-            $default =~ s/[\(\)]//g;
-        $default =~ s/[\s]*$//;
-        $default =~ s/'//g;
-        if ($type ne "TSTRING" && !$default) {$default = "0";}
-        if ($ISBINARY && $default eq "0x") {$default = "";}
-    }
-    elsif ($type eq "TSTRING") {$default = " ";}
-    else {$default = 0;}
-
-    if ($type eq "TSTRING" && $default eq "") {$default = " ";}
-
-    $colNum++;
-
-    print OUT "  ".uc($tableName)."_".uc($name)." = ".$colNum.",\n";
-
-    $writer->startTag('column',
-            "name" => $name,
-            "type" => $type,
-            "default" => $default,
-            "comment" => $comment);
-
-    $writer->endTag();
-
-    return $colNum;
-}
