From 41e6be61e7e44e6ab3c4672b94fccd48ab58a1f2 Mon Sep 17 00:00:00 2001 From: - <-> Date: Tue, 8 Feb 2022 19:32:02 -0800 Subject: [PATCH] Created script to generate pages for all distinct maps --- allmaps.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 allmaps.py diff --git a/allmaps.py b/allmaps.py new file mode 100644 index 0000000..4a6db62 --- /dev/null +++ b/allmaps.py @@ -0,0 +1,62 @@ +import sqlite3 as sql +import subprocess + +def getmaps(database): + output = [] + con = sql.connect(database) + with con: + cursor = con.cursor() + try: + # get all maps in database + cursor.execute("select distinct mapid from Cts_times;") + output = cursor.fetchall() + except sql.Error: + print("Shit is fucked.") + return output + +# if there is no query then it outputs the index file. +def getcontent(query=None): + cmd = [("./cts")] + proc = subprocess.Popen(cmd, env=query, stdout=subprocess.PIPE, shell=True) + # communicate returns 'bytes' class with function 'decode' + return proc.communicate()[0].decode('utf-8') + +def renderindex(template): + # no env variable + table = getcontent() + title = "XDF Leaderboards - Xonotie" + filename = "./output/index.html" + header = '''
Server Name: /v/ Xonotie 0.8.2 - Pacific / US West
+ Stats: http://stats.xonotic.org/server/6459