-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplify.py
67 lines (51 loc) · 1.5 KB
/
simplify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
#coding: utf-8
import os
try:#io from right folder.
from config import WEBROOT
os.chdir(WEBROOT)
except:
pass
errormsg = dict(
missing_jammers_file="""
Ah hoy!, forgotten something Mrs/Mr?
-Missing 'jammers.csv'.
Make sure 'jammers.csv' is in the same folder
as this script and run again. This file contains
the information about your site's jammers.
Download it from your jamsite's global gamejam page.
Click the button [Download Jammer info]
at the bottom, beneath the list of jammers.
""",
missing_dependencies="""
Failed to import dependencies, (python modules this script uses).
You can install all dependencies by running these
commands in the terminal: (copy, paste, enter)
%s
"""%open('dependencies.txt').read()
)
def make_minimum_configuration():
"""
Generates the minimum required configuration to run
the web-interface out of the box
"""
SECRET_KEY = ''.join('%02x' % ord(x) for x in os.urandom(16))
with open("config.py", "w") as configfile:
configfile.write("SECRET_KEY='%s'\n"%SECRET_KEY)
def load_sources():
""" Will attempt to load sources from config,
returns default sources if config doesn't exist.
"""
try:
import config
sources = getattr(config, "sources", [dict(file='jammers.csv')])
except:
sources = [dict(file='jammers.csv')]
return sources
def load_extra():
""" Load extra field from config or give defualt False back if none"""
try:
import config
return getattr(config, "extra", False)
except:
return False