[python] Some fixes.

This commit is contained in:
Maksim Andrianov 2019-06-06 12:49:49 +03:00 committed by gmoryes
parent c6a6c67340
commit 61972e95a3
4 changed files with 7 additions and 5 deletions

View file

@ -30,7 +30,7 @@ def stage(func):
main_status.update_status()
logger.info(f"{stage_formatted}: start ...")
t = time.time()
with open(logfile, "w") as l:
with open(logfile, "a+") as l:
env.set_subprocess_out(l)
func(env, *args, **kwargs)
d = time.time() - t

View file

@ -106,7 +106,9 @@ def parse_time(time_str):
return datetime.timedelta(**time_params)
def get_stages_info(log_path):
def get_stages_info(log_path, ignored_stages=None):
if ignored_stages is None:
ignored_stages = set()
result = defaultdict(lambda: defaultdict(dict))
for file in os.listdir(log_path):
path = os.path.join(log_path, file)
@ -117,7 +119,7 @@ def get_stages_info(log_path):
continue
stage_name = m.group(2)
dt = parse_time(m.group(3))
if file.startswith("stage_"):
if file.startswith("stage_") and stage_name not in ignored_stages:
result["stages"][stage_name] = dt
else:
country = file.split(".")[0]

View file

@ -290,7 +290,7 @@ def stage_statistics(env):
countries = filter(lambda x: x not in WORLDS_NAMES, mwms)
with ThreadPool() as pool:
pool.map(partial(stage_mwm_statistics, env), countries)
stages_info = get_stages_info(env.log_path)
stages_info = get_stages_info(env.log_path, {"statistics"})
result["stages"] = stages_info["stages"]
for c in stages_info["countries"]:
result["countries"][c]["stages"] = stages_info["countries"][c]

View file

@ -140,7 +140,7 @@ def hierarchy_to_countries(old_vs_new_csv_path, borders_vs_osm_csv_path,
oldvs = parse_old_vs_new(old_vs_new_csv_path)
vsosm = parse_borders_vs_osm(borders_vs_osm_csv_path)
countries_synonyms = parse_countries_synonyms(countries_synonyms_csv_path)
stack = [CountryDict(v=version, nameattr="Countries", g=[])]
stack = [CountryDict(v=version, id="Countries", g=[])]
last = None
with open(hierarchy_path) as f:
for line in f: