config.py 1.71 KB
Newer Older
1
import logging
2 3 4
import os
import threading

5 6
from peewee import MySQLDatabase

7

8
class Config:
9 10 11
    profileCount = 21  # number of Firefox profiles. Its name is just a number – 0,1...
    browser = 'firefox'  # iceweasel, firefox. What browser gets launched.
    configFile = '/opt/mdmaug/.cache/mdmaug-scans/_tmp/queue.cache'  # RAM disk was too small: '/tmp/mdm/queue.cache'
12
    APP_PORT = 8000
13 14 15
    APP_DOMAIN = 'https://217.31.202.41:' + str(APP_PORT)  # csirt.csirt.office.nic.cz
    LOG_DIR = "/opt/mdmaug/.cache/mdmaug-scans/_tmp/"
    CACHE_DIR = "/opt/mdmaug/.cache/mdmaug-scans/"
16
    DIR = os.path.dirname(os.path.realpath(__file__)) + "/../"
17 18
    myDB: None
    lock = threading.RLock()  # doufam, ze kdyz je lock tady, ze je funknci. Closure...? XX nejak otestovat
19
    THUMBNAIL_SIZE = 640, 640
20 21 22 23
    MAX_WHOIS_DOMAIN_THREADS = 10  # spusti maximalne 10 threadu doraz, jednou mi to totiz preteklo (kazda domena spusti jeste tolik threadu, kolik ma IP, ale tech byva jen par)
    MAX_BROWSER_RUN_TIME = 25  # maximum time for a browser to run
    MAX_BROWSER_EXPIRATION = 15  # seconds that we wait before killing the browser (waiting for the files to be written)

24 25 26
    def connect():
        # XX resim problem peewee.OperationalError: (2006, "MySQL server has gone away (BrokenPipeError(32, 'Broken pipe'))") po 7 hodinach timeoutu
        # XX kupodivu pripojeni nemuze byt v dbp DBModel.connect. Prestoze type je pak spravne (MySQLDatabase), nic udelat nejde a pokusy o select konci NoneType.
27
        logging.debug("Connecting to DB.")
28 29 30 31
        Config.myDB = MySQLDatabase("mdmaug", host='localhost', port=3306, user="mdmaug",
                                    passwd="fidFDSs676")  # XX dal jsem pryc: , threadlocals=False


32
Config.connect()