made script consistent with readme

This commit is contained in:
scuti 2024-10-12 09:57:56 -07:00
parent 0ec0045301
commit bf18c0a9cc
2 changed files with 16 additions and 9 deletions

View File

@ -31,12 +31,12 @@ The program queries the database `db/cts.db` (`./src/dbquery.c`, function `stati
python scripts/allmaps.py 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. Before executing `allmaps.py`, copy and modify the templates.
cp ./template-generic.html ./template.html cp ./templates/overview.html ./overview.html
cp ./template_map-generic.html ./template_map.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/`. `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 ## Compilers
* gcc (GCC) 10.2.1 * gcc (GCC) 10.2.1
* MinGW, GCC 4.7.1 * MinGW, GCC 4.7.1
__________________ __________________
This program uses an sqlite3 database file created from `~/.xonotic/data/data/server.db`. This program uses an sqlite3 database file created from `~/.xonotic/data/data/server.db`.

View File

@ -1,5 +1,5 @@
import sqlite3 as sql import sqlite3 as sql
import subprocess import subprocess, traceback
# get all maps in database # get all maps in database
def getmaps(database): def getmaps(database):
@ -32,11 +32,11 @@ def renderindex(template):
def main(): def main():
template = "" template = ""
with open("templates/overview.html", 'r') as fin: with open("overview.html", 'r') as fin:
template = fin.read() template = fin.read()
renderindex(template) renderindex(template)
maps = getmaps("db/cts.db") maps = getmaps("db/cts.db")
with open("templates/map.html", 'r') as fin: with open("map.html", 'r') as fin:
template = fin.read() template = fin.read()
# for each map generate an html file. # for each map generate an html file.
for game_map in maps: for game_map in maps:
@ -53,9 +53,15 @@ def main():
table=table) table=table)
) )
# fout.write(template % (title, map_name, table)) # fout.write(template % (title, map_name, table))
pass return True
if __name__ == "__main__": if __name__ == "__main__":
print("allmaps.py - Generating .html files for all maps.") success = False
main() 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 pass