server creates dummy db for initial upload
This commit is contained in:
parent
6fe9ba59a7
commit
c06ebc29dc
2
overwrought_master.py
Normal file → Executable file
2
overwrought_master.py
Normal file → Executable file
|
@ -255,7 +255,7 @@ def post_pack():
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb')
|
files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb')
|
||||||
files[config_master.modpack_name + '.html'] = open(
|
files[config_master.modpack_name + '.html'] = open(
|
||||||
config_master.modpack_name, 'rb')
|
config_master.modpack_name +'.html', 'rb')
|
||||||
|
|
||||||
res = requests.post(
|
res = requests.post(
|
||||||
url=config_master.remote_addr + '/post',
|
url=config_master.remote_addr + '/post',
|
||||||
|
|
17
overwrought_server.py
Normal file → Executable file
17
overwrought_server.py
Normal file → Executable file
|
@ -2,6 +2,7 @@
|
||||||
"""
|
"""
|
||||||
The overwrought server, for exchanging mods from master to slave recipients.
|
The overwrought server, for exchanging mods from master to slave recipients.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import threading
|
import threading
|
||||||
|
@ -13,6 +14,22 @@ import config_server
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['db_lock'] = threading.Lock()
|
app.config['db_lock'] = threading.Lock()
|
||||||
|
os.makedirs('mods', exist_ok=True)
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""
|
||||||
|
If no database is found, a dummy database is created to allow the
|
||||||
|
initial modpack upload to go smoothly.
|
||||||
|
"""
|
||||||
|
con = sqlite3.connect('modpack.db')
|
||||||
|
cur = con.cursor()
|
||||||
|
try:
|
||||||
|
cur.execute("SELECT filename FROM mod").fetchone()
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
cur.execute("CREATE TABLE mod(filename TEXT)")
|
||||||
|
con.commit()
|
||||||
|
con.close()
|
||||||
|
init_db()
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user