Исправление импорта модуля в main.py и добваление запись ошибок для parse_saby.py
parent
ebee8687a8
commit
f55b303192
|
|
@ -4,9 +4,7 @@ pipeline {
|
|||
stages {
|
||||
stage('recreate > build > run container') {
|
||||
steps {
|
||||
// sh "docker-compose up --force-recreate --build parse_saby"
|
||||
sh "docker-compose build --no-cache parse_saby"
|
||||
sh "docker-compose up parse_saby"
|
||||
sh "docker-compose up --force-recreate --build parse_saby"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ LOG_FILE = "errors.log"
|
|||
def current_datatime():
|
||||
return datetime.datetime.now().strftime("[%d-%m-%Y %H:%M:%S]")
|
||||
|
||||
def write_to_log(error_message, log_file=LOG_FILE):
|
||||
def write_to_log(error_message:str, log_file=LOG_FILE):
|
||||
"""
|
||||
Записывает ошибку в лог-файл с временной меткой
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
import app.error_to_log as error_to_log
|
||||
import error_to_log
|
||||
|
||||
def parse_html(url: str):
|
||||
"""
|
||||
|
|
@ -86,7 +86,9 @@ def parse_reports(soup:BeautifulSoup, # HTML объект
|
|||
# Добавление всех данных в итоговый словарь
|
||||
result_dict_data.update({id: (name_title, span.text, from_date, to_date, version)})
|
||||
except Exception as e:
|
||||
print(f"Ошибка при обработке отчета {report_title}: ", e)
|
||||
error_message = f"Ошибка при обработке отчета {report_title}: {e}"
|
||||
print(error_message)
|
||||
error_to_log.write_to_log(error_message)
|
||||
continue
|
||||
return result_dict_data
|
||||
|
||||
|
|
@ -183,6 +185,7 @@ def process_reports_parse(url_formats = 'https://formats.saby.ru'):
|
|||
except Exception as e:
|
||||
print(f"Ошибка при обработке отчета {report_title}: {str(e)}")
|
||||
error_message = f"ERROR-PARSE_SABY: {e} DATA: {report_title}"
|
||||
error_to_log.write_to_log(error_message)
|
||||
continue
|
||||
return dict_result
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue