import logging import os from os.path import abspath from os.path import dirname from os.path import join from os.path import pardir from kombu.utils.url import safequote from dotenv import load_dotenv # Load environment variables from a .env file dotenv_path = abspath(join(dirname(__file__), pardir, '.env')) load_dotenv(dotenv_path) # Values of all the environments. ENVIRONMENT_PROD = 'prod' ENVIRONMENT_DEV = 'dev' ENVIRONMENT_QA = 'qa' ENVIRONMENT = os.environ.get('Environment') or ENVIRONMENT_DEV AWS_REGION = os.environ.get('AWS_REGION') LOGGER_NAME = 'ows1' LOGGER_LEVEL = logging.INFO logging.getLogger('ddtrace').setLevel(logging.WARNING) SERVICE_NAME = 'ows-label-audit' SERVICE_VERSION = '0.0.1' HEALTH_CHECK = '/hello/' # Queue configuration # ------------------- # All queues are prefixed with the environment name (for policy settings) and # the name of the service (which allows to quickly identify unused pidbox). CELERY_QUEUE_PREFIX = '{}-ows-label-audit-'.format(ENVIRONMENT) LABEL_QUEUE = 'general' ASSET_SEARCH_QUEUE = 'search' AUDIT_GENERATION_QUEUE = 'generation' # OA # -- OA_URL = 'http://oa.theorchard.com' if ENVIRONMENT == ENVIRONMENT_QA: OA_URL = 'http://oa.qaorch.com' # Vapi configuration # ------------------ # Allow Label Audit to fetch data from vapi. VAPI_BASE_URL = os.environ.get('BASE_URL') VAPI_CLIENT_ID = os.environ.get('CLIENT_ID') VAPI_CLIENT_SECRET = os.environ.get('CLIENT_SECRET') VAPI_REDIRECT_URI = os.environ.get('REDIRECT_URI') VAPI_USER_ID = os.environ.get('USER_ID') VAPI_USER_TYPE = os.environ.get('USER_TYPE') # Batch size of reports to generate. Each report in the # batch is processed asynchronously. Currently anticipated # maximum volume is 250 reports spread over a year. AUDIT_GENERATION_BATCH_SIZE = 50 # Recommend 5 minutes (300 seconds) AUDIT_GENERATION_RUN_INTERVAL = os.environ.get('AUDIT_GENERATION_RUN_INTERVAL') CACHE_ENABLED = int(os.environ.get('CACHE_ENABLED') or 0) REDIS = os.environ.get('REDIS_HOST', '') # Email address for the Google API service account to be used GOOGLE_SERVICE_EMAIL = os.environ.get('GOOGLE_SERVICE_EMAIL') # Base file name of the P12 key for the service account GOOGLE_API_KEY_FILE = '{}_google_api_key.p12'.format(ENVIRONMENT) # Sentry: allows us to track effectively exceptions. SENTRY_DSN = os.environ.get('SENTRY_DSN') # During report generation, # of releases processed in a batch # Currently, stream buffers at this number as well. NUM_RELEASES_WRITE_CSV = 100 # Number of times to retry a task that retries on exception CELERY_MAX_RETRIES = 10 # Time to wait before retrying a task that retries on exception (in seconds) CELERY_RETRY_DELAY = 10 # S3 (Simple Storage Service) # For QA and Dev, we use a common bucket (which helps us not to reach the max # limit on the number of available buckets.) S3_BUCKET = 'prod-ows-label-audit' S3_BUCKET_ROOT = None if ENVIRONMENT in (ENVIRONMENT_DEV, ENVIRONMENT_QA): S3_BUCKET = '{}-orcdbucket'.format(ENVIRONMENT) S3_BUCKET_ROOT = 'ows-label-audit/' # Set up emails for audit report completion EMAIL_FROM_ADDRESS = 'donotreply@theorchard.com' # TODO replace qa address with one that Artur provides DEFAULT_EMAIL_TO_ADDRESS = 'vs.squad@theorchard.com' EMAIL_TO_ADDRESS = os.environ.get('EMAIL_TO_ADDRESS', DEFAULT_EMAIL_TO_ADDRESS) if ENVIRONMENT == ENVIRONMENT_PROD: EMAIL_TO_ADDRESS = 'ytprojects@theorchard.com' elif ENVIRONMENT == ENVIRONMENT_QA: EMAIL_TO_ADDRESS = DEFAULT_EMAIL_TO_ADDRESS AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') BROKER_URL = os.environ.get( 'BROKER_URL', 'sqs://{}:{}@'.format( safequote(AWS_ACCESS_KEY_ID), safequote(AWS_SECRET_ACCESS_KEY) ) if AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY else 'sqs://' ) assert BROKER_URL, 'BROKER_URL env var is missing'