[Bio] / PPO / ppo_generate.pl Repository:
ViewVC logotype

View of /PPO/ppo_generate.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Tue Mar 23 13:57:51 2010 UTC (9 years, 7 months ago) by paczian
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, mobedac_release_05302012, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.4: +4 -3 lines
added object cache exclusion

#!/usr/bin/env perl

use strict;
use warnings; 

use PPOGenerator;
use Getopt::Long;

use constant KNOWN_BACKENDS => { 'MySQL' => 1, 'SQLite' => 1 };

# usage message 
sub usage {
  my $error = shift;
  print "Usage: ppo_generate.pl -xml xml_file [-backend db_backend -database db_name] [-file sql output filename] [-host hostname] [-user username] [-password passwd] [-port port] [-socket socket] [-perl_target target_dir/]\n";
  print "Error: $error\n" if($error);
  exit;
}

print "PPO Generator:\n";

# get command line parameters
my %options = ();
GetOptions (\%options, 
	    "xml=s",
	    "backend=s", "database=s",
	    "perl_target=s",
	    "file=s",
	    "user=s", "password=s",
	    "host=s", "port=s", "socket=s",
	   ); 


# check for xml file
unless(exists($options{xml}) and -f $options{xml}) {
  &usage("No xml definition file given or file not found.");
}

# read in xml definition
my $generator;
eval { 
  $generator = PPOGenerator->new($options{xml}) 
};
if (ref $generator) {
  print "XML definition successfully read.\n";
  
  # generate perl modules
  if ($options{perl_target}) {
    print "Creating perl modules for PPO... ";
    eval { $generator->generate_perl($options{perl_target}) };
    if ($@) {
      print "failed.\n .. with $@";
    }
    else {
      print "done.\n";
    }
  }
  
  # create database
  if ($options{backend} and $options{database}) {
    print "Creating database for PPO... ";
    if (KNOWN_BACKENDS->{$options{backend}}) {
      eval { $generator->create_database( -backend => $options{backend},
					  -database => $options{database},
					  -host => ($options{host}) ? $options{host} : '',
					  -port => ($options{port}) ? $options{port} : '',
					  -user => ($options{user}) ? $options{user} : '',
					  -password => ($options{password}) ? $options{password} : '',
					  -create => 1,
					  -socket => ($options{socket}) ? $options{socket} : '',
					  -file => ($options{file}) ? $options{file} : undef ) };
      if ($@) {
	print "failed.\n .. with $@";
      }
      else {
	print "done.\n";
      }
    }
    else {
      print "failed.\n .. with Unknown backend type.\n";
    }
  }

}
elsif ($@) { 
  &usage("Invalid xml definition:\n $@"); 
}
else {
  &usage("Unable to read xml defintion (PPOGenerator->new returned undef).");
}

print "Bye.\n";

exit 1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3