1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-09-05 17:30:01 +00:00

Specify utf8 encoding in generated seahub_settings.py

This commit is contained in:
Shuai Lin
2017-01-07 11:17:38 +08:00
parent ef8fa4a309
commit 902a205f93
2 changed files with 20 additions and 11 deletions

View File

@@ -988,22 +988,29 @@ class SeahubConfigurator(AbstractConfigurator):
def ask_questions(self):
pass
# self.ask_admin_email()
# self.ask_admin_password()
def generate(self):
'''Generating seahub_settings.py'''
print 'Generating seahub configuration ...\n'
time.sleep(1)
self.write_secret_key()
with open(self.seahub_settings_py, 'a') as fp:
with open(self.seahub_settings_py, 'w') as fp:
self.write_utf8_comment(fp)
fp.write('\n')
self.write_secret_key(fp)
fp.write('\n')
self.write_database_config(fp)
def write_secret_key(self):
Utils.run_argv([Utils.get_python_executable(),
os.path.join(env_mgr.install_path, 'seahub',
'tools', 'secret_key_generator.py'),
self.seahub_settings_py])
def write_utf8_comment(self, fp):
fp.write('# -*- coding: utf-8 -*-')
def write_secret_key(self, fp):
script = os.path.join(env_mgr.install_path, 'seahub/tools/secret_key_generator.py')
cmd = [
Utils.get_python_executable(),
script,
]
key = Utils.get_command_output(cmd).strip()
fp.write('SECRET_KEY = "%s"' % key)
def write_database_config(self, fp):
template = '''\