Compare commits

...

13 Commits
2022 ... master

23 changed files with 32597 additions and 40729 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
GunRun2022_250.png (Stored with Git LFS)

Binary file not shown.

BIN
GunRun2022_500.png (Stored with Git LFS)

Binary file not shown.

View File

@ -93,17 +93,17 @@ WHEN "Source" = '10KM' THEN
WHEN regexp_match( "Name", '^[2456]$') THEN 'R,BR'
WHEN regexp_match( "Name", '^[1]$') THEN 'T'
WHEN regexp_match( "Name", '^[3]$') THEN 'B'
WHEN regexp_match( "Name", '^Finish$') THEN 'TR,R'
WHEN regexp_match( "Name", '^Start$') THEN 'BL,L'
WHEN regexp_match( "Name", '^Finish$') THEN 'BR,R'
WHEN regexp_match( "Name", '^Start$') THEN 'BR,R'
END
WHEN "Source" = '5KM' THEN
WHEN "Source" ILIKE '%5KM%' THEN
CASE
WHEN regexp_match( "Name", '^[12]$') THEN 'L,TL'
WHEN regexp_match( "Name", '^[0]$') THEN 'R,BR'
WHEN regexp_match( "Name", '^[4]$') THEN 'T'
WHEN regexp_match( "Name", '^[3]$') THEN 'B'
WHEN regexp_match( "Name", '^Finish$') THEN 'TR,R'
WHEN regexp_match( "Name", '^Start$') THEN 'BL,L'
WHEN regexp_match( "Name", '^Finish$') THEN 'BL,R'
WHEN regexp_match( "Name", '^Start$') THEN 'BR,R'
END
WHEN "Source" = 'Trail' THEN
CASE

View File

@ -1,11 +1,17 @@
#!/usr/bin/python3
import glob, fileinput, os, re, shutil, sys, tempfile, time
import pprint
year = 2022
year = 2023
webfile_dir = "~/public_html/GunRun{}/".format(year)
print("NOTE: year is {}".format(year))
def natural_sort(l):
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(l, key=alphanum_key)
webfile_dir = os.path.expanduser(webfile_dir)
for root, dirs, files in os.walk(webfile_dir):
documents=[]
@ -28,6 +34,28 @@ for root, dirs, files in os.walk(webfile_dir):
else:
canonical.append(name)
most_recent = {}
for file in natural_sort(archive):
m = re.search("^(\d{{8}}) - (Gun Run {} - .*?)(?:\s*\d+(?:\.\d+)?)?(\.\S+)$".format(year), file, re.IGNORECASE)
if m:
date = m.group(1)
name = m.group(2) + m.group(3)
current = most_recent.get(name)
if current is None or date >= current.get('date'):
most_recent[name] = { 'date': date, 'file': file }
for k, v in most_recent.items():
canon = os.path.join(webfile_dir, k)
#file = os.path.join(webfile_dir, v.get('file'))
# No need for directory, since it's in the same directory
file = v.get('file')
#print("Creating symlink from {} to {}".format(file, canon))
if os.path.isfile(canon):
os.unlink(canon)
os.symlink(file, canon)
if k not in canonical:
canonical.append(k)
indexfile = open(os.path.join(webfile_dir, root, "index.html"), "w")
output = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
@ -41,7 +69,7 @@ for root, dirs, files in os.walk(webfile_dir):
if canonical:
output += """<p>Maps</p><ul>"""
for link in sorted(canonical):
for link in natural_sort(canonical):
overview=re.search("Marshal overview", link)
if overview is not None:
continue
@ -55,15 +83,15 @@ for root, dirs, files in os.walk(webfile_dir):
if dirs:
output +="""<p>Clubs</p><ul>"""
dirs.sort()
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>"""
if archive:
archive=[i.split(' - ') for i in archive]
archive.sort(key=lambda line: (line[2],line[0]))
#archive.sort(key=lambda x: (x[2], x[0]))
archive.sort(key=lambda x: (re.split('\s*v?[\d\.]+\w+$', x[2])[0], x[0]))
archive = [' - '.join(i) for i in archive]
output +="""<p>Source Maps</p><ul>"""
@ -73,9 +101,9 @@ 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 marshals:
for link in natural_sort(marshals):
m = re.search('^(.*?).(pdf|png|jpg|jpeg)$', link)
if m is not None:
positions.setdefault(m.group(1), {})[m.group(2)] = link
@ -100,4 +128,5 @@ for root, dirs, files in os.walk(webfile_dir):
indexfile.write(output)
indexfile.close()
# vim: set expandtab shiftwidth=4 softtabstop=4 :

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,