# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import socorro.lib.ConfigurationManager as cm
import datetime

from config.commonconfig import databaseHost
from config.commonconfig import databaseName
from config.commonconfig import databaseUserName
from config.commonconfig import databasePassword

from config.commonconfig import hbaseHost
from config.commonconfig import hbasePort
from config.commonconfig import hbaseTimeout

brokenFirefoxLinuxQuery = """
    SELECT uuid,date_processed FROM reports WHERE product = 'Firefox'
      AND (version = '4.0b11' OR version = '4.0b12')
      AND os_name = 'Linux'
      AND date_processed > '%s'
      AND date_processed < (now() - INTERVAL '30 minutes')
      ORDER BY date_processed
"""
brokenFirefoxLinuxFixer = './minidump_hack-firefox_linux'

brokenFennecQuery = """
    SELECT uuid,date_processed FROM reports WHERE product = 'Fennec'
      AND version = '4.0b5'
      AND date_processed > '%s'
      AND date_processed < (now() - INTERVAL '30 minutes')
      ORDER BY date_processed
"""
brokenFennecFixer = './minidump_hack-fennec'

brokenBoot2GeckoQuery = """
    SELECT uuid,date_processed FROM reports WHERE product = 'B2G'
      AND os_name = 'Android'
      AND date_processed > '%s'
      AND date_processed < (now() - INTERVAL '30 minutes')
      ORDER BY date_processed
"""
brokenBoot2GeckoFixer = './minidump_hack-b2g'

persistentBrokenDumpPathname = cm.Option()
persistentBrokenDumpPathname.doc = 'a pathname to a file system location where this script can store persistent data'
persistentBrokenDumpPathname.default = './fixbrokendumps.pickle'

daysIntoPast = cm.Option()
daysIntoPast.doc = 'number of days to look into the past for broken crashes (0 - use last run time)'
daysIntoPast.default = 30

#-------------------------------------------------------------------------------
# Logging

syslogHost = cm.Option()
syslogHost.doc = 'syslog hostname'
syslogHost.default = 'localhost'

syslogPort = cm.Option()
syslogPort.doc = 'syslog port'
syslogPort.default = 514

syslogFacilityString = cm.Option()
syslogFacilityString.doc = 'syslog facility string ("user", "local0", etc)'
syslogFacilityString.default = 'user'

syslogLineFormatString = cm.Option()
syslogLineFormatString.doc = 'python logging system format for syslog entries'
syslogLineFormatString.default = 'Socorro Fix Broken Dumps (pid %(process)d): %(asctime)s %(levelname)s - %(threadName)s - %(message)s'

syslogErrorLoggingLevel = cm.Option()
syslogErrorLoggingLevel.doc = 'logging level for the log file (10 - DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)'
syslogErrorLoggingLevel.default = 10

stderrLineFormatString = cm.Option()
stderrLineFormatString.doc = 'python logging system format for logging to stderr'
stderrLineFormatString.default = '%(asctime)s %(levelname)s - %(message)s'

stderrErrorLoggingLevel = cm.Option()
stderrErrorLoggingLevel.doc = 'logging level for the logging to stderr (10 - DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)'
stderrErrorLoggingLevel.default = 40


