utils.py 665 Bytes
Newer Older
Matteo's avatar
Matteo committed
1
2
3
import os
import subprocess
import json
Matteo's avatar
Matteo committed
4
from mpai_cae_arp.files import get_file_content
Matteo's avatar
Matteo committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


def analyze(files_name: str, working_path: str | None = None) -> subprocess.CompletedProcess:
    executable = os.path.abspath("frame_extraction/bin/frame_extraction")

    config = get_file_content("config/config.json", "json")

    # Update configuration file with query parameters
    config["FilesName"] = files_name
    if working_path is not None:
        config["WorkingPath"] = working_path
    with open("config/config.json", "w") as json_file:
        json.dump(config, json_file)

    process = subprocess.run([executable], capture_output=True)
    return process