def get_url_content(url): logger = logging.getLogger("word_cloud") logger.info("begin to load {url}".format(url = url)) i = 0 content = None while i <= 2 and not content : logger.info("Try to load at {i} time".format(i=i)) content = ts.notice_content(url) i += 1 if not content: logger.warning("Load failed, sleep for a while and try again") time.sleep(2) if content: logger.info("load {url} successfully".format(url=url)) logger.info("=========================================================") return content else: logger.error("load {url} failed and will ignore this url".format(url=url)) logger.info("=========================================================") return ""
def get_url_content(url): logger = logging.getLogger("word_cloud") logger.info("begin to load {url}".format(url=url)) i = 0 content = None while i <= 2 and not content: logger.info("Try to load at {i} time".format(i=i)) content = ts.notice_content(url) i += 1 if not content: logger.warning("Load failed, sleep for a while and try again") time.sleep(2) if content: logger.info("load {url} successfully".format(url=url)) logger.info( "=========================================================") return content else: logger.error( "load {url} failed and will ignore this url".format(url=url)) logger.info( "=========================================================") return ""
is_user_admin, ServiceManagerWindows, ) # from configs import Conf from traceback import format_exc from libs.service_modules import LocalModule, LocalService from modules.simulator.main import Simulator from modules.websocket_server.main import * from modules.websocket_server.scheme import Action from modules.websocket_server.scheme import Update from shared_libs.read_log import read_log logger = logging.getLogger("service") logger.propagate = False def start_minimal(): try: db = ServiceManagerWindows("PostgreSQL") logger.debug('Db service status: {}'.format(db.status())) if db.status() not in ["RUNNING", "STARTING"]: db.start() sleep(5) except: logger.critical( 'Запуск невозможен. База данных не найдена или не может быть запущена.' ) logger.critical(format_exc())
from models.work_db import * from models.local_db import * from modules.parser_module.utils import string_tools from modules.parser_module.utils import parsing_rules from modules.parser_module.utils import table_tools from modules.parser_module.utils.xlsx_tools import pars_formated_strings from modules.parser_module.utils import other_tools except: from traceback import format_exc print( "Ошибка запуска. Одна или несколько библиотек отсутствуют. {}".format( format_exc())) raise SystemExit() log = logging.getLogger("parser") log.propagate = False config = Conf("config.ini").config class MainParser: """ Класс парсинга переменных из файла таблиц типа .xlsx. """ def __init__(self, file=CONFIG_DIR + config['parsing']['input_file_name']): if os.path.isfile(file): log.info( "Проверка наличия файла первоначальной конфигурации... в папке {}\n" .format(CONFIG_DIR) + (bclr.OKG + "OK" + bclr.C)) else:
""" Модуль чтения переменных Modbus TCP сервера Для чтения из клиента. """ __log__ = "logs/modbus_reader.log" __config__ = "configs/modbus_reader.ini" import asyncio import traceback from time import sleep from modules.modbus_reader.modbus_read import InputModbusDataBlock, run_custom_db_server from logs import logging from models.work_db import * config = Conf("modbus_reader.ini").config log = logging.getLogger("modbus_reader") log.propagate = False source_name = "modbus_reader" class ModbusReaderMain: """ Класс ридера openOPC сервиса """ def __init__(self, ip=None, port=None, loop=None): if ip is None: ip = self.server_name = config["connection"]["ip"] if port is None: port = self.server_name = config["connection"]["port"] if loop is None: loop = asyncio.get_event_loop()
""" Модуль расчёта переменных. Включает в себя получение данных, расчёт и загрузку результатов в базу данных. """ from time import sleep from threading import Thread from traceback import format_exc import asyncio from logs import logging from models.local_db import * from models.work_db import * from modules.calculation_module.helpers import * from shared_libs.custom_math import * tm_g = datetime.now() log = logging.getLogger("python_calc") log.propagate = False source_name = "python_calc" class CalculationMain: """ Модуль чтения, расчётов и записи перменных. """ @db_session def __init__(self, loop=None): # if loop is None: # loop = asyncio.get_event_loop() self.loop = asyncio.get_event_loop() self.pause = False
__log__ = "logs/reader.log" __config__ = "configs/opc_reader.ini" import asyncio import concurrent.futures import traceback from time import sleep from threading import Thread import OpenOPC from logs import logging from models.work_db import * config = Conf("opc_reader.ini").config log = logging.getLogger("opc_reader") log.propagate = False source_name = "opc_reader" class ReaderMain: """ Класс ридера openOPC сервиса """ def __init__(self, ip=None, port=None, loop=None): if ip is None: ip = self.server_name = config["connection"]["ip"] if port is None: port = self.server_name = config["connection"]["port"] if loop is None: