]> git.donarmstrong.com Git - biopieces.git/commitdiff
added .biopiecesrc
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 29 Jul 2009 08:48:03 +0000 (08:48 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 29 Jul 2009 08:48:03 +0000 (08:48 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@612 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/list_mysql_databases
bp_bin/read_mysql
bp_bin/remove_mysql_tables
bp_bin/write_mysql
code_perl/Maasha/Biopieces.pm

index 040e7ab62e0da4b28326bb414a6d4baaca8ccef8..45587d862827ec1b3a07b309936481ede45f9eea 100755 (executable)
@@ -38,8 +38,8 @@ use Maasha::SQL;
 
 my ( $options, $user, $password, @databases, $database );
 
-$user     = $ENV{ "USER" };
-$password = $ENV{ "USER" };
+$user     = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
 
 $options = Maasha::Biopieces::parse_options(
     [
index ff96a81ee6bd4d00926e1991b38fa51a24e207db..2d8f7b1674c3704cb2bb554554fb703a70505a8a 100755 (executable)
@@ -36,17 +36,17 @@ use Maasha::UCSC;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $default_user, $default_password, $options, $in, $out, $record, $dbh, $results );
+my ( $user, $password, $options, $in, $out, $record, $dbh, $results );
 
-$default_user     = Maasha::UCSC::ucsc_get_user();
-$default_password = Maasha::UCSC::ucsc_get_password();
+$user     = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef,             allowed => undef, disallowed => undef },
-        { long => 'query',    short => 'q', type => 'string', mandatory => 'yes', default => undef,             allowed => undef, disallowed => undef },
-        { long => 'user',     short => 'u', type => 'string', mandatory => 'no',  default => $default_user,     allowed => undef, disallowed => undef },
-        { long => 'password', short => 'p', type => 'string', mandatory => 'no',  default => $default_password, allowed => undef, disallowed => undef },
+        { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef,     allowed => undef, disallowed => undef },
+        { long => 'query',    short => 'q', type => 'string', mandatory => 'yes', default => undef,     allowed => undef, disallowed => undef },
+        { long => 'user',     short => 'u', type => 'string', mandatory => 'no',  default => $user,     allowed => undef, disallowed => undef },
+        { long => 'password', short => 'p', type => 'string', mandatory => 'no',  default => $password, allowed => undef, disallowed => undef },
     ]   
 );
 
index 1419cbc5b0889fa33f7d1ee03f3bbf8757365c0e..794ab0f9c36db3248f6da0414c68eefec04c2a41 100755 (executable)
@@ -37,15 +37,18 @@ use Maasha::UCSC;
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, %table_hash, $dbh, $table );
+my ( $options, $user, $password, $in, $out, $record, %table_hash, $dbh, $table );
+
+$user     = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
 
 $options = Maasha::Biopieces::parse_options(
     [
-        { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef, allowed => undef, disallowed => undef },
-        { long => 'tables',   short => 't', type => 'list',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'keys',     short => 'k', type => 'list',   mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'user',     short => 'u', type => 'string', mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
-        { long => 'password', short => 'p', type => 'string', mandatory => 'no',  default => undef, allowed => undef, disallowed => undef },
+        { long => 'database', short => 'd', type => 'string', mandatory => 'yes', default => undef,     allowed => undef, disallowed => undef },
+        { long => 'tables',   short => 't', type => 'list',   mandatory => 'no',  default => undef,     allowed => undef, disallowed => undef },
+        { long => 'keys',     short => 'k', type => 'list',   mandatory => 'no',  default => undef,     allowed => undef, disallowed => undef },
+        { long => 'user',     short => 'u', type => 'string', mandatory => 'no',  default => $user,     allowed => undef, disallowed => undef },
+        { long => 'password', short => 'p', type => 'string', mandatory => 'no',  default => $password, allowed => undef, disallowed => undef },
     ]   
 );
 
index 1a783bf7396022fb41445a5c057327f660d7ddf3..aa2c5a431cc703814f7441c7ad93f9957263ed3b 100755 (executable)
@@ -39,8 +39,8 @@ use Maasha::Calc;
 
 my ( $options, $user, $password, $dbh, $in, $out, $tmp_dir, $tmp_file, $fh_out, $record, $key, $type_hash, $i, @keys, $line );
 
-$user     = $ENV{ "USER" };
-$password = $ENV{ "USER" };
+$user     = Maasha::Biopieces::biopiecesrc( "MYSQL_USER" );
+$password = Maasha::Biopieces::biopiecesrc( "MYSQL_PASSWORD" );
 
 $options = Maasha::Biopieces::parse_options(
     [
index 20e1083db3e52b6ba93349c9f114c7dcc0ee546e..d9af0f1a53875f5b5b6b710fc5b54eba106de43c 100644 (file)
@@ -846,6 +846,36 @@ sub get_tmpdir
 }
 
 
+sub biopiecesrc
+{
+    # Martin A. Hansen, July 2009.
+
+    # Read Biopiece configuration info from .biopiecesrc.
+    # and returns the value of a given key.
+
+    my ( $key,   # configuration key
+       ) = @_;
+
+    # Returns a string.
+
+    my ( $file, $fh, $record );
+
+    $file = "$ENV{ 'HOME' }/.biopiecesrc";
+
+    return undef if not -f $file;
+
+    $fh     = Maasha::Filesys::file_read_open( $file );
+    $record = get_record( $fh );
+    close $fh;
+
+    if ( exists $record->{ $key } ) {
+        return $record->{ $key };
+    } else {
+        return undef;
+    }
+}
+
+
 END
 {
     clean_tmp();