src/hg/utils/automation/HgDb.pm 1.8
1.8 2010/02/02 20:18:47 larrym
support PROFILE option
Index: src/hg/utils/automation/HgDb.pm
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/automation/HgDb.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -B -U 4 -r1.7 -r1.8
--- src/hg/utils/automation/HgDb.pm 12 Oct 2009 06:50:48 -0000 1.7
+++ src/hg/utils/automation/HgDb.pm 2 Feb 2010 20:18:47 -0000 1.8
@@ -22,9 +22,10 @@
sub new
{
# $args{DB} is required
-# $args{USER}, $args{PASSWORD} and $args{HOST} are optional (and override .hg.conf values)
+# $args{PROFILE}: let's you select db profile (optional: defaults to "db").
+# $args{USER}, $args{PASSWORD} and $args{HOST} are optional (and override .hg.conf values).
my ($class, %args) = (@_);
my $ref = {};
if(!defined($args{DB})) {
die "Missing \$args{DB}";
@@ -33,17 +34,18 @@
my $confFile = "$ENV{HOME}/.hg.conf";
if(! -e $confFile) {
die "Cannot locate conf file: '$confFile'";
}
+ my $profile = $args{PROFILE} || "db";
open(CONF, $confFile);
for (<CONF>) {
next if /^#/;
if(/^include/) {
# XXXX TODO: support "include ../cgi-bin/hg.conf"
die "include ... syntax not currently supported";
}
for my $name (qw(host user password)) {
- if(/^db\.$name\s*=\s*(.+)/) {
+ if(/^$profile\.$name\s*=\s*(.+)/) {
$ref->{uc($name)} = $1;
}
}
}