Esempio n. 1
0
def load_provinces_and_cities(file_path):
    from os import path
    from collections import OrderedDict
    import codecs

    utf8reader = codecs.getreader('utf-8')

    with utf8reader(open(path.join(pmc_config.get_project_root(),
                                   file_path))) as fin:
        provinces = OrderedDict()
        cities = OrderedDict()
        for line in fin:
            province, province_code, city, city_code = line.strip().split('\t')
            provinces.setdefault(province_code, province)
            cities_in_current_province = cities.setdefault(
                province_code, OrderedDict())
            cities_in_current_province.setdefault(city_code, city)
    return provinces, cities
Esempio n. 2
0
from pytoolbox.util.pmc_config import get_project_root
import os
from datetime import timedelta

root = get_project_root()


class App:
    NAME = 'cs'

    TESTING = False
    DEBUG = True

    SECRET_KEY = os.getenv('SECRET_KEY') or '.yek tset'

    # sqlalchemy
    SQLALCHEMY_DATABASE_URI = 'postgresql://*****:*****@localhost/cs_dev'
    SQLALCHEMY_POOL_SIZE = 30
    SQLALCHEMY_ECHO = not (os.environ.get('DISABLE_SQLALCHEMY_ECHO', False) or os.environ.get('CELERY_RUNNING', False))
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # cache
    CACHE = {
        'CACHE_TYPE': 'redis',
        'CACHE_KEY_PREFIX': NAME + '_',
        'CACHE_REDIS_URL': 'redis://127.0.0.1:6379/13'
    }

    # jwt
    JWT_AUTH_HEADER = 'X-ANY-JWT'
    JWT_AUTH_HEADER_PATTERN = 'X-%s-JWT'
Esempio n. 3
0
# coding=utf-8
import os
from pytoolbox.util.pmc_config import register_config, get_project_root

PROJECT_ROOT = get_project_root(target='src')


def load_config(env):
    register_config(__name__, 'settings', env=env)


load_config(os.getenv('ENV', 'default'))

Esempio n. 4
0
# coding=utf-8
from pytoolbox.util.pmc_config import register_config, get_project_root

PROJECT_ROOT = get_project_root()


def load_config(env):
    register_config(__name__, 'zyt_pay', env=env)
    register_config(__name__, 'lianlian_pay', env=env)
    register_config(__name__, 'test_pay', env=env)
    register_config(__name__, 'weixin_pay', env=env)
    register_config(__name__, 'ali_pay', env=env)

    # business
    register_config(__name__, 'application', env=env)

    # etc
    register_config(__name__, 'etc', env=env)

    # celery
    register_config(__name__, 'api_celery_task', env=env)