import os import random import string def random_choices(population, k): """Emulate random.choices for Python < 3.6""" return [random.choice(population) for _ in range(k)] class Config: SECRET_KEY = os.environ.get('SECRET_KEY') or \ ''.join(random_choices(string.ascii_letters, k=20)) DATA_DIR = os.environ.get('DATA_DIR') or '/var/tmp/prolefeeder-test-data' OUT_DIR = os.environ.get('OUT_DIR') or '/var/tmp/prolefeeder-test-out' MAX_LENGTH = os.environ.get('MAX_LENGTH') or 180 KBITS = os.environ.get('KBITS') or 128 DEBUG = False if not os.path.exists(DATA_DIR): raise "DATA_DIR does not exist" if not os.path.exists(OUT_DIR): raise "OUT_DIR does not exist"