1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-26 02:57:04 +00:00

utils.py can't import non-standard modules because it is imported by migrate.py, which is run before anything is installed

closes #540
This commit is contained in:
Joshua Tauberer 2015-08-30 13:50:34 -04:00
parent d19c215bf1
commit c5082498ab

View File

@ -1,5 +1,8 @@
import os.path import os.path
import rtyaml
# DO NOT import non-standard modules. This module is imported by
# migrate.py which runs on fresh machines before anything is installed
# besides Python.
# THE ENVIRONMENT FILE AT /etc/mailinabox.conf # THE ENVIRONMENT FILE AT /etc/mailinabox.conf
@ -22,11 +25,13 @@ def save_environment(env):
# THE SETTINGS FILE AT STORAGE_ROOT/settings.yaml. # THE SETTINGS FILE AT STORAGE_ROOT/settings.yaml.
def write_settings(config, env): def write_settings(config, env):
import rtyaml
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml') fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
with open(fn, "w") as f: with open(fn, "w") as f:
f.write(rtyaml.dump(config)) f.write(rtyaml.dump(config))
def load_settings(env): def load_settings(env):
import rtyaml
fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml') fn = os.path.join(env['STORAGE_ROOT'], 'settings.yaml')
try: try:
config = rtyaml.load(open(fn, "r")) config = rtyaml.load(open(fn, "r"))