# Path: config/base_settings.py
# BASE_PATH = os.path.split(os.path.split(__file__)[0])[0]
# OUTPUT_PATH = os.path.join(BASE_PATH, 'output')
# OUTPUT_GROUP_PATH = os.path.join(OUTPUT_PATH, TimeUtil.getFormatTime('%Y%m%d_%H%M%S'))
# DATABASE_NAME = os.path.join(OUTPUT_GROUP_PATH, 'Patent.db')
# EXCEL_NAME = os.path.join(OUTPUT_GROUP_PATH, '专利.xlsx')
# CHARTS_NAME = os.path.join(OUTPUT_GROUP_PATH, 'charts.html')
# LOG_FILENAME = os.path.join(OUTPUT_GROUP_PATH, "PatentCrawler.log")
# CAPTCHA_MODEL_NAME = os.path.join(BASE_PATH, 'res', 'captcha', 'sipo3.job')
# AD_PATH = os.path.join(BASE_PATH, 'res', 'advertisement', 'ad.html')
# USE_PROXY = False
# PROXY_URL = 'http://127.0.0.1:5010/get'
# TIMEOUT = 10
# DOWNLOAD_DELAY = 1
# OUTPUT_ITEMS = ['data', 'log', 'chart']
#         USE_PROXY = use_proxy
#                 PROXY_URL = proxy_url
#             TIMEOUT = timeout
#             DOWNLOAD_DELAY = delay
#             OUTPUT_ITEMS = output_items
# def check_proxy(cfg):
# def check_request(cfg: configparser.ConfigParser):
# def check_output(cfg):
# 
# Path: controller/url_config.py



import json
import controller as ctrl
import requests
from logbook import Logger
from requests.exceptions import RequestException, ReadTimeout
from config import base_settings as bs
from controller.url_config import url_pre_execute, url_index
        return None


def update_proxy():
    """
    获取并校验代理ip地址
    :return:
    """
    if bs.USE_PROXY:
        i = 0
        while True:
            try:
                get_proxy()
                notify_ip_address()
                return True
            except Exception:
                i += 1
                logger.error("代理获取失败，尝试重试，重试次数%s" % (i, ))
    else:
        logger.info('notify address')
        notify_ip_address()


def update_cookies(cookies=None):
    """
    更新或获取cookies
    :param cookies:
    :return:
    """
    if cookies is None:

# Path: config/base_settings.py
# BASE_PATH = os.path.split(os.path.split(__file__)[0])[0]
# OUTPUT_PATH = os.path.join(BASE_PATH, 'output')
# OUTPUT_GROUP_PATH = os.path.join(OUTPUT_PATH, TimeUtil.getFormatTime('%Y%m%d_%H%M%S'))
# DATABASE_NAME = os.path.join(OUTPUT_GROUP_PATH, 'Patent.db')
# EXCEL_NAME = os.path.join(OUTPUT_GROUP_PATH, '专利.xlsx')
# CHARTS_NAME = os.path.join(OUTPUT_GROUP_PATH, 'charts.html')
# LOG_FILENAME = os.path.join(OUTPUT_GROUP_PATH, "PatentCrawler.log")
# CAPTCHA_MODEL_NAME = os.path.join(BASE_PATH, 'res', 'captcha', 'sipo3.job')
# AD_PATH = os.path.join(BASE_PATH, 'res', 'advertisement', 'ad.html')
# USE_PROXY = False
# PROXY_URL = 'http://127.0.0.1:5010/get'
# TIMEOUT = 10
# DOWNLOAD_DELAY = 1
# OUTPUT_ITEMS = ['data', 'log', 'chart']
#         USE_PROXY = use_proxy
#                 PROXY_URL = proxy_url
#             TIMEOUT = timeout
#             DOWNLOAD_DELAY = delay
#             OUTPUT_ITEMS = output_items
# def check_proxy(cfg):
# def check_request(cfg: configparser.ConfigParser):
# def check_output(cfg):
# 
# Path: controller/url_config.py



# Path: service/proxy.py
import json
import controller as ctrl
import requests
from logbook import Logger
from requests.exceptions import RequestException, ReadTimeout
from config import base_settings as bs
from controller.url_config import url_pre_execute, url_index

        return None


def update_proxy():
    """
    获取并校验代理ip地址
    :return:
    """
    if bs.USE_PROXY:
        i = 0
        while True:
            try:
                get_proxy()
                notify_ip_address()
                return True
            except Exception:
                i += 1
                logger.error("代理获取失败，尝试重试，重试次数%s" % (i, ))
    else:
        logger.info('notify address')
        notify_ip_address()


def update_cookies(cookies=None):
    """
    更新或获取cookies
    :param cookies:
    :return:
    """
    if cookies is None:

        ctrl.COOKIES = requests.get(url=url_index.get('url'), proxies=ctrl.PROXIES, timeout=bs.TIMEOUT).cookies