"""
Production configuration for grading controller
"""
import json
import os

from .logsettings import get_logger_config
from .settings import *
import logging

######################################################################
#General config

DEBUG = True
TEMPLATE_DEBUG = False

######################################################################
#Read config from json file
with open(ENV_ROOT / "env.json") as env_file:
    ENV_TOKENS = json.load(env_file)

#General
REQUESTS_TIMEOUT=int(ENV_TOKENS.get('REQUESTS_TIMEOUT',5))
TIME_BETWEEN_XQUEUE_PULLS=int(ENV_TOKENS.get('TIME_BETWEEN_XQUEUE_PULLS',5))
TIME_BETWEEN_EXPIRED_CHECKS=int(ENV_TOKENS.get('TIME_BETWEEN_EXPIRED_CHECKS',1800))
GRADER_SETTINGS_DIRECTORY=ENV_TOKENS.get('GRADER_SETTINGS_DIRECTORY')
MAX_NUMBER_OF_TIMES_TO_RETRY_GRADING=int(ENV_TOKENS.get('MAX_NUMBER_OF_TIMES_TO_RETRY_GRADING'))

#ML
MIN_TO_USE_ML=int(ENV_TOKENS.get('MIN_TO_USE_ML',100))
ML_PATH=os.path.join(ENV_ROOT, ENV_TOKENS.get('ML_PATH'))
ML_MODEL_PATH=os.path.join(ENV_ROOT, ENV_TOKENS.get('ML_MODEL_PATH'))
TIME_BETWEEN_ML_CREATOR_CHECKS=int(ENV_TOKENS.get('TIME_BETWEEN_ML_CREATOR_CHECKS',3000))
TIME_BETWEEN_ML_GRADER_CHECKS=int(ENV_TOKENS.get('TIME_BETWEEN_ML_GRADER_CHECKS',5))

#Peer
MIN_TO_USE_PEER=int(ENV_TOKENS.get('MIN_TO_USE_PEER',20))
PEER_GRADER_COUNT=int(ENV_TOKENS.get('PEER_GRADER_COUNT',3))
PEER_GRADER_MINIMUM_TO_CALIBRATE=int(ENV_TOKENS.get("PEER_GRADER_MINIMUM_TO_CALIBRATE",3))
PEER_GRADER_MAXIMUM_TO_CALIBRATE=int(ENV_TOKENS.get("PEER_GRADER_MAXIMUM_TO_CALIBRATE",6))
PEER_GRADER_MIN_NORMALIZED_CALIBRATION_ERROR=float(ENV_TOKENS.get("PEER_GRADER_MIN_NORMALIZED_CALIBRATION_ERROR",.5))

#Submission Expiration
EXPIRE_SUBMISSIONS_AFTER=int(ENV_TOKENS.get('EXPIRE_SUBMISSIONS_AFTER',432000))
RESET_SUBMISSIONS_AFTER=int(ENV_TOKENS.get('RESET_SUBMISSIONS_AFTER',600))

local_loglevel = ENV_TOKENS.get('LOCAL_LOGLEVEL', 'INFO')
LOG_DIR = ENV_TOKENS.get("LOG_DIR", ENV_ROOT / "log")

LOGGING = get_logger_config(LOG_DIR,
    logging_env=ENV_TOKENS['LOGGING_ENV'],
    syslog_addr=(ENV_TOKENS['SYSLOG_SERVER'], 514),
    local_loglevel=local_loglevel,
    debug=DEBUG)

######################################################################
# Read secure config
with open(ENV_ROOT / "auth.json") as auth_file:
    AUTH_TOKENS = json.load(auth_file)


XQUEUE_INTERFACE = AUTH_TOKENS['XQUEUE_INTERFACE']
GRADING_CONTROLLER_INTERFACE = AUTH_TOKENS['GRADING_CONTROLLER_INTERFACE']
DATABASES = AUTH_TOKENS['DATABASES']
DATABASES['OPTIONS']['autocommit']="True"

AWS_ACCESS_KEY_ID = AUTH_TOKENS["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = AUTH_TOKENS["AWS_SECRET_ACCESS_KEY"]
@@ -2473,50 +2473,8 @@
 ES'%5D
-%0ADATABASES%5B'OPTIONS'%5D%5B'autocommit'%5D=%22True%22
 %0A%0AAW

Remove autocommit setting