Update scripts

This commit is contained in:
Timothy Allen 2023-09-15 10:02:53 +02:00
parent 621c8842b1
commit e82cf4ce26
4 changed files with 30494 additions and 30480 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -83,8 +83,7 @@ for root, dirs, files in os.walk(webfile_dir):
if dirs:
output +="""<p>Clubs</p><ul>"""
natural_sort(dirs)
for link in dirs:
for link in natural_sort(dirs):
if not os.path.islink(link):
output += """<li><a href="{}">{}</a></li>""".format(link, link)
output += """</ul>"""
@ -102,7 +101,7 @@ for root, dirs, files in os.walk(webfile_dir):
if marshals:
output +="""<p>Marshal maps</p><table style="border-collapse: collapse;">"""
marshals.sort(key=lambda x: int(re.sub('^.*_(\d+)\..{3,6}?$', '\g<1>', x)))
marshals.sort(key=lambda x: re.sub('^.*_(\d{2}\w)\..{3,6}?$', '\g<1>', x))
positions={}
for link in natural_sort(marshals):
m = re.search('^(.*?).(pdf|png|jpg|jpeg)$', link)

View File

@ -17,10 +17,10 @@ use File::Basename;
use Try::Tiny;
use Data::Dumper;
my $map_dir = '/home/tim/Documents/Projects/2022/Gun Run/Maps/';
my $map_dir = '/home/tim/Documents/Projects/2023/Gun Run/Maps/';
my $email_csv = "$map_dir/marshals_by_position.csv";
my $pdf_dir = "$map_dir/GIS Base Map/Marshals/";
my $debug = 1;
my $debug = 2;
my @emails;
if ($debug == 2) {
@ -76,8 +76,8 @@ if ($ARGV[0]) {
foreach my $person (@emails) {
next unless $$person{"email"};
next unless $$person{"club"} =~ /^(AAC)$/;
next if $$person{"position"} =~ /\D/;
next unless $$person{"club"} =~ /^(AAC|Atlantic Athletic.*?)$/;
next if $$person{"position"} !~ /\d\d\w/;
#my $name = $$person{"name"};
my $email = $$person{"email"};
my $club = $$person{"club"};
@ -85,11 +85,26 @@ foreach my $person (@emails) {
my $day = $$person{"day"};
my $position = $$person{"position"};
my $position_time;
if ($position =~ /^..?$/) {
$position_time = "6:30AM";
} elsif ($position =~ /^(10\d|110)$/) {
if ($day eq '1' and $position =~ /^10\w$/) {
# Start, Saturday
$position_time = "5:00AM";
} elsif ($day eq '2' and $position =~ /^20\w$/) {
# Start, Sunday
$position_time = "4:30AM";
} elsif ($day eq '1' and $position =~ /^00\w$/) {
# Ask Me, Saturday
$position_time = "6:00AM";
} elsif ($day eq '2' and $position =~ /^60\w$/) {
# Ask Me, Sunday
$position_time = "5:30AM";
} elsif ($position =~ /^0[1-7]\w$/) {
# Trail, Saturday
$position_time = "6:30AM";
} elsif ($day eq '1') {
# Saturday
$position_time = "6:00AM";
} else {
# Sunday
$position_time = "5:30AM";
}
@ -108,7 +123,7 @@ foreach my $person (@emails) {
my $jpg = $pdf_dir . $club . '/' . $day . '_' . $club . '_marshal_map_' . $position . '.jpg';
my $pdf_filename = basename($pdf);
my $jpg_filename = basename($jpg);
die "No PDF at $pdf_filename" unless -e $pdf;
die "No PDF at $pdf_filename $pdf" unless -e $pdf;
die "No JPG at $jpg_filename" unless -e $jpg;
my $html = qq(
@ -120,11 +135,11 @@ Please find attached to this email a map that gives your marshalling position. <
</p>
<p>
If you have any trouble opening the attachment, the map is available online as a <a href="https://node.org.za/GunRun2022/$club/$pdf_filename">PDF document</a> and an <a href="https://node.org.za/GunRun2022/$club/$jpg_filename">image</a>.
If you have any trouble opening the attachment, the map is available online as a <a href="https://node.org.za/GunRun2023/$club/$pdf_filename">PDF document</a> and an <a href="https://node.org.za/GunRun2023/$club/$jpg_filename">image</a>.
</p>
<p>
In addition, there is a complete <a href="https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Routes.pdf">route map</a> and a map of <a href="https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Marshal%20plan.pdf">all marshal positions</a>. If you need to lay out cones, you may find the <a href="https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Fencing%20-%20Cones.pdf">fencing map</a> helpful.
In addition, there is a complete <a href="https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Routes.pdf">route map</a> and a map of <a href="https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Marshal%20plan.pdf">all marshal positions</a>. If you need to lay out cones, you may find the <a href="https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Fencing%20-%20Cones.pdf">fencing map</a> helpful.
</p>
<p>
@ -148,9 +163,9 @@ Thank you for helping to make this year's Gun Run a success!
my $plain_text = qq(Please find attached to this email 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.
If you have any trouble opening the attachment, the map is available online as a PDF document at <https://node.org.za/GunRun2022/$club/$pdf_filename> and as an image at <https://node.org.za/GunRun2022/$club/$jpg_filename>.
If you have any trouble opening the attachment, the map is available online as a PDF document at <https://node.org.za/GunRun2023/$club/$pdf_filename> and as an image at <https://node.org.za/GunRun2023/$club/$jpg_filename>.
In addition, there is a complete route map at <https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Routes.pdf> and a map of all marshal positions at <https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Marshal%20plan.pdf>. If you need to lay out cones, you may find the fencing map helpful: <https://node.org.za/GunRun2022/Gun%20Run%202022%20-%20Fencing%20rev%202.1%20-%20Cones.pdf>.
In addition, there is a complete route map at <https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Routes.pdf> and a map of all marshal positions at <https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Marshal%20plan.pdf>. If you need to lay out cones, you may find the fencing map helpful: <https://node.org.za/GunRun2023/Gun%20Run%202023%20-%20Fencing%20rev%202.1%20-%20Cones.pdf>.
You'll notice the map has several phone numbers on it -- if in doubt, please call the Venue Operations Centre (VOC) in case of any emergency, as you'll get a faster response than by calling your captain or myself.
@ -169,7 +184,7 @@ Thank you for helping to make this year's Gun Run a success!
my $mail = Email::MIME->create_html(
header => [
From => 'Timothy Allen <tim@allen.org.za>',
Subject => 'Your Gun Run 2022 marshalling position',
Subject => 'Your Gun Run 2023 marshalling position',
To => $m,
],
body => $html,