diff --git a/README.md b/README.md index 3f51425..476bb31 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,12 @@ The program queries the database `db/cts.db` (`./src/dbquery.c`, function `stati python scripts/allmaps.py -The CGI program is still invoked in static generation. The files `allmaps.py`, `output/leaderboard.css`, `template.html`, `template_map.html` help produce the output. +The CGI program is still invoked in static generation. The files `allmaps.py`, `output/leaderboard.css`, `overview.html`, `map.html` produce the output. Before executing `allmaps.py`, copy and modify the templates. - cp ./template-generic.html ./template.html - cp ./template_map-generic.html ./template_map.html + cp ./templates/overview.html ./overview.html + cp ./templates/map.html ./map.html `allmaps.py` outputs an html file for all distinct maps in the database. The leaderboards for each map (equivalent to `?map=[map name]`) are in `output/maps/`. @@ -47,6 +47,7 @@ Before executing `allmaps.py`, copy and modify the templates. ## Compilers * gcc (GCC) 10.2.1 * MinGW, GCC 4.7.1 + __________________ This program uses an sqlite3 database file created from `~/.xonotic/data/data/server.db`. diff --git a/scripts/allmaps.py b/scripts/allmaps.py index 9213484..b820402 100644 --- a/scripts/allmaps.py +++ b/scripts/allmaps.py @@ -1,5 +1,5 @@ import sqlite3 as sql -import subprocess +import subprocess, traceback # get all maps in database def getmaps(database): @@ -32,11 +32,11 @@ def renderindex(template): def main(): template = "" - with open("templates/overview.html", 'r') as fin: + with open("overview.html", 'r') as fin: template = fin.read() renderindex(template) maps = getmaps("db/cts.db") - with open("templates/map.html", 'r') as fin: + with open("map.html", 'r') as fin: template = fin.read() # for each map generate an html file. for game_map in maps: @@ -53,9 +53,15 @@ def main(): table=table) ) # fout.write(template % (title, map_name, table)) - pass + return True if __name__ == "__main__": - print("allmaps.py - Generating .html files for all maps.") - main() + success = False + try: + main() + except FileNotFoundError: + traceback.print_exc() + print("\n\t The script probably didn't find the page templates needed to generate a page. You can copy minimal working examples from the repository at templates/.") + if success: + print("allmaps.py - Generated pages for all maps.") pass