Commit 33ae8c51 authored by Tomas Krizek's avatar Tomas Krizek

datafile: consistently check the file exists

parent 5f701a7c
from argparse import ArgumentParser, Namespace
import logging
import os
import sys
import cfg
......@@ -33,7 +34,13 @@ def add_arg_datafile(parser: ArgumentParser) -> None:
REPORT_FILENAME))
def get_datafile(args: Namespace) -> str:
if args.datafile is None:
return os.path.join(args.envdir, REPORT_FILENAME)
return args.datafile
def get_datafile(args: Namespace, check_exists=True) -> str:
datafile = args.datafile
if datafile is None:
datafile = os.path.join(args.envdir, REPORT_FILENAME)
if check_exists and not os.path.exists(datafile):
logging.error("JSON report (%s) doesn't exist!", datafile)
sys.exit(1)
return datafile
......@@ -4,11 +4,9 @@ import argparse
from itertools import zip_longest
import logging
from multiprocessing import pool
import os
import pickle
import random
import subprocess
import sys
from typing import Any, Iterable, Iterator, Mapping, Sequence, Tuple, TypeVar
import cli
......@@ -108,6 +106,7 @@ def main():
args = parser.parse_args()
sendrecv.module_init(args)
datafile = cli.get_datafile(args)
report = DiffReport.from_json(datafile)
restart_scripts = get_restart_scripts(args.cfg)
if args.sequential:
......@@ -115,13 +114,6 @@ def main():
else:
nproc = args.cfg['sendrecv']['jobs']
# TODO copypasta from msgdiff, should also be checked in diffsum -- refactor?
# JSON report has to be created by orchestrator
if not os.path.exists(datafile):
logging.error("JSON report (%s) doesn't exist!", datafile)
sys.exit(1)
report = DiffReport.from_json(datafile)
if report.reprodata is None:
report.reprodata = ReproData()
......
......@@ -2,11 +2,8 @@
import argparse
from functools import partial
import logging
import multiprocessing.pool as pool
import os
import pickle
import sys
from typing import Any, Dict, Iterator, Mapping, Optional, Sequence, Tuple # noqa
import dns.message
......@@ -269,11 +266,6 @@ def main():
criteria = args.cfg['diff']['criteria']
target = args.cfg['diff']['target']
# JSON report has to be created by orchestrator
if not os.path.exists(datafile):
logging.error("JSON report (%s) doesn't exist!", datafile)
sys.exit(1)
with LMDB(args.envdir, fast=True) as lmdb_:
lmdb = lmdb_
lmdb.open_db(LMDB.ANSWERS)
......
......@@ -48,7 +48,7 @@ def main():
args = parser.parse_args()
sendrecv.module_init(args)
datafile = cli.get_datafile(args)
datafile = cli.get_datafile(args, check_exists=False)
start_time = int(time.time())
with LMDB(args.envdir) as lmdb:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment