Beispiel #1
0
def worker(loop, seconds, url):
    i = 1
    total_erros = 0
    dao = Dao()
    while(i <= loop):
        print('check => ', url, 'i => ', i)
        try:
            start = time.time()
            request = requests.get(url, timeout=CONFIG.get("REQUEST_TIMEOUT"))
            status_code = request.status_code
        except Exception as e:
            if CONFIG.get("SENTRY_URL") != "":
                sentry_sdk.init(CONFIG.get("SENTRY_URL"))
                sentry_sdk.capture_exception(e)
            status_code = CONFIG.get("REQUEST_DEFAULT_ERROR")
            total_erros += 1

        if total_erros > CONFIG.get("NUMBER_ERRORS_SEND_MAIL"):
            if CONFIG.get("SENDMAIL"):
                mail = Mail(url, status_code)
                mail.send_mail()
            total_erros = 0

        try:
            dao.insert(log_entity(url, status_code, (time.time() - start)))
        except Exception as e:
            if CONFIG.get("SENTRY_URL") != "":
                sentry_sdk.init(CONFIG.get("SENTRY_URL"))
                sentry_sdk.capture_exception(e)
            sentry_sdk.capture_exception(e)

        i += 1
        time.sleep(seconds)
Beispiel #2
0
import random
import time

from config.pathes import PROJECTINFO
from utils.FileReader import YamlReader
from utils.mail import Mail
from utils.report import runner

Y = []
time.sleep(random.randint(1, 90))
test = 'test_oa_clockin_Y*'
runner(test)
receusers = YamlReader(PROJECTINFO).get('OA').get('mail')['receusers'][0]
Y.append(receusers)
eml = Mail('OA', Y)
eml.send_mail()