• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • AudioLink
  • Mailing Lists

[AudioLink-cvs]audiolink/code audiolink,1.2,1.3

Status: Alpha
Brought to you by: amitshah
  • Summary
  • Files
  • Reviews
  • Support
  • Mailing Lists
  • Bugs
  • News
  • Git
  • CVS
Menu ▾ ▴
  • audiolink-cvs

[AudioLink-cvs]audiolink/code audiolink,1.2,1.3

[AudioLink-cvs]audiolink/code audiolink,1.2,1.3
From: <ami...@us...> - 2003-12-04 16:20:21
Update of /cvsroot/audiolink/audiolink/code
In directory sc8-pr-cvs1:/tmp/cvs-serv11258

Modified Files:
	audiolink 
Log Message:
1. documentation
2. create/modify config file based on user input if $user, $pass, $host not present
3. create database
4. create table


Index: audiolink
===================================================================
RCS file: /cvsroot/audiolink/audiolink/code/audiolink,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** audiolink	29 Nov 2003 17:27:55 -0000	1.2
--- audiolink	4 Dec 2003 16:20:17 -0000	1.3
***************
*** 27,30 ****
--- 27,200 ----
  
  
+ # Currently, we'll do the database setting up and the config file
+ # setting up here. Eventually, move this to alconf and aldbconf.
+ 
+ # First, detect if there's a config file in the home dir.
+ 
+ 
+ use DBI;
+ use Getopt::Long;
+ 
+ # Options for the database
+ $user = undef;
+ $password = undef;
+ $host = "localhost"; # use local mysql server by default
+ 
+ 
+ # ask_for_configfile_and_input: This function asks if the user wants
+ # to create a config file for the mandatory data she hasn't provided
+ # us with (user/passwd/host for the database).
+ #
+ # arg 1: String field of what's to be asked for.
+ #
+ # return: -1:     User doesn't want to create a config file now.
+ #         string: the string typed in by the user. Implies she wants a
+ #                  config file.
+ 
+ sub ask_for_configfile_and_input {
+ 
+     print STDERR "
+     You haven't specified the " . $_[0] . " field for the database. The
+     easiest way of doing this is by storing it in the AudioLink
+     configuration file. Would you like to do that now?  [Yes/no] ";
+ 
+     chomp($input = <STDIN>);
+ 
+     unless ($input) {
+ 	$input = "yes";
+     }
+ 
+     unless ($input =~ /yes/i) {
+ 
+ 	print "\n\tQuitting now. See the audiolink(1) man page for
+ 	more information on the mandatory input information needed,
+ 	the config file and alternate ways of specifying the
+ 	information.\n";
+ 
+ 	# This is bad... don't quit from a subroutine!
+ 	close CONFFILE;
+ 	exit -1;
+     }
+ 
+     $input = "";
+ 
+     while (not $input) {
+ 	print STDERR "Please enter the " . $_[0] . " field for the database: ";
+ 
+ 	chomp($input = <STDIN>);
+     }
+     return $input;
+ }
+ 
+ GetOptions(
+ 	   'help'      => \$help,
+ 	   'user=s'    => \$user,
+ 	   'pass=s'    => \$password,
+ 	   'host=s'    => \$host,
+ 	   ) or pod2usage();
+ 
+ if ($help) {
+     pod2usage();
+ }
+ 
+ $config_file = "$ENV{HOME}/.audiolink/config";
+ 
+ unless (do $config_file) {
+     warn "WARNING: Couldn't parse the config file, $config_file: $@" if $@;
+     warn "WARNING: Couldn't read the config file, $config_file: $!";
+ }
+ 
+ open(CONFFILE, ">>", $config_file);
+ 
+ unless ($user) {
+     $user = ask_for_configfile_and_input("username");
+     print CONFFILE '$user = ' . $user . ";\n";
+ }
+ unless ($password) {
+     $password = ask_for_configfile_and_input("password");
+     print CONFFILE '$password = ' . $password . ";\n";
+ }
+ unless ($host) {
+     $host = ask_for_configfile_and_input("host");
+     print CONFFILE '$host = ' . $host . ";\n";
+ }
+ 
+ # connect to the database.
+ $dbi_string = "DBI:mysql:aldb:$host"; # using MySQL
+ 
+ $dbh = DBI->connect($dbi_string,$user,$password, 
+ 		    { PrintError => 0,
+ 		      AutoCommit => 1} )
+     or warn "\n$0: WARNING: Could not connect to the database!\
+  !! This probably means that the AudioLink database is not initialized or
+  !! the MySQL server you are trying to connect to is not available.
+ # If
+ # !! you have already created the database tables, answer \"no\" below and
+ # !! start the MySQL server. If you're running it on your local machine,
+ # !! executing \'/etc/init.d/mysql restart\' as root would suffice.\n";
+ 
+ $input = "";
+ 
+ # while (not $input) {
+ #     print "\nShould I initialize the AudioLink database [Yes/no]? ";
+ #     chomp($input = <STDIN>);
+ 
+ #     unless ($input) {
+ # 	$input = "yes";
+ #     }
+ # }
+ 
+ if ($input =~ /no/i) {
+     exit -2;
+ }
+ 
+ $db_name = "aldb";
+ 
+ print "\nCreating the AudioLink database...";
+ 
+ $ret = system("mysqladmin -u$user -p$password -h$host create  $db_name 2>/tmp/audiolink.db.tmp");
+ 
+ #    or print "\nSome error occured.
+ # If the error reported that the database already exists, it's okay. You already had the database created.
+ # If it was some other error, consult the mysqladmin man page and/or notify the AudioLink developers.\n
+ # Anyways, continuing to create AudioLink tables.\n";
+ 
+ open (DBOP, "/tmp/audiolink.db.tmp");
+ while (<DBOP>) {
+     if ( /database exists/i) {
+ 	print "The database already exists. Moving on to creating the tables...\n";
+     } else {
+ 	print "Some error occured while creating the database:\n$_\n";
+ 	print "Ask for help on the audiolink-users\@lists.sourceforge.net mailing list.\n";
+     }
+ }
+ 
+ close DBOP;
+ 
+ print "\nCreating the AudioLink tables...";
+ 
+ $ret = system ("mysql -u$user -p$password -h$host $db_name < /usr/share/doc/audiolink/mysql.schema 2>/tmp/audiolink.tb.tmp");
+ #    or print "\nSome error occured.
+ # If the error reported that the table already exists, it's okay. You already had the table created.
+ # If it was some other error, consult the mysql man page and/or notify the AudioLink developers.\n";
+ 
+ open (DBOP, "/tmp/audiolink.tb.tmp");
+ 
+ while (<DBOP>) {
+     if ( /already exists/i) {
+ 	print "The table already exists.\n";
+     } else {
+ 	print "Some error occured while creating the table:\n$_";
+ 	print "Ask for help on the audiolink-users\@lists.sourceforge.net mailing list.\n";
+     }
+ }
+ 
+ $dbh->disconnect;
+ 
+ print "\n\nAudioLink is now setup. You're now ready to run the program. Take a look at the AudioLink documentation\n";
+ print "available via the three man pages: audiolink(1), alfilldb(1), alsearch(1)\n";
+ print "\nReport positive or negative feedback on the audiolink-users\@lists.sourceforge.net mailing list.\n";
+ 
+ exit 0;
  
  =pod
***************
*** 32,50 ****
  =head1 NAME
  
  audiolink - Music collection manager
  
  =head1 DESCRIPTION
  
! B<AudioLink> is a set of programs which help you manage your music
! collection.
  
! The programs that come with B<AudioLink> are alfilldb and alsearch.
  
! alfilldb(1) 
  
! Creating symbolic links to the actual files is analogous to creating
! playlists in audio-playing software. Symbolic links are actually just
! point to the actual files on the hard disk; 
  
  
  The user and password fields for the database have to be
--- 202,255 ----
  =head1 NAME
  
+ audiolink - Create AudioLink config file, databases and tables
+ 
+ =begin later
  audiolink - Music collection manager
  
+ --- when everything is integrated
+ 
+ =end later
+ 
+ =head1 SYNOPSIS
+ 
+ audiolink [I<OPTION>]...
+ 
  =head1 DESCRIPTION
  
! AudioLink is a set of programs which help you manage your music
! collection. It makes searching for music on your local storage media
! easier and faster. Your searches can include a variety of criteria,
! like male artists, female artists, band, genre, etc.
  
! It supports music files of MP3 and Ogg Vorbis formats.
  
! B<audiolink> assists you in creating a configuration file for oft-used
! options passed to the AudioLink programs and creating the MySQL
! database and tables which the AudioLink programs, L<alfilldb(1)> and
! L<alsearch(1)> use.
  
! =head1 OPTIONS
! 
! =over
! 
! =item B<--help>
! 
! Brief usage information
! 
! =item B<--host>=I<xxx>
! 
! Connects to the MySQL server on the target host. Default is localhost.
! 
! =item B<--pass>=I<xxx>
  
+ Password for the database
+ 
+ =item B<--user>=I<xxx>
+ 
+ Username for the database
+ 
+ =back
+ 
+ =head1 MORE INFORMATION
  
  The user and password fields for the database have to be
***************
*** 58,68 ****
  the programs:
  
- =over
- 
  C<alfilldb --user=mysql_username --pass=mysql_password --prompt=basic /songs/>
  
  C<alsearch --user=mysql_username --pass=mysql_password --artist=kishore --td=/songs/kishore>
  
- =back
  
  =item 2. Environment variables
--- 263,270 ----
***************
*** 71,77 ****
  
  
! If you're using bash, ksh, zsh or sh do this:
  
- =over
  
  C<export DBI_USER=mysql_username>
--- 273,278 ----
  
  
! If you are using bash, ksh, zsh or sh do this:
  
  
  C<export DBI_USER=mysql_username>
***************
*** 79,87 ****
  C<export DBI_PASS=mysql_password>
  
- =back
  
! If you're using csh or tcsh, do this:
  
- =over
  
  C<setenv DBI_USER mysql_username>
--- 280,286 ----
  C<export DBI_PASS=mysql_password>
  
  
! If you are using csh or tcsh, do this:
  
  
  C<setenv DBI_USER mysql_username>
***************
*** 89,93 ****
  C<setenv DBI_USER mysql_password>
  
- =back
  
  Consult the man page of the respective shell interpreter that you
--- 288,291 ----
***************
*** 101,104 ****
--- 299,352 ----
  
  =back
+ 
+ =head1 CONFIGURATION FILE
+ 
+ The AudioLink configuration file resides in the .audiolink/ directory
+ in the user's home directory (F<~/.audiolink/config>). This config
+ file is perl code; it is included in the AudioLink scripts at
+ run-time. This behavior will be changed in a later version, and a
+ simple-to-understand format will be used.
+ 
+ The format of the current config file is such: The option which you
+ want to associate with a value is prepended with a '$' sign, and the
+ value with which it is to be associated follows after an '=' sign. End
+ the statement with a ';'. For example, if you want to associate the
+ value of 'root' to the option 'user', you will use:
+ 
+ C<$user = root;>
+ 
+ =head1 SEE ALSO
+ 
+ =begin man
+ 
+ L<alfilldb(1)>, L<alsearch(1)>
+ 
+ =end man
+ 
+ =begin html
+ 
+ <em><a href="alfilldb_doc.html">alfilldb(1)</a></em>,
+ <em><a href="alsearch_doc.html">alsearch(1)</a></em>
+ 
+ =end html
+ 
+ The current version of this man page is available on the AudioLink
+ website at E<lt>http://audiolink.sourceforge.net/E<gt>.
+ 
+ =head1 BUGS
+ 
+ Report bugs related to the AudioLink software or the man pages to the
+ audiolink-devel mailing list E<lt>aud...@li...<gt>.
+ 
+ =head1 AUTHOR
+ 
+ This manual page is written and maintained by Amit Shah E<lt>ami...@gm...<gt>
+ 
+ =head1 COPYRIGHT
+ 
+ The AudioLink package is Copyright (C) 2003, Amit Shah
+ E<lt>ami...@gm...<gt>. All the programs and the documentation that come
+ as part of AudioLink are licensed by the GNU General Public License v2
+ (GPLv2).
  
  =cut





View entire thread

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2025 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
×
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
✔
✘
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL: