head	1.2;
access;
symbols
	TIGRIS_1_1_0RC2:1.2
	TIGRIS_1_1_0RC1:1.2
	TIGRIS_1_1:1.2.0.6
	TIGRIS_1_0_8:1.2
	TIGRIS_1_0_8RC3:1.2
	TIGRIS_1_0_8RC2:1.2
	TIGRIS_1_0_8RC1:1.2
	TIGRIS_1_0_7:1.2
	TIGRIS_1_0_7RC3:1.2
	TIGRIS_1_0_7RC2:1.2
	TIGRIS_1_0_7RC1:1.2
	TIGRIS_1_0_6:1.2
	TIGRIS_1_0_6RC5:1.2
	TIGRIS_1_0_6RC4:1.2
	TIGRIS_1_0_6RC3:1.2
	TIGRIS_1_0_6RC2:1.2
	TIGRIS_1_0_6RC1:1.2
	TIGRIS_1_0_5:1.2
	TIGRIS_1_0_5RC6:1.2
	TIGRIS_1_0_5RC5:1.2
	TIGRIS_1_0_5RC4:1.2
	TIGRIS_1_0_5RC3:1.2
	TIGRIS_1_0_5RC2:1.2
	TIGRIS_1_0_5RC1:1.2
	TIGRIS_1_0_4:1.2
	TIGRIS_1_0_3:1.2
	TIGRIS_1_0_2:1.2
	TIGRIS_1_0_1:1.2
	TIGRIS_1_0:1.2.0.8
	TIGRIS_1_0_0:1.2
	TIGRIS_1_0_0_RC1:1.2.0.4
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.2
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.2
	TIGRIS_0_9_2_1:1.2
	TIGRIS_0_9_2:1.2.0.2
	TIGRIS_0_9_0:1.1.0.2;
locks; strict;
comment	@# @;


1.2
date	2000.12.22.12.17.27;	author edk;	state Exp;
branches
	1.2.6.1
	1.2.8.1;
next	1.1;

1.1
date	2000.12.22.12.15.53;	author edk;	state dead;
branches
	1.1.1.1
	1.1.2.1;
next	;

1.1.1.1
date	2001.02.21.00.36.24;	author dlr;	state Exp;
branches;
next	;

1.1.2.1
date	2000.12.22.12.16.11;	author edk;	state Exp;
branches;
next	;

1.2.6.1
date	2001.08.22.19.12.10;	author ms;	state Exp;
branches;
next	;

1.2.8.1
date	2001.08.22.08.13.38;	author ms;	state Exp;
branches;
next	;


desc
@@


1.2
log
@a script to convert ezmlm archives to mbox files for eyebrowse
@
text
@#!/usr/bin/perl

use DBI;  
use Getopt::Long;
use strict;

main();

sub main {
    my $options_ref = getOptions();
    $main::dbh = getDatabaseConnection();
    my $lists_ref = getLists($main::dbh);
    handleLists($options_ref, $lists_ref);
}

#################################
### handle any required actions
#################################

sub handleLists {
    my ($options_ref, $lists_ref) = @@_;
    my @@command_base = getCommand($options_ref);
    foreach my $list (@@$lists_ref) {
        my ($list, $project, $domain) = @@$list;
        my @@command = getCommand($options_ref, $list, $project, $domain);
#        print "would do @@command\n";
        system (@@command);
    }
}

sub getCommand {
    my ($options_ref, $list, $project, $domain) = @@_;
    my @@command =
        ($options_ref->{sandbox}."/eyebrowse/src/scripts/index2mbox.pl",
         "--directory");
    if ($options_ref->{type} eq "oldtigris") {
        # treat www as a special case
        push @@command, $options_ref->{directory} . "/" .
            ($project eq 'www' ? '' : "$project-" ) . $list;
    } elsif ($options_ref->{type} eq "sourcecast") {
        push @@command, $options_ref->{directory} . "/domains/" . $domain .
            "/projects/" . $project . "/addresses/" . $list;
    }
    push @@command, "--output", $options_ref->{sandbox} . "/data/eyebrowse/".
        $domain . "/" . $project . "/" . $list . "/0mbox";
    return @@command;
}

#################################
### process information according to business logic
#################################

#################################
###  preparation (getting information, db connections, etc.)
#################################

sub getOptions {
    my %options;
    if (!GetOptions(\%options, "type=s", "directory=s", "sandbox=s")) {
        showUsage();
    }
    $options{sandbox} || ($options{sandbox} = '__SANDBOX__');
    $options{type}    || ($options{type}    = "oldtigris");
    die "invalid type $options{type}\n" 
        if ($options{type} ne "oldtigris" and $options{type} ne "sourcecast");

    if (not $options{directory}) {
        if ($options{type} eq "oldtigris") {
            $options{directory} = "$options{sandbox}/data/helm/qmail";
        } elsif ($options{type} eq "sourcecast") {
            $options{directory} = "$options{sandbox}/data/anzu";
        }
    }
    return \%options;
}
    
sub getLists {
    my ($dbh) = @@_;
    my @@lists = ();
    my $select  = $dbh->prepare(
            "SELECT ml.LIST_NAME as list, ".
                "proj.NAME as project, ".
                "dom.NAME as domain " .
            "FROM HELM_MAILINGLIST ml, HELM_PROJECT proj, HELM_DOMAIN dom ".
            "WHERE ml.PROJECT_ID = proj.PROJECT_ID AND ".
                "proj.DOMAIN_ID = dom.DOMAIN_ID");
    my $ret  = $select->execute();
    warn "error selecting lists" if not $ret;
    while (my $listRecord = $select->fetchrow_hashref) {
        my $list = $listRecord->{list};
        my $project = $listRecord->{project};
        my $domain = $listRecord->{domain};
        push @@lists, [$list, $project, $domain];
    }
    return \@@lists;
}

END { $main::dbh->disconnect if $main::dbh }

sub getDatabaseConnection {
    my $db_base = 'mysql';
    my $db_name = '__DATABASE_NAME__';
    my $db_host = '__DATABASE_HOST__';
    my $db_port = '__DATABASE_PORT__';
    my $db_user = '__DATABASE_USER__';
    my $db_pass = '__DATABASE_PASSWORD__';
    my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port";
    my $dbh = DBI->connect($connectstring, $db_user, $db_pass)
        or die "Can't connect to the table '$connectstring'.\n";
    return $dbh;
}

sub showUsage {
    print "usage: archive_convert [--sandbox {sandbox}] [--directory {dir}]\n",
        "\t[--type {type}]\n";
    exit;
}

@


1.2.6.1
log
@fix for lists having different names in the db to disc
@
text
@a32 1
    ($list, $project, $domain) = lc ($list, $project, $domain);
@


1.2.8.1
log
@fix for lists having different names in the db to disc
@
text
@a32 1
    ($list, $project, $domain)  = lc($list, $project, $domain);
@


1.1
log
@file archive_convert.in was initially added on branch HEAD.
@
text
@d1 118
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@a0 118
#!/usr/bin/perl

use DBI;  
use Getopt::Long;
use strict;

main();

sub main {
    my $options_ref = getOptions();
    $main::dbh = getDatabaseConnection();
    my $lists_ref = getLists($main::dbh);
    handleLists($options_ref, $lists_ref);
}

#################################
### handle any required actions
#################################

sub handleLists {
    my ($options_ref, $lists_ref) = @@_;
    my @@command_base = getCommand($options_ref);
    foreach my $list (@@$lists_ref) {
        my ($list, $project, $domain) = @@$list;
        my @@command = getCommand($options_ref, $list, $project, $domain);
#        print "would do @@command\n";
        system (@@command);
    }
}

sub getCommand {
    my ($options_ref, $list, $project, $domain) = @@_;
    my @@command =
        ($options_ref->{sandbox}."/eyebrowse/src/scripts/index2mbox.pl",
         "--directory");
    if ($options_ref->{type} eq "oldtigris") {
        # treat www as a special case
        push @@command, $options_ref->{directory} . "/" .
            ($project eq 'www' ? '' : "$project-" ) . $list;
    } elsif ($options_ref->{type} eq "sourcecast") {
        push @@command, $options_ref->{directory} . "/domains/" . $domain .
            "/projects/" . $project . "/addresses/" . $list;
    }
    push @@command, "--output", $options_ref->{sandbox} . "/data/eyebrowse/".
        $domain . "/" . $project . "/" . $list . "/0mbox";
    return @@command;
}

#################################
### process information according to business logic
#################################

#################################
###  preparation (getting information, db connections, etc.)
#################################

sub getOptions {
    my %options;
    if (!GetOptions(\%options, "type=s", "directory=s", "sandbox=s")) {
        showUsage();
    }
    $options{sandbox} || ($options{sandbox} = '__SANDBOX__');
    $options{type}    || ($options{type}    = "oldtigris");
    die "invalid type $options{type}\n" 
        if ($options{type} ne "oldtigris" and $options{type} ne "sourcecast");

    if (not $options{directory}) {
        if ($options{type} eq "oldtigris") {
            $options{directory} = "$options{sandbox}/data/helm/qmail";
        } elsif ($options{type} eq "sourcecast") {
            $options{directory} = "$options{sandbox}/data/anzu";
        }
    }
    return \%options;
}
    
sub getLists {
    my ($dbh) = @@_;
    my @@lists = ();
    my $select  = $dbh->prepare(
            "SELECT ml.LIST_NAME as list, ".
                "proj.NAME as project, ".
                "dom.NAME as domain " .
            "FROM HELM_MAILINGLIST ml, HELM_PROJECT proj, HELM_DOMAIN dom ".
            "WHERE ml.PROJECT_ID = proj.PROJECT_ID AND ".
                "proj.DOMAIN_ID = dom.DOMAIN_ID");
    my $ret  = $select->execute();
    warn "error selecting lists" if not $ret;
    while (my $listRecord = $select->fetchrow_hashref) {
        my $list = $listRecord->{list};
        my $project = $listRecord->{project};
        my $domain = $listRecord->{domain};
        push @@lists, [$list, $project, $domain];
    }
    return \@@lists;
}

END { $main::dbh->disconnect if $main::dbh }

sub getDatabaseConnection {
    my $db_base = 'mysql';
    my $db_name = '__DATABASE_NAME__';
    my $db_host = '__DATABASE_HOST__';
    my $db_port = '__DATABASE_PORT__';
    my $db_user = '__DATABASE_USER__';
    my $db_pass = '__DATABASE_PASSWORD__';
    my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port";
    my $dbh = DBI->connect($connectstring, $db_user, $db_pass)
        or die "Can't connect to the table '$connectstring'.\n";
    return $dbh;
}

sub showUsage {
    print "usage: archive_convert [--sandbox {sandbox}] [--directory {dir}]\n",
        "\t[--type {type}]\n";
    exit;
}

@


1.1.2.1
log
@a script to convert ezmlm archives to mbox files for eyebrowse
@
text
@a0 118
#!/usr/bin/perl

use DBI;  
use Getopt::Long;
use strict;

main();

sub main {
    my $options_ref = getOptions();
    $main::dbh = getDatabaseConnection();
    my $lists_ref = getLists($main::dbh);
    handleLists($options_ref, $lists_ref);
}

#################################
### handle any required actions
#################################

sub handleLists {
    my ($options_ref, $lists_ref) = @@_;
    my @@command_base = getCommand($options_ref);
    foreach my $list (@@$lists_ref) {
        my ($list, $project, $domain) = @@$list;
        my @@command = getCommand($options_ref, $list, $project, $domain);
#        print "would do @@command\n";
        system (@@command);
    }
}

sub getCommand {
    my ($options_ref, $list, $project, $domain) = @@_;
    my @@command =
        ($options_ref->{sandbox}."/eyebrowse/src/scripts/index2mbox.pl",
         "--directory");
    if ($options_ref->{type} eq "oldtigris") {
        # treat www as a special case
        push @@command, $options_ref->{directory} . "/" .
            ($project eq 'www' ? '' : "$project-" ) . $list;
    } elsif ($options_ref->{type} eq "sourcecast") {
        push @@command, $options_ref->{directory} . "/domains/" . $domain .
            "/projects/" . $project . "/addresses/" . $list;
    }
    push @@command, "--output", $options_ref->{sandbox} . "/data/eyebrowse/".
        $domain . "/" . $project . "/" . $list . "/0mbox";
    return @@command;
}

#################################
### process information according to business logic
#################################

#################################
###  preparation (getting information, db connections, etc.)
#################################

sub getOptions {
    my %options;
    if (!GetOptions(\%options, "type=s", "directory=s", "sandbox=s")) {
        showUsage();
    }
    $options{sandbox} || ($options{sandbox} = '__SANDBOX__');
    $options{type}    || ($options{type}    = "oldtigris");
    die "invalid type $options{type}\n" 
        if ($options{type} ne "oldtigris" and $options{type} ne "sourcecast");

    if (not $options{directory}) {
        if ($options{type} eq "oldtigris") {
            $options{directory} = "$options{sandbox}/data/helm/qmail";
        } elsif ($options{type} eq "sourcecast") {
            $options{directory} = "$options{sandbox}/data/anzu";
        }
    }
    return \%options;
}
    
sub getLists {
    my ($dbh) = @@_;
    my @@lists = ();
    my $select  = $dbh->prepare(
            "SELECT ml.LIST_NAME as list, ".
                "proj.NAME as project, ".
                "dom.NAME as domain " .
            "FROM HELM_MAILINGLIST ml, HELM_PROJECT proj, HELM_DOMAIN dom ".
            "WHERE ml.PROJECT_ID = proj.PROJECT_ID AND ".
                "proj.DOMAIN_ID = dom.DOMAIN_ID");
    my $ret  = $select->execute();
    warn "error selecting lists" if not $ret;
    while (my $listRecord = $select->fetchrow_hashref) {
        my $list = $listRecord->{list};
        my $project = $listRecord->{project};
        my $domain = $listRecord->{domain};
        push @@lists, [$list, $project, $domain];
    }
    return \@@lists;
}

END { $main::dbh->disconnect if $main::dbh }

sub getDatabaseConnection {
    my $db_base = 'mysql';
    my $db_name = '__DATABASE_NAME__';
    my $db_host = '__DATABASE_HOST__';
    my $db_port = '__DATABASE_PORT__';
    my $db_user = '__DATABASE_USER__';
    my $db_pass = '__DATABASE_PASSWORD__';
    my $connectstring = "dbi:$db_base:$db_name:host=$db_host:port=$db_port";
    my $dbh = DBI->connect($connectstring, $db_user, $db_pass)
        or die "Can't connect to the table '$connectstring'.\n";
    return $dbh;
}

sub showUsage {
    print "usage: archive_convert [--sandbox {sandbox}] [--directory {dir}]\n",
        "\t[--type {type}]\n";
    exit;
}

@

