Final updates for 2019.

This commit is contained in:
Timothy Allen 2019-10-25 09:40:29 +02:00
parent 9e68c64444
commit 8c2af36944
5 changed files with 189 additions and 145 deletions

Binary file not shown.

View File

@ -1,139 +0,0 @@
#!/usr/bin/perl
#
# Tool to clean up marshal spreadsheet data, 2017
#
use strict;
use warnings;
use Data::Dumper;
my $clubs = {
'AAC' => {
},
'Eerste Rivier' => {
'captain' => 'Raphael Manual',
'captain_ph' => '084-494-4525',
'email' => 'raphaeljm1@gmail.com',
},
'Spartan Harriers' => {
'captain' => 'Gavin Craig',
'captain_ph' => '076-569-6898',
'email' => 'gavinc@ctpflexibles.co.za',
},
'Nantes' => {
'captain' => 'Caroline Peters',
'captain_ph' => '073-029-7879',
'email' => 'carolinepeters1964@gmail.com',
},
'Midas Spartans' => {
'captain' => 'Michael Schouw',
'captain_ph' => '083-635-1346',
'email' => 'schouw.za@gmail.com',
},
'Edgemead Runners' => {
'captain' => 'Stephan Roux ',
'captain_ph' => '082-433-0230',
'email' => 'raceconvener@edgemeaddrunners.org.za',
},
};
my @marshals;
sub assign_club {
my $position = shift;
my $club = shift;
$marshals[$position]->{'club'} = $club;
foreach my $key ( keys %{ $clubs->{$club} } ) {
$marshals[$position]->{$key} = $clubs->{$club}->{$key};
}
}
for ( my $position = 0; $position < 324; $position++ ) {
if ($position > 0 && $position <= 10) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = "William Ruijsch van Dugteren";
$marshals[$position]->{'captain_ph'} = '';
} elsif ($position > 10 && $position <= 35 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = "Darwees Gesant";
} elsif ($position > 35 && $position <= 54 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = "Faried Rinquest";
} elsif ($position > 54 && $position <= 69 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = '';
} elsif ($position > 69 && $position <= 80 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = 'Colin Sedeman';
} elsif ($position > 80 && $position <= 126 ) {
assign_club( $position, 'Eerste Rivier' );
} elsif ($position > 126 && $position <= 127 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 127 && $position <= 131 ) {
assign_club( $position, 'Eerste Rivier' );
} elsif ($position > 131 && $position <= 132 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 132 && $position <= 153 ) {
assign_club( $position, 'Nantes' );
} elsif ($position > 153 && $position <= 199 ) {
assign_club( $position, 'Midas Spartans' );
} elsif ($position > 199 && $position <= 238 ) {
assign_club( $position, 'Nantes' );
} elsif ($position > 238 && $position <= 250 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 250 && $position <= 256 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 256 && $position <= 257 ) {
assign_club( $position, 'Edgemead Runners' );
} elsif ($position > 257 && $position <= 261 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 261 && $position <= 264 ) {
assign_club( $position, 'Edgemead Runners' );
} elsif ($position > 264 && $position <= 274 ) {
assign_club( $position, 'Spartan Harriers' );
} elsif ($position > 274 && $position <= 281 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = 'Keith Bake';
} elsif ($position > 281 && $position <= 297 ) {
assign_club( $position, 'Edgemead Runners' );
} elsif ($position > 297 && $position <= 301 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = 'Colin Sedeman';
} elsif ($position > 301 && $position <= 313 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = 'Keith Bake';
} elsif ($position > 313 && $position <= 323 ) {
assign_club( $position, 'AAC' );
$marshals[$position]->{'captain'} = 'Colin Sedeman';
}
}
=cut
AAC : Positions 1 to 10 Start - William Ruijsch van Dugteren
AAC : Positions 11 to 35 Darawees Gasant
AAC : positions 36 to 54 Faried Rinquest
AAC : Positions 55 to 69 may be John Damata
AAC : Positions 70 to 80, 298 to 301 and 314 to 323 - Collin Sedeman
AAC: Positions 275 to 281, and 302 to 313 - Keith Bake
Eerste Rivier : Positions 81 to 126 and 128 to 131 (50 marshals ) - Rapheal Manual 084 494 4525 raphaeljm1@gmail.com
Nantes : Positions 133 to 153 and 200 to 238 (60 marshals ) - Caroline Peters 073 029 7879 carolinepeters1964@gmail.com
Midas Spartans : Positions 154 to 199 (47 marshals ) - Michael Schouw 083 635 1346 schouw.za*gmail.com
Spartan Harriers : Positions 239 to 250, 132 x 2, 127, 251 to 256, 258 to 261, 265 to 274 ( 35 marshals ) - Gavin Craig 076 569 6898 gavinc@ctpflexibles.co.za
Edgemead Runners : Positions 257, 262 to 265 and 282 to 297 ( 20 marshals ) - Stephan Roux 082 433 0230 raceconvener@edgemeaddrunners.org.za
=cut
#warn Dumper(@marshals);
print "CASE\n";
foreach (1..$#marshals) {
my $data = $marshals[$_]->{'email'};
print qq(
WHEN "position" = $_
THEN '$data'
) if $data;
}
print "END\n";

View File

@ -91,7 +91,7 @@ foreach my $person (@emails) {
if ($position =~ /^(10\d|110)$/) {
$position_time = "4:45AM";
} else {
$position_time = "6AM";
$position_time = "5:45AM";
}
# if ($position =~ /^(26|27)$/i) {
@ -106,6 +106,8 @@ foreach my $person (@emails) {
my $pdf = $pdf_dir . $club . '_marshal_map_' . $position . '.pdf';
my $jpg = $pdf_dir . $club . '_marshal_map_' . $position . '.jpg';
my $parking = $map_dir . '/Gun Run 2019 - P9 Marshal Parking.pdf';
my $directions = $map_dir . '/Gun Run 2019 - P9 Parking Access.pdf';
my $pdf_filename = basename($pdf);
my $jpg_filename = basename($jpg);
die "No PDF at $pdf_filename" unless -e $pdf;
@ -120,11 +122,11 @@ Dear $salutation
</p>
<p>
Thank you for helping out at this year's Gun Run!
I believe that many marshals didn't receive their maps, so I'm re-sending to everyone. If you received your map before, please accept my apologies, along with the attached voucher for parking in P9! I've also attached a map that shows you how to get to P9: turn off Helen Suzman by the Virgin Active, turn right at the T-junction, and pass through the gate at the end of the road, onto the field in Green Point Park. Please note that you will need to <b>print</b> the map (security won't accept an image on your phone).
</p>
<p>
Attached to this email is a map that gives your marshalling position. <b>You are in position $position on the map.</b> It's important to be in place by <b>$position_time</b> on the day, as the police and traffic officials will be conducting spot checks at that point, and if any marshal is not in position, they may call off the race or delay it.
Also attached to this email is a map that gives your marshalling position. <b>You are in position $position on the map.</b> It's important to be in place by <b>$position_time</b> on the day, as the police and traffic officials will be conducting spot checks at that point, and if any marshal is not in position, they may call off the race or delay it.
</p>
<p>
@ -156,7 +158,7 @@ Tim
my $plain_text = qq(Dear $salutation
Thank you for helping out at this year's Gun Run!
I believe that many marshals didn't receive their maps, so I'm re-sending to everyone. If you received your map before, please accept my apologies, along with the attached voucher for parking in P9! I've also attached a map that shows you how to get to P9: turn off Helen Suzman by the Virgin Active, turn right at the T-junction, and pass through the gate at the end of the road, onto the field in Green Point Park. Please note that you will need to print the map (security won't accept an image on your phone).
Attached to this email is a map that gives your marshalling position. You are in position $position. It's important to be in place by $position_time on the day, as the police and traffic officials will be conducting spot checks at that point, and if any marshal is not in position, they may call off the race or delay it.
@ -174,12 +176,16 @@ Tim
);
$pdf_filename =~ s/^.*?_//;
my %objects = ( "$pdf_filename" => $pdf );
my %objects = (
"$pdf_filename" => $pdf,
"Gun_Run_2019_-_P9_Marshal_Parking.pdf" => $parking,
"Gun_Run_2019_-_P9_Parking_Access.pdf" => $directions,
);
my $mail = Email::MIME->create_html(
header => [
From => 'Timothy Allen <tim@allen.org.za>',
Subject => 'Your Gun Run 2019 marshalling position',
Subject => 'Your Gun Run 2019 marshalling position (with parking voucher)',
To => $m,
],
body => $html,

177
send_thanks.pl Executable file
View File

@ -0,0 +1,177 @@
#!/usr/bin/perl
# Debug level 0: Send email
# Debug level 1: Send email to myself
# Debug level 2: Print names and email addresses
use strict;
use warnings;
use Text::CSV;
use Email::MIME::CreateHTML;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP;
use Email::Sender::Transport::SMTPS;
use Email::Sender::Transport::SMTP::TLS;
use Term::ReadKey;
use File::Basename;
use Try::Tiny;
use Data::Dumper;
my $map_dir = '/home/tim/Documents/Projects/2019/Gun Run/Maps/';
my $email_csv = "$map_dir/GIS Base Map/marshals_by_position.csv";
my $debug = 2;
my @emails;
if ($debug == 2) {
print "WARNING: Printing names. Not sending emails!\n";
} elsif ($debug == 1) {
print "WARNING: Sending emails to a TEST address.\n";
} elsif ($debug == 0) {
print "Sending emails to...\n";
} else {
print "ERROR: Invalid debug value\n";
}
my $password;
if (-f "$map_dir/password_store") {
open(my $fh, '<:encoding(UTF-8)', "$map_dir/password_store") or die "Could not open password store: $!";
while (my $row = <$fh>) {
chomp($password = $row);
}
close($fh)
} else {
print "Please type your email password: ";
#chomp($password = <STDIN>);
ReadMode('noecho');
chomp($password = ReadLine(0));
print "\n";
ReadMode('normal');
}
my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $ifh, "<", $email_csv or die "Could not read $email_csv: $!";
$csv->column_names($csv->getline( $ifh ));
while ( my $row = $csv->getline( $ifh ) ) {
my $person = {
"position" => $row->[0],
"club" => $row->[1],
"first_name" => $row->[2],
"name" => $row->[4],
"email" => $row->[6],
};
$person->{"name"} =~ s/ +$//g if $person->{"name"};
$person->{"name"} =~ s/ +/ /g if $person->{"name"};
$person->{"first_name"} =~ s/ +$//g if $person->{"first_name"};
$person->{"first_name"} =~ s/ +/ /g if $person->{"first_name"};
$person->{"email"} =~ s/,//g if $person->{"email"};
push @emails, $person;
}
$csv->eof or $csv->error_diag();
close $ifh;
#@emails = sort { $a->{"position"} cmp $b->{"position"} } @emails;
if ($ARGV[0]) {
my $pos = $ARGV[0];
@emails = grep { $_->{"position"} =~ /^$pos$/ } @emails;
}
#print Dumper(@emails);
foreach my $person (@emails) {
next unless $$person{"name"} and $$person{"email"};
next unless $$person{"club"} =~ /^(AAC)$/;
next if $$person{"position"} =~ /\D/;
my $salutation = $$person{"first_name"};
my $name = $$person{"name"};
my $email = $$person{"email"};
my $club = $$person{"club"};
next unless $email =~ /@/;
my $position = $$person{"position"};
foreach my $m (split(/[, ]+/, $email)) {
$m = "$name <$m>";
printf "%-4s %-15s %15s\n", $$person{"position"}, $salutation, $m if ($debug >= 0);
$m = 'Timothy Allen <tim@allen.org.za>' if ($debug == 1);
my $html = qq(
<html><head>
</head>
<body>
<p>
Dear $salutation
</p>
<p>
A big thank you from me and from the Gun Run committee for your help marshalling today.
</p>
<p>
It was a very successful Gun Run, and we can all be pleased by how well the event ran. I heard a lot of compliments about the marshalling, and the race went beautifully, I thought, with very few major hiccups.
</p>
<p>
If you have any suggestions as to how we can improve next year, please drop me or Roger an email.
</p>
<p>
I hope you enjoyed the experience and will hopefully support us again next year. Until then, enjoy your running and take care out there.
</p>
<p>
Warm regards,
</p>
<p>
Tim
</p>
</body>
</html>
);
my $plain_text = qq(Dear $salutation
A big thank you from me and from the Gun Run committee for your help marshalling today.
It was a very successful Gun Run, and we can all be pleased by how well the event ran. I heard a lot of compliments about the marshalling, and the race went beautifully, I thought, with very few major hiccups.
If you have any suggestions as to how we can improve next year, please drop me or Roger an email.
I hope you enjoyed the experience and will hopefully support us again next year. Until then, enjoy your running and take care out there.
Warm regards,
Tim
);
my $mail = Email::MIME->create_html(
header => [
"From" => 'Timothy Allen <tim@allen.org.za>',
"Subject" => 'Thank you for marshalling',
"To" => $m,
"Reply-To" => 'Timothy Allen <tim@allen.org.za>, Roger Steward <stewardrh@gmail.com>',
],
body => $html,
text_body => $plain_text,
);
my $g_transport = Email::Sender::Transport::SMTP::TLS->new(
host => 'smtp.gmail.com',
username => 'trallen@gmail.com',
password => $password,
);
my $t_transport = Email::Sender::Transport::SMTP::TLS->new(
host => 'mail.treehouse.org.za',
username => 'tim',
password => $password,
);
try {
# sendmail($mail, { transport => $g_transport }) if ($debug <= 1);
sendmail($mail, { transport => $t_transport }) if ($debug <= 1);
} catch {
warn "\n\nError sending email for position $position\n\n";
warn $_;
};
}
sleep 2 if ($debug < 1);
last if ($debug == 1);
}
# vim: set expandtab shiftwidth=4 softtabstop=4 :