-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreeze.py
133 lines (96 loc) · 3.48 KB
/
freeze.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Run this script to produce a frozen version of Evennia that can run Avenew
# You must be in the Virtual Environment (with evennia installed) to run this.
import os
import shutil
import sys
from textwrap import dedent
try:
import evennia
except ImportError:
print "evennia cannot be found on this Python path. You should run this script from a Python environment where evennia is installed."
sys.exit(1)
# Try to freeze evennia
print "Trying to freeze Evennia version", evennia.__version__, "with cx_Freeze"
# Have to change directory to freeze
os.chdir("../evennia")
status = os.system("python freeze.py build")
print "Finished building avenew.exe and twistd.exe with status", status
os.chdir("../avenew")
if os.path.exists("avenew"):
shutil.rmtree("avenew")
print "Cloning the source code from Github..."
os.system("git clone -b fr https://github.com/vincent-lg/Avenew avenew")
print "Placing the frozen executables in the frozen folder."
shutil.copytree("../evennia/dist", "avenew/dist")
if os.path.exists("avenew/server/evennia.db3"):
print "Removing the database."
os.remove("avenew/server/evennia.db3")
# Change directory to frozen
os.chdir("avenew")
# Override a few sensitive files
print "Overriding settings..."
with open("server/conf/secret_settings.py", "w") as file:
file.write(dedent('''
# -*- coding: utf-8 -*-
"""Scret settings."""
SECRET_KEY = 'bjqsznek!jj$m-5z9az)b)21(n)to3iu1vo)!rqlr@i5wf#-ki'
# Enable DEBUG
DEBUG = True
TEST_SESSION = True
# Protocols
IRC_ENABLED = False
SSL_ENABLED = False
# Email configuration
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
DEFAULT_FROM_EMAIL = "[email protected]"
DNS_NAME = "avenew.one"
ANYMAIL = {}
# Outgoing email aliases
OUTGOING_ALIASES = {}
# Language options
USE_I18N = True
LANGUAGE_CODE = 'fr'
ENCODINGS = ["latin-1", "utf-8", "ISO-8859-1"]
''').strip())
if os.path.exists("server/conf/secret_settings.pyc"):
os.remove("server/conf/secret_settings.pyc")
with open("server/conf/secret_at_initial_setup.py", "w") as file:
file.write(dedent('''
# -*- coding: utf-8 -*-
"""
secret_At_initial_setup module template
Secret at_initial_setup method.
"""
from django.conf import settings
from evennia import ChannelDB, ObjectDB
from evennia.utils import create
def secret_setup():
pass
''').strip())
if os.path.exists("server/conf/secret_at_initial_setup.pyc"):
os.remove("server/conf/secret_at_initial_setup.pyc")
if os.path.exists("server/ssl.cert"):
os.remove("server/ssl.cert")
if os.path.exists("server/ssl.key"):
os.remove("server/ssl.key")
# Removing log files
if not os.path.exists("server/logs"):
os.mkdir("server/logs")
for name in os.listdir("server/logs"):
os.remove("server/logs/" + name)
if not os.path.exists("world/areas"):
os.mkdir("world/areas")
for name in os.listdir("world/areas"):
os.remove("world/areas/" + name)
print "Run migrations..."
os.system("evennia migrate")
# Redirect stdin
os.system("evennia createsuperuser")
# Create simple batch files
with open("start.bat", "w") as file:
file.write(r"cmd /k dist\avenew.exe start")
with open("stop.bat", "w") as file:
file.write(r"cmd /k dist\avenew.exe stop")
with open("avenew.bat", "w") as file:
file.write(r"cmd /k dist\avenew.exe %*")
os.chdir("..")