def test_basic_config(self): os.environ["ENVVAR"] = "Environment Variable Value" config = Configuration() self.assertEqual(config("ENVVAR"), "Environment Variable Value") self.assertEqual(config("ENVFILE"), "Environment File Value") self.assertEqual(config("INIFILE"), "INI File Value") self.assertEqual(len(config.configurations), 3) # envvar + .env + settings.ini
def test_from_import_basic_config(self): from prettyconf import config os.environ["ENVVAR"] = "Environment Variable Value" self.assertEqual(config("ENVVAR"), "Environment Variable Value") self.assertEqual(config("ENVFILE"), "Environment File Value") self.assertEqual(config("INIFILE"), "INI File Value") self.assertEqual(len(config.configurations), 3) # envvar + .env + settings.ini
def test_basic_config_with_starting_path(self): os.environ["ENVVAR"] = "Environment Variable Value" starting_path = os.path.dirname(__file__) config = Configuration(starting_path=starting_path) self.assertEqual(config("ENVVAR"), "Environment Variable Value") self.assertEqual(config("ENVFILE"), "Environment File Value") self.assertEqual(config("INIFILE"), "INI File Value") self.assertEqual(len(config.configurations), 3) # envvar + .env + settings.ini
def test_basic_config(self): os.environ["ENVVAR"] = "Environment Variable Value" config = Configuration() self.assertTrue(repr(config).startswith("Configuration(loaders=[")) self.assertEqual(config("ENVVAR"), "Environment Variable Value") self.assertEqual(config("ENVFILE"), "Environment File Value") self.assertEqual(config("INIFILE"), "INI File Value") self.assertEqual(len(config.loaders), 2) # Environment + RecursiveSearch del os.environ["ENVVAR"]
def test_customized_loaders(self): os.environ["ENVVAR"] = "Environment Variable Value" os.environ["ENVVAR2"] = "Foo" loaders = [EnvFile(self.envfile), Environment(), IniFile(self.inifile)] config = Configuration(loaders=loaders) self.assertEqual(config("ENVVAR"), "Must be overrided") self.assertEqual(config("ENVVAR2"), "Foo") self.assertEqual(config("ENVFILE"), "Environment File Value") self.assertEqual(config("INIFILE"), "INI File Value") self.assertEqual(len(config.loaders), 3) del os.environ["ENVVAR"] del os.environ["ENVVAR2"]
def __init__(self, expectation, host=None, port=None, docker=False): form = MockForm(data=expectation) if not form.validate(): raise ValidationError(form.errors) self.expectation = expectation self.host = host or config("ECHOD_API_HOST", default="127.0.0.1") self.port = port or config("ECHOD_API_PORT", default=9876) self.base_url = "http://{}:{}".format(self.host, self.port) self._session = requests.Session() self._urls = { "health": url_path_join(self.base_url, "health", "/"), "mocks": url_path_join(self.base_url, "mocks", "/"), "response": None, } self.mock_url = None
def main(): unix_path = config('CURYTYBAINBOX_UNIX_PATH', default='/var/run/curytybainbox') b = box.BoxProcess(unix_path) b.start() try: b.join() except KeyboardInterrupt: pass finally: b.stop() b.terminate() sys.exit(0)
def start(loop, api_host='127.0.0.1', api_port=9876): app = web.Application(loop=loop) app['mock_db'] = {} redis_address = (config('ECHOD_REDIS_HOST', default='127.0.0.1'), config('ECHOD_REDIS_PORT', default=6379)) redis_db = int(config('ECHOD_REDIS_DB', default=0)) redis_pool = yield from aioredis.create_pool(redis_address, db=redis_db, minsize=5, maxsize=10, encoding='utf-8', loop=loop) app['redis_pool'] = redis_pool # Mock app.router.add_route('GET', '/mocks/', get_mock) app.router.add_route('PUT', '/mocks/', put_mock) # Proxies app.router.add_route('GET', '/proxies/', get_proxy) app.router.add_route('PUT', '/proxies/', put_proxy) # Callbacks app.router.add_route('*', '/callbacks/{app}/{queue}/', callback) app.router.add_route('GET', '/callbacks/_all/{app}/{queue}/', all_callback) app.router.add_route('GET', '/callbacks/_first/{app}/{queue}/', first_callback) app.router.add_route('GET', '/callbacks/_last/{app}/{queue}/', last_callback) app.router.add_route('GET', '/callbacks/_clean/{app}/{queue}/', clean_callback) # Health app.router.add_route('GET', '/health/', health) handler = app.make_handler() server = yield from loop.create_server(handler, api_host, api_port) address = server.sockets[0].getsockname() log.info('API started at http://{}:{}/'.format(*address)) return server, handler, redis_pool
from prettyconf import config, casts try: from django.conf import settings as django_settings except ImportError: django_settings = None ENVIRONMENT = getattr(django_settings, 'ENVIRONMENT', config('ENVIRONMENT', default='develop')) DEBUG = getattr(django_settings, 'DEBUG', config('DEBUG', default=True, cast=casts.Boolean())) JANGL_EPOCH = getattr(django_settings, 'JANGL_EPOCH', config('JANGL_EPOCH', default=1420070400)) CID_HEADER_NAME = getattr(django_settings, 'CID_HEADER_NAME', config('CID_HEADER_NAME', default='X-CID')) SITE_ID_HEADER_NAME = getattr(django_settings, 'SITE_ID_HEADER_NAME', config('SITE_ID_HEADER_NAME', default='X-Site-ID')) SERVICES_BACKEND_HOST = getattr(django_settings, 'SERVICES_BACKEND_HOST', config('PRODUCTION_BACKEND_HOST', default=config('HOST', default='localhost'))) SERVICES_BACKEND_PORT = getattr(django_settings, 'SERVICES_BACKEND_PORT', config('PRODUCTION_BACKEND_PORT', default='8008')) # Deprecated, use enable DISABLE_BACKEND_API_CACHE = getattr(django_settings, 'DISABLE_BACKEND_API_CACHE', config('DISABLE_BACKEND_API_CACHE', default=False, cast=casts.Boolean())) ENABLE_BACKEND_API_CACHE = getattr(django_settings, 'ENABLE_BACKEND_API_CACHE', config('ENABLE_BACKEND_API_CACHE', default=(not DISABLE_BACKEND_API_CACHE), cast=casts.Boolean())) USE_NEW_BACKEND_API = getattr(django_settings, 'USE_NEW_BACKEND_API',
import os from dj_database_url import parse as parse_db_url from prettyconf import config PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=bool) ALLOWED_HOSTS = ['*'] EMAIL_BACKEND = "sgbackend.SendGridBackend" SENDGRID_API_KEY = config('SENDGRID_API_KEY') # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'ong.apps.OngConfig', ]
from prettyconf import config import dj_database_url from workatolist.settings.base import * DEBUG = False ALLOWED_HOSTS = ['work-at-list.herokuapp.com'] DATABASES = { 'default': dj_database_url.parse(config('DATABASE_URL')) } STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
def test_config_cast_value(self): os.environ["INTEGER"] = "42" config = Configuration() self.assertEqual(config("INTEGER", cast=int), 42)
def test_fail_unknown_config_without_default_value(self): os.environ["ENVVAR"] = "Environment Variable Value" config = Configuration() with self.assertRaises(UnknownConfiguration): config("UNKNOWN")
"""Environment variables.""" import os from typing import List # noqa from prettyconf import config from c**t.config import cast_to_directory_list config.starting_path = os.path.expanduser("~/.config/c**t") RSYNC_EXCLUDE = config( "RSYNC_EXCLUDE", cast=config.list, default="lost+found/,.dropbox.cache,.Trash-*,.DS_Store" ) # type: List[str] BACKUP_DIRS = config("BACKUP_DIRS", cast=cast_to_directory_list()) # type: List[str] PICTURE_DIRS = config("PICTURE_DIRS", cast=cast_to_directory_list()) # type: List[str]
from prettyconf import config DEFAULT_FILE_STORAGE = 'jangl_utils.s3_storage.MediaRootS3BotoStorage' STATICFILES_STORAGE = 'jangl_utils.s3_storage.StaticRootS3BotoStorage' AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME') AWS_QUERYSTRING_AUTH = False STORAGE_DOMAIN = config('STORAGE_DOMAIN', default='https://{0}.s3.amazonaws.com'.format(AWS_STORAGE_BUCKET_NAME))
from mongoengine import connect from prettyconf import config from dj_database_url import parse as db_url # Build paths inside the project like this: os.path.join(ROOT_DIR, ...) ROOT_DIR = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) APPS_DIR = os.path.join(ROOT_DIR, 'procapi') CSV_INITIAL_DATA_PATH = os.path.join(ROOT_DIR, 'initial_data_csv') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=config.boolean) ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=config.list) # Application definition DJANGO_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
from decimal import Decimal from django.conf import settings from prettyconf import config # Tells to Django where it is the configuration class of this module default_app_config = 'apps.investment.apps.Config' # Credit line config settings.LOAN_INTEREST_PERCENT = config('LOAN_INTEREST_PERCENT', cast=Decimal, default=Decimal('30')) settings.OVERDRAFT_INTEREST_PERCENT = config('LOAN_INTEREST_PERCENT', cast=Decimal, default=Decimal('10'))
For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=True, cast=config.boolean) ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'library-testapi.herokuapp.com'] # Application definition DJANGO_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles' ] LOCAL_APPS = ["my_api", "library"]
import os import dj_database_url import django_heroku from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config( 'SECRET_KEY', default="q!sb&ef3zbuk*y63u%^u$rkil!ar06g3yu%nu5fx2rr#1+x@ib") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=config.boolean) # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', # Disable Django's own staticfiles handling in favour of WhiteNoise, for # greater consistency between gunicorn and `./manage.py runserver`. See: # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from prettyconf import config BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'iwk$bwy9i3!5u-m0*2so^_=zu5)a6orbp0w!&moq*mi2+ypo-&' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=True, cast=config.boolean) ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'finder') MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
# -*- coding: utf-8 -*- from __future__ import unicode_literals import os from prettyconf import config import dj_database_url import dj_email_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=config.boolean) ALLOWED_HOSTS = [ '*', ] # Application definition INSTALLED_APPS = [ # django core 'django.contrib.admin', 'django.contrib.auth',
"""Configs for briefy.ws.""" from prettyconf import config # JWT JWT_EXPIRATION = config('JWT_EXPIRATION', default='84600') JWT_SECRET = config('JWT_SECRET', default='e68d4ffb-d621-4d17-a33e-00183e9553e1') # USER SERVICE USER_SERVICE_BASE = config( 'USER_SERVICE_BASE', default='http://briefy-rolleiflex.briefy-rolleiflex/internal' ) USER_SERVICE_TIMEOUT = config( 'USER_SERVICE_TIMEOUT', default=24 * 60 # 24 hours )
#!/bin/env python3 # coding: utf-8 import sys import logging import multiprocessing from prettyconf import config from curytybainbox import box debug = config('CURYTYBAINBOX_DEBUG', default=False, cast=config.boolean) log = logging.getLogger('curytybainbox') if debug: log.addHandler(logging.StreamHandler(sys.stdout)) log.setLevel(logging.INFO) multiprocessing.log_to_stderr(logging.DEBUG) def main(): unix_path = config('CURYTYBAINBOX_UNIX_PATH', default='/var/run/curytybainbox') b = box.BoxProcess(unix_path) b.start() try: b.join() except KeyboardInterrupt: pass finally: b.stop()
import os from dj_database_url import parse as parse_db_url from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) config.root_path = os.path.realpath(os.path.join(BASE_DIR, '..')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=False, cast=config.boolean) ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=config.list) # Application definition INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mptt',
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.9/ref/settings/ """ import os import redis from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY', default='mysupersecret') # SECURITY WARNING: don"t run with debug turned on in production! DEBUG = config('DEBUG', default=True) ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=config.list, default='localhost, 127.0.0.1') # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "bootstrapform", "app"
from rest_framework.views import APIView from rest_framework import permissions from django.http import JsonResponse from drf_yasg import openapi from drf_yasg.utils import swagger_auto_schema from apps.devices.models import Device from pymongo import MongoClient, DESCENDING, ASCENDING from prettyconf import config from datetime import datetime, timedelta MONGO_URI = config('MONGO_URI', default='mongodb://localhost:27017/') client = MongoClient(MONGO_URI) packages = client.mes.packages packages.create_index([('device_id', DESCENDING), ('time', ASCENDING), ('type', DESCENDING)]) PACKAGE_TYPES = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] class CardsView(APIView): """ Returns data to fill cards """ permission_classes = (permissions.IsAuthenticated, ) def device_info(self, device): def get_active_types():
https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os from dj_database_url import parse as parse_db_url from prettyconf import config BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ SECRET_KEY = config('SECRET_KEY', default='secret_key') DEBUG = config('DEBUG', default=True, cast=config.boolean) ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config("SECRET") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=False, cast=bool) ALLOWED_HOSTS = config("ALLOWED_HOSTS") # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles",
async def channel_publish(): await Tortoise.init(db_url=config("DATABASE_URL"), modules={"models": ["ninegag.models"]}) headers = { "Accept": "application/json, text/plain, */*", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3", "Cache-Control": "max-age=0", "Connection": "keep-alive", "DNT": "1", "Host": "9gag.com", "Referer": "https://9gag.com/", "TE": "Trailers", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:73.0) Gecko/20100101 Firefox/73.0", } cookies = { "__cfduid": COOKIE_ID, "____ri": "6195", "____lo": "US", "gag_tz": "-3" } async with aiohttp.ClientSession(headers=headers, cookies=cookies) as session: url = "https://9gag.com/v1/group-posts/group/default/type/hot" async with session.get(url) as resp: response = await resp.json() posts = response["data"]["posts"] for post in posts: section, _ = await Section.get_or_create( name=post["postSection"]["name"], slug=post["postSection"]["url"].split("/")[-1], ) post_obj, created = await Post.get_or_create( id=post["id"], url=post["url"], file_url=get_file_url(post), title=post["title"], section=section, post_type=post["type"], has_audio=bool(post["type"] == "Animated" and post["images"]["image460sv"]["hasAudio"]), tags=",".join(tag["url"].split("/tag/")[1] for tag in post["tags"]), ) if not created: continue if section.name == "Promoted": continue params = { "chat_id": CHAT_ID, "caption": await post_obj.caption(), "parse_mode": types.ParseMode.HTML, } if post_obj.is_photo(): send_method = bot.send_photo params["photo"] = post_obj.file_url elif post_obj.is_gif(): send_method = bot.send_animation params["animation"] = post_obj.file_url elif post_obj.is_video(): send_method = bot.send_video params["video"] = post_obj.file_url await send_method(**params) await Tortoise.close_connections()
def base_url(): host = config('UPSTREAM_IP', default='127.0.0.1') port = config('UPSTREAM_PORT', default='8080') return f'http://{host}:{port}'
def test_config_default_values(self): config = Configuration() self.assertEqual(config("DEFAULT", default="Default Value"), "Default Value")
USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 100 } # Game Options MAX_ROUNDS_PER_BATTLE = config('MAX_ROUNDS_PER_BATTLE', cast=config.eval) MAX_NUMBER_OF_PLAYERS = config('MAX_NUMBER_OF_PLAYERS', cast=config.eval) NUMBER_OF_INITIAL_CARDS = config('NUMBER_OF_INITIAL_CARDS', cast=config.eval) NUMBER_OF_CARDS_PER_DECK = config('NUMBER_OF_CARDS_PER_DECK', cast=config.eval)
def test_fail_invalid_cast_type(self): os.environ["INTEGER"] = "42" config = Configuration() with self.assertRaises(InvalidConfigurationCast): config("INTEGER", cast="not callable")
from dj_database_url import parse as parse_db_url from dj_email_url import parse as parse_email_url from django.contrib.messages import constants as message_constants from prettyconf import config from quickstartup import settings_utils from django.utils.translation import ugettext_lazy as _ BASE_DIR = Path(__file__).absolute().parents[2] PROJECT_DIR = Path(__file__).absolute().parents[1] FRONTEND_DIR = PROJECT_DIR / "frontend" # Project Info QS_PROJECT_NAME = "Django Quickstartup" QS_PROJECT_DOMAIN = config("PROJECT_DOMAIN") QS_PROJECT_CONTACT = "contact@{}".format(QS_PROJECT_DOMAIN) QS_PROJECT_URL = "http://{}".format(QS_PROJECT_DOMAIN) # Debug & Development DEBUG = config("DEBUG", default=False, cast=config.boolean) # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
def test_none_as_default_value(self): config = Configuration() self.assertIsNone(config("UNKNOWN", default=None))
import os import django_heroku from dj_database_url import parse as parse_db_url from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=False, cast=config.boolean) ALLOWED_HOSTS = config("ALLOWED_HOSTS", default="*", cast=config.list) SECRET_KEY = config("SECRET_KEY") # Application definition LOCAL_APPS = [ 'apps.hospitals', ] DJANGO_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
""" WSGI config for workatolist project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application from prettyconf import config from whitenoise.django import DjangoWhiteNoise settings = config('SETTINGS', default='workatolist.settings.heroku') os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings) application = get_wsgi_application() application = DjangoWhiteNoise(application)
from prettyconf import config TELEGRAM_BOT_TOKEN = config('TELEGRAM_BOT_TOKEN') GROUPS_FILENAME = config('GROUPS_FILENAME', default='groups.dat') FLASK_APP = config('FLASK_APP') FLASK_ENV = config('FLASK_ENV') AUTH_TOKEN = config('AUTH_TOKEN') PRODUCTION_HOST = config('PRODUCTION_HOST')
from prettyconf import config # absolute path to the supervisord pid file SUPERVISOR_PID_FILE = config( 'SUPERVISOR_PID_FILE', default='/var/run/supervisord.pid' ) SENDGRID_APIKEY = config('SENDGRID_APIKEY') SENDGRID_FROM_EMAIL = config('SENDGRID_FROM_EMAIL') SENDGRID_FROM_NAME = config('SENDGRID_FROM_NAME') TO_EMAIL_ADDRESS = config('TO_EMAIL_ADDRESS')
class Settings: LOG_LEVEL = config("LOG_LEVEL", default="INFO") LOGGERS = config("LOGGERS", default="", cast=config.list) WAIT_TIME_SECONDS = config("WAIT_TIME_SECONDS", default="5", cast=config.eval) AWS_DEFAULT_REGION = config("AWS_DEFAULT_REGION") AWS_ACCESS_KEY_ID = config("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = config("AWS_SECRET_ACCESS_KEY") AWS_ENDPOINT_URL = config("AWS_ENDPOINT_URL", default=None) TEAMS_MATCH_CREATED_QUEUE = config("TEAMS_MATCH_CREATED_QUEUE") PLAYERS_MATCH_CREATED_QUEUE = config("PLAYERS_MATCH_CREATED_QUEUE") TEAMS_API_URL = config("TEAMS_API_URL") PLAYERS_API_URL = config("PLAYERS_API_URL")
#!/bin/env python3 # coding: utf-8 import sys import logging import multiprocessing from prettyconf import config from curytybainbox import web debug = config('CURYTYBAINBOX_DEBUG', default=False, cast=config.boolean) log = logging.getLogger('curytybainbox') if debug: log.addHandler(logging.StreamHandler(sys.stdout)) log.setLevel(logging.INFO) multiprocessing.log_to_stderr(logging.DEBUG) host = config('CURYTYBAINBOX_WEB_HOST', default='127.0.0.1') port = int(config('CURYTYBAINBOX_WEB_PORT', default=9876)) secret_key = config('CURYTYBAINBOX_SECRETY_KEY', default='super_secret_key') def main(): web.app.config['DEBUG'] = debug web.app.config['SECRET_KEY'] = secret_key web.app.run(host=host, port=port, processes=5) # threaded=True sys.exit(0)
# -*- coding: utf-8 -*- """Init and utils.""" from prettyconf import config from zope.i18nmessageid import MessageFactory _ = MessageFactory("contentrules.slack") SLACK_WEBHOOK_URL = config("SLACK_WEBHOOK_URL", default="")
""" Django settings for {{ project_name }} project. """ from os.path import join, dirname, abspath from prettyconf import config, casts import dj_database_url import pytz BASE_DIR = dirname(dirname(abspath(__file__))) # Development Settings as Defaults DEBUG = config('DEBUG', default=True, cast=casts.Boolean) SECRET_KEY = config('SECRET_KEY', default='{{ secret_key }}') DEFAULT_HOST = ['*'] if DEBUG else None DEFAULT_DB = 'sqlite:///'+join(BASE_DIR, 'db.sqlite3') ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=DEFAULT_HOST, cast=casts.List) DATABASE_URL = config('DATABASE_URL', default=DEFAULT_DB) # Internationalization LANGUAGE_CODE = config('LANGUAGE_CODE', default='en-us') TIME_ZONE = config('TIME_ZONE', default='UTC') USE_I18N = True USE_L10N = True USE_TZ = True US_TIMEZONES = (
from dj_database_url import parse as parse_db_url from dj_email_url import parse as parse_email_url from django.contrib.messages import constants as message_constants from prettyconf import config from quickstartup import settings_utils # Project Structure BASE_DIR = Path(__file__).absolute().parents[2] PROJECT_DIR = Path(__file__).absolute().parents[1] FRONTEND_DIR = PROJECT_DIR / "frontend" # Project Info QS_PROJECT_NAME = "Django Quickstartup" QS_PROJECT_DOMAIN = config("PROJECT_DOMAIN") QS_PROJECT_CONTACT = "contact@{}".format(QS_PROJECT_DOMAIN) QS_PROJECT_URL = "http://{}".format(QS_PROJECT_DOMAIN) # Debug & Development DEBUG = config("DEBUG", default=False, cast=config.boolean) # Database DATABASES = { 'default': config('DATABASE_URL', cast=parse_db_url), } DATABASES['default']['CONN_MAX_AGE'] = None # always connected
import os from prettyconf import config BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'iwk$bwy9i3!5u-m0*2so^_=zu5)a6orbp0w!&moq*mi2+ypo-&' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config("DEBUG", default=True, cast=config.boolean) ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'finder'
from unipath import Path from dj_database_url import parse as parse_db_url from django_cache_url import parse as parse_cache_url from prettyconf import config # Project Structure BASE_DIR = Path(__file__).ancestor(3) PROJECT_DIR = Path(__file__).ancestor(2) FRONTEND_DIR = PROJECT_DIR.child("frontend") # Debug & Development DEBUG = config('DEBUG', default=False, cast=config.boolean) # Database DATABASES = { 'default': config( 'DATABASE_URL', cast=parse_db_url, default='sqlite:///db.sqlite3' ), } DATABASES['default']['CONN_MAX_AGE'] = config('CONN_MAX_AGE', cast=config.eval, default='None') # always connected DATABASES['default']['TEST'] = {'NAME': config('TEST_DATABASE_NAME', default=None)} # Security & Signup/Signin ADMIN_USERNAME = config('ADMIN_USERNAME', default='ADMIN') ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='*', cast=config.list) SECRET_KEY = config('SECRET_KEY', default='example-kn59*npHxq)G#p7VkwfZCb)RgtUWaJjfDBrEYJ6fEk9Sj$(d)Q#uZ6U##')
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don"t run with debug turned on in production! DEBUG = config('DEBUG', default='False', cast=config.boolean) ALLOWED_HOSTS = config( 'ALLOWED_HOSTS', default='127.0.0.1, localhost', cast=config.list ) # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth",
from prettyconf import config DEFAULT_FILE_STORAGE = 'jangl_utils.s3_storage.MediaRootS3BotoStorage' STATICFILES_STORAGE = 'jangl_utils.s3_storage.StaticRootS3BotoStorage' AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET_NAME') AWS_QUERYSTRING_AUTH = False STORAGE_DOMAIN = config( 'STORAGE_DOMAIN', default='https://{0}.s3.amazonaws.com'.format(AWS_STORAGE_BUCKET_NAME))
https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os from prettyconf import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config( 'SECRET_KEY', default="Don't forget to set this in a .env file." ) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', cast=config.boolean, default=True) ALLOWED_HOSTS = config( 'ALLOWED_HOSTS', cast=config.list, default='localhost, 127.0.0.1', ) # Application definition INSTALLED_APPS = [
from prettyconf import config PUBLIC_KEY = config('ILOVEPDF_PUBLIC_KEY') SECRET_KEY = config('ILOVEPDF_SECRET_KEY')
def test_fail_invalid_cast_type(self): os.environ["INTEGER"] = "42" config = Configuration() with self.assertRaises(TypeError): config("INTEGER", cast="not callable")
'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'health.wsgi.application' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases DATABASES = { 'default': config('DATABASE_URL', cast=parse_db_url), } # Password validation # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, {
import logging import aiohttp from aiogram import Bot, types from aiogram.dispatcher import Dispatcher from prettyconf import config from tortoise import Tortoise from ninegag.api import get_file_url from ninegag.models import Post, Section BOT_TOKEN = config("BOT_TOKEN") CHAT_ID = config("CHAT_ID") COOKIE_ID = config("COOKIE_ID") bot = Bot(token=BOT_TOKEN) dp = Dispatcher(bot) logger = logging.getLogger(__name__) async def channel_publish(): await Tortoise.init(db_url=config("DATABASE_URL"), modules={"models": ["ninegag.models"]}) headers = { "Accept": "application/json, text/plain, */*", "Accept-Encoding": "gzip, deflate, br", "Accept-Language":
For the full list of settings and their values, see https://docs.djangoproject.com/en/1.9/ref/settings/ """ import os from pathlib import Path from prettyconf import config from dj_database_url import parse as parse_db_url from django_cache_url import parse as parse_cache_url # Project Structure BASE_DIR = Path(__file__).absolute().parents[2] PROJECT_DIR = Path(__file__).absolute().parents[1] PROJECT_DOMAIN = config('PROJECT_DOMAIN') # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='*', cast=config.list) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = config('DEBUG', default=False, cast=config.boolean)
import sys import socket import logging from prettyconf import config from flask import Flask from flask import (redirect, url_for, render_template, flash) app = Flask(__name__) log = logging.getLogger('curytybainbox') unix_path = config('CURYTYBAINBOX_UNIX_PATH', default='/var/run/curytybainbox') client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) try: client.connect(unix_path) except socket.error: print('Can not connect to curytybainbox daemon.\nStart it using: curytybainboxd') sys.exit(1) def send_command(command): try: client.send(command) except socket.error: flash('Error sending command: "{}", check if "curytybainboxd" process is running.'.format(command), 'bg-danger')