コード例 #1
0
ファイル: settings.py プロジェクト: vanyakosmos/userbot
import os
import re

import easy_env
from dotenv import find_dotenv, load_dotenv

load_dotenv(find_dotenv())

DEBUG = easy_env.get_bool('DEBUG', default=False)
USERBOT_NAME = easy_env.get('USERBOT_NAME', 'userbot')
REDIS_URL = easy_env.get_str('REDIS_URL')
API_ID = easy_env.get_int('API_ID', raise_error=True)
API_HASH = easy_env.get('API_HASH', raise_error=True)

USER_PHONE = easy_env.get('USER_PHONE')
USER_PASSWORD = easy_env.get('USER_PASSWORD')

NOU_LIST = easy_env.get_list('NOU_LIST', ['baka', 'idiot'], separator='|')
NOU_PATTERN = "|".join([f"\\b{w}\\b" for w in NOU_LIST])
NOU_PATTERN = f'.*({NOU_PATTERN}).*'
NOU_LIST_REGEX = re.compile(NOU_PATTERN, re.IGNORECASE)

NAME = easy_env.get('NAME', 'dude')
LOGS_FILE_PATH = easy_env.get('LOGS_FILE_PATH', 'logs.txt')
LOGS_FILE_DIR = os.path.split(LOGS_FILE_PATH)[0]
if LOGS_FILE_DIR:
    os.makedirs(LOGS_FILE_DIR, exist_ok=True)

LOGGING_LEVEL = easy_env.get('LOGGING_LEVEL', 'DEBUG')
LOGGING_LEVEL_ROOT = easy_env.get('LOGGING_LEVEL_ROOT', 'INFO')
コード例 #2
0
import logging
import multiprocessing
import os
from os.path import abspath, dirname, join

import dj_database_url
import easy_env
from dotenv import find_dotenv, load_dotenv


load_dotenv(find_dotenv())

BASE_DIR = dirname(dirname(abspath(__file__)))
SECRET_KEY = easy_env.get('SECRET_KEY', raise_error=True)
DEBUG = easy_env.get('DEBUG', default=False)
THIS_HOST = easy_env.get('THIS_HOST', 'http://0.0.0.0:8000')
ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'whitenoise.runserver_nostatic',  # whitenoise support in dev
    'django.contrib.staticfiles',
    # 3rd parties
    'solo.apps.SoloAppConfig',
    'rest_framework',
コード例 #3
0
 def test_get_list(self):
     os.environ['VALUE'] = '1,2,4'
     value = environ.get('VALUE', [], item_factory=int)
     self.assertEqual(value, [1, 2, 4])
コード例 #4
0
 def test_get_int_default(self):
     value = environ.get('VALUE', 1)
     self.assertEqual(value, 1)
コード例 #5
0
 def test_get_int(self):
     os.environ['VALUE'] = '5'
     value = environ.get('VALUE', 1)
     self.assertEqual(value, 5)
コード例 #6
0
 def test_without_default(self):
     os.environ['VALUE'] = '432'
     value = environ.get('VALUE')
     self.assertEqual(value, '432')
コード例 #7
0
 def test_bad_default(self):
     with self.assertRaises(ValueError):
         environ.get('VALUE', default=object())