def setup_logger(name="Pyhole"): """Log handler""" # NOTE(jk0): Disable unnecessary requests logging. requests.packages.urllib3.disable_warnings() requests_log = logging.getLogger("requests") requests_log.setLevel(logging.WARNING) debug_option = utils.get_option("debug") debug_config = utils.get_config().get("debug", type="bool") debug = debug_option or debug_config log_dir = utils.get_directory("logs") log_level = logging.DEBUG if debug else logging.INFO log_format = "%(asctime)s [%(name)s] %(message)s" log_datefmt = "%H:%M:%S" logging.basicConfig(level=log_level, format=log_format, datefmt=log_datefmt) log_file = "%s/%s.log" log = logging.handlers.TimedRotatingFileHandler( log_file % (log_dir, name.lower()), "midnight") log.setLevel(log_level) formatter = logging.Formatter(log_format, log_datefmt) log.setFormatter(formatter) logging.getLogger(name).addHandler(log)
def _create_dabbmd(osenv, component_name, buildenv_path): # RED this needs to be set at the abe level and passed in try: with open('.abe_config.yml', 'r') as f: abe_config_dict = yaml.load(f) except IOError as ie: click.echo("No abe_config found...") abe_config_dict = {} # YELLOW this should come from a global list config_dict = {} DABB_OPTIONS = ['docker_username', 'docker_repository'] for opt in DABB_OPTIONS: config_dict[opt] = utils.get_option(opt, {}, abe_config_dict) # YELLOW we're probably goingto want this to be more fine-grained dabbmd_dict = {} dabbmd_dict.update(config_dict) dabbmd_dict['component_name'] = component_name # RED yeah, this is needs to have a known way of getting the right version dabbmd_dict['buildenv_version'] = 'latest' click.echo(dabbmd_dict) with open(os.path.join(buildenv_path, 'dabbmd.json'), 'w') as f: json.dump(dabbmd_dict, f)
def setup_logger(name="Pyhole"): """Log handler""" # NOTE(jk0): Disable unnecessary requests logging. requests.packages.urllib3.disable_warnings() requests_log = logging.getLogger("requests") requests_log.setLevel(logging.WARNING) debug_option = utils.get_option("debug") debug_config = utils.get_config().get("debug", type="bool") debug = debug_option or debug_config log_dir = utils.get_directory("logs") log_level = logging.DEBUG if debug else logging.INFO log_format = "%(asctime)s [%(name)s] %(message)s" log_datefmt = "%H:%M:%S" logging.basicConfig(level=log_level, format=log_format, datefmt=log_datefmt) log_file = "%s/%s.log" log = logging.handlers.TimedRotatingFileHandler(log_file % (log_dir, name.lower()), "midnight") log.setLevel(log_level) formatter = logging.Formatter(log_format, log_datefmt) log.setFormatter(formatter) logging.getLogger(name).addHandler(log)
def arrange_area(browser, stattype, startdate, datetype, arrange, interval, next_interval): # 判断next_interval if interval == int(get_option("arrange_area_next_interval")): handle_input(browser, '#roomAreaBegin', 1 if interval == 0 else interval) handle_input(browser, '#roomAreaEnd', '' if next_interval == 0 else next_interval) statdata_by_properties( browser, stattype, startdate, datetype, arrange, interval) # 更新next_interval set_option("arrange_area_next_interval", next_interval)
def setup_logger(name="Pyhole"): """Log handler""" debug_option = utils.get_option("debug") debug_config = utils.get_config().get("debug", type="bool") debug = debug_option or debug_config log_dir = utils.get_directory("logs") log_level = logging.DEBUG if debug else logging.INFO log_format = "%(asctime)s [%(name)s] %(message)s" log_datefmt = "%H:%M:%S" logging.basicConfig(level=log_level, format=log_format, datefmt=log_datefmt) log_file = "%s/%s.log" log = logging.handlers.TimedRotatingFileHandler(log_file % (log_dir, name.lower()), "midnight") log.setLevel(log_level) formatter = logging.Formatter(log_format, log_datefmt) log.setFormatter(formatter) logging.getLogger(name).addHandler(log)
def setup_logger(name="Pyhole"): """Log handler""" debug_option = utils.get_option("debug") debug_config = utils.get_config().get("debug", type="bool") debug = debug_option or debug_config log_dir = utils.get_directory("logs") log_level = logging.DEBUG if debug else logging.INFO log_format = "%(asctime)s [%(name)s] %(message)s" log_datefmt = "%H:%M:%S" logging.basicConfig(level=log_level, format=log_format, datefmt=log_datefmt) log_file = "%s/%s.log" log = logging.handlers.TimedRotatingFileHandler( log_file % (log_dir, name.lower()), "midnight") log.setLevel(log_level) formatter = logging.Formatter(log_format, log_datefmt) log.setFormatter(formatter) logging.getLogger(name).addHandler(log)
def hr(): print("*" * 71) for i in rede.agencias: num = len(rede.travessia_profundidade_agencias(i)) p = "ões" if num != 1 else "ão" print(f"{i} - {num} ligaç{p}") print("*" * 71) while True: hr() print(" 1 – Adicionar ou remover agências e ligações entre agências.") print(" 2 – Obter as agências de notícias atingíveis através de uma travessia") print(" em profundidade com início numa determinada agência de notícias.") print(" 3 – Obter um caminho entre duas agências de notícias.") print(" 4 – Saír.") option = get_option(" > ", 4) if option == 1: while True: hr() print(" Agências:") print(" 1 - Adicionar") print(" 2 - Remover") print(" Ligações:") print(" 3 - Adicionar") print(" 4 - Remover") print(" 5 - Voltar a tráz") option = get_option(" > ", 5) if option in [1, 2]: agencia = input(" Nome da agência: ").strip() if option == 1: rede.adicionar_agencia(agencia) elif option == 2: rede.remover_agencia(agencia)
# Detect limits self.calculate_limits() except pygame.error, message: print message except IndexError, message: print message except Exception, message: print message print "No cached image, generating it" except: print "No cached image, generating it" level_md5 = utils.file_md5("{0}.gif".format(stage_file)) print "MD5 of level ", level_md5 level_old_md5 = utils.get_option("{0}_hash".format(stage_file)) print "Old MD5 of level ", level_old_md5 if level_md5 != level_old_md5: print "Level has changed, process it again" cached_image = False if cached_image == False: self.overimage_lava, self.overrect_lava = utils.load_image("lava.png") self.overimage_rocks, self.overrect_rocks = utils.load_image("rocks.png") self.image_grass_bl, self.rect_grass = utils.load_image("stage_grass_bl.png") self.image_grass_br, self.rect_grass = utils.load_image("stage_grass_br.png") self.image_grass_tl, self.rect_grass = utils.load_image("stage_grass_tl.png") self.image_grass_tr, self.rect_grass = utils.load_image("stage_grass_tr.png") self.image_grass_t, self.rect_grass = utils.load_image("stage_grass_t.png")
import difflib import json import time import requests from config import STATDELTA, STATTYPES from spider import prepare_statdata, initialize_browser, close_browser, client_login from utils import get_option, set_option, sql_exec, sql_query if __name__ == "__main__": browser = initialize_browser() current_datetime = datetime.datetime.now() client_login(browser) # 统计resume_statdate_month statdate = datetime.datetime.strptime(get_option("resume_statdate_month"), '%Y-%m-%d') delta = current_datetime - statdate for item in range(1, delta.days - STATDELTA): statdate_item = statdate + datetime.timedelta(days=item) if 1 == int(statdate_item.day): # 月初统计上月月报 enddate = statdate_item - datetime.timedelta(days=1) startdate = datetime.datetime.strptime( '%s-%s-%s' % (enddate.year, enddate.month, 1), '%Y-%m-%d') for stattype in STATTYPES: print("statistic resume month.................") prepare_statdata(browser, stattype, startdate.strftime('%Y-%m-%d'), enddate.strftime('%Y-%m-%d'), 'month') # 更新统计日期 set_option("resume_statdate_month", statdate_item.strftime('%Y-%m-%d'))
# enddate = statdate_item - datetime.timedelta(days=1) # startdate = datetime.datetime.strptime( # '%s-%s-%s' % (enddate.year, enddate.month, 1), '%Y-%m-%d') # # 仅 成交情况 时统计价格区间 # print("statistic amount.................") # prepare_statdata(browser, STATTYPES[0], startdate.strftime( # '%Y-%m-%d'), enddate.strftime('%Y-%m-%d'), 'month', 'amount') # # 更新统计日期 # set_option("arrange_amount_statdate", # statdate_item.strftime('%Y-%m-%d')) # 关闭浏览器 import pdb pdb.set_trace() close_browser(browser) # 更新区域 cities = json.loads(get_option("cities")) current_cities = [] for cts in cities: current_scopes = cts['children'] scopes = [item['value'] for item in current_scopes] addition_scopes = [] sqli = 'SELECT DISTINCT `scope` FROM `dataset_resume` WHERE `city`="%s"' % cts[ 'value'] result = sql_query(sqli) for item in result: if item[0] not in scopes: addition_scopes.append({ "value": item[0], "label": item[0], "center": { "lng": 0,