from boto3.dynamodb.conditions import Key
import os
import re
+import sys
WEBROOT = "/srv/halibut.cworth.org/www"
f.close()
return None
-# Initialize AWS resources to talk to database
+def generate_for_hunt_id(table, hunt_id):
+ hunt, puzzles, rounds = hunt_info(table, hunt_id)
+
+ # Create a directory for the hunt in the WEBROOT
+ root = hunt_file(hunt, "")
+ try:
+ os.mkdir(root)
+ except FileExistsError:
+ # We're happy as a clam if the directory already exists
+ pass
+
+ overview(hunt, puzzles, rounds)
+ for rnd in rounds:
+ round_overview(hunt, rnd, puzzles)
+ for puzzle in puzzles:
+ puzzle_overview(hunt, puzzle)
+ puzzle_lists(hunt, puzzles, "All")
+ puzzle_lists(hunt, puzzles, "Solved")
+ puzzle_lists(hunt, puzzles, "Unsolved")
+
+# Initialize AWS resources to talk to the database
db = boto3.resource('dynamodb')
table = db.Table("turbot")
-hunt, puzzles, rounds = hunt_info(table, "mh2021")
-
-# Create a directory for the hunt in the WEBROOT
-root = hunt_file(hunt, "")
-try:
- os.mkdir(root)
-except FileExistsError:
- # We're happy as a clam if the directory already exists
- pass
-
-overview(hunt, puzzles, rounds)
-for rnd in rounds:
- round_overview(hunt, rnd, puzzles)
-for puzzle in puzzles:
- puzzle_overview(hunt, puzzle)
-puzzle_lists(hunt, puzzles, "All")
-puzzle_lists(hunt, puzzles, "Solved")
-puzzle_lists(hunt, puzzles, "Unsolved")
+
+def usage():
+ print("Usage: {} hunt_id [...]")
+ print("")
+ print("Generates pages (under {}) ".format(WEBROOT))
+ print("for the specified hunt_id(s).")
+
+if len(sys.argv) < 2:
+ usage()
+ sys.exit(1)
+
+for hunt_id in sys.argv[1:]:
+ generate_for_hunt_id(table, hunt_id)