def load_problems(args):
    problem_dir = args.problems_directory[0]
    grader_dir = args.graders_directory[0]
    static_dir = args.static_directory[0]

    if not path.exists(static_dir):
        logging.debug("No directory {}. Creating...".format(static_dir))
        makedirs(static_dir)

    if not path.exists(problem_dir):
        logging.critical("No such directory: {}".format(problem_dir))
        return

    for (dirpath, dirnames, filenames) in walk(problem_dir):
        if "problem.json" in filenames:
            json_file = path.join(dirpath, 'problem.json')
            contents = open(json_file, "r").read()

            try:
                data = json_util.loads(contents)
            except __HOLE__ as e:
                logging.warning("Invalid JSON format in file {filename} ({exception})".format(filename=json_file,
                                                                                              exception=e))
                continue

            if not isinstance(data, dict):
                logging.warning("Invalid JSON format in file {}".format(json_file))
                continue

            if 'name' not in data:
                logging.warning("Invalid problem format in file {}".format(json_file))
                continue

            problem_name = data['name']
            relative_path = path.relpath(dirpath, problem_dir)
            logging.info("Found problem '{}'".format(problem_name))

            if 'grader' not in dirnames:
                logging.warning("Problem '{}' appears to have no grader folder. Skipping...".format(problem_name))
                continue

            grader_path = path.join(grader_dir, relative_path)
            if path.exists(grader_path):
                shutil.rmtree(grader_path)

            shutil.copytree(path.join(dirpath, 'grader'), grader_path)
            logging.info("Graders updated for problem {}".format(problem_name))

            try:
                if api.common.safe_fail(api.problem.get_problem, pid=api.common.hash(problem_name)):
                    api.problem.update_problem(api.common.hash(problem_name), data)
                else:
                    api.problem.insert_problem(data)
            except api.common.WebException as e:
                logging.info("Problem '{}' was not added to the database. Reason: {}".format(problem_name, e))

            if 'static' in dirnames:
                logging.info("Found a static directory for '{}'. Copying...".format(problem_name))
                static_path = path.join(static_dir, relative_path)
                if path.exists(static_path):
                    shutil.rmtree(static_path)
                shutil.copytree(path.join(dirpath, 'static'), static_path)


    errors = api.problem.analyze_problems()
    for error in errors:
        logging.warning(error)
dataset/ETHPy150Open IceCTF/ctf-platform/api/api_manager.py/load_problems