/[notice-sender]/trunk/sender.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/sender.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (hide annotations)
Sat May 14 10:44:53 2005 UTC (18 years, 11 months ago) by dpavlin
File MIME type: text/plain
File size: 1739 byte(s)
call commit, now works

1 dpavlin 1 #!/usr/bin/perl -w
2    
3     use strict;
4     use Class::DBI::Loader::Pg;
5     use Getopt::Long;
6     use Data::Dumper;
7    
8 dpavlin 2 my ($list_opt,$debug) = (0,0);
9     my $add_opt;
10 dpavlin 1
11     my $result = GetOptions(
12 dpavlin 2 "list" => \$list_opt,
13     "add=s" => \$add_opt,
14 dpavlin 1 "debug" => \$debug,
15     );
16    
17    
18     my $loader = Class::DBI::Loader::Pg->new(
19     debug => $debug,
20     dsn => "dbi:Pg:dbname=notices",
21     user => "dpavlin",
22     password => "",
23     namespace => "Noticer",
24     # additional_classes => qw/Class::DBI::AbstractSearch/,
25     # additional_base_classes => qw/My::Stuff/,
26 dpavlin 3 relationships => 1,
27 dpavlin 1 );
28    
29 dpavlin 2 my $lists = $loader->find_class('lists');
30     my $users = $loader->find_class('users');
31     my $user_list = $loader->find_class('user_list');
32    
33     if ($list_opt) {
34 dpavlin 1 foreach my $list ($lists->retrieve_all) {
35     print $list->name,"\n";
36     foreach my $user_on_list ($user_list->search(list_id => $list->id)) {
37     my $user = $users->retrieve( id => $user_on_list->user_id );
38     print "\t",$user->full_name," <", $user->email, ">\n";
39     }
40     }
41 dpavlin 2 } elsif ($add_opt) {
42     #my $noticer = $loader->find_class('Noticer') || die "can't find my class!";
43     my $list = $lists->find_or_create({
44     name => $add_opt,
45     }) || die "can't add list $add_opt\n";
46     while(<>) {
47     chomp;
48     next if (/^#/ || /^\s*$/);
49     my ($email, $name) = split(/\s+/,$_, 2);
50     print "# $name <$email>\n";
51     my $this_user = $users->find_or_create({
52     email => $email,
53     full_name => $name,
54     }) || die "can't find or create member\n";
55     my $user_on_list = $user_list->find_or_create({
56     user_id => $this_user->id,
57     list_id => $list->id,
58     }) || die "can't add user to list";
59     }
60 dpavlin 3
61     foreach my $c_name ($loader->tables) {
62     my $c = $loader->find_class($c_name)|| die "can't find $c_name";
63     $c->dbi_commit();
64     }
65    
66 dpavlin 1 } else {
67 dpavlin 3 die "$0 --list --add=name_of_list --debug\n";
68 dpavlin 1 }
69    
70    

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26