# Path: app/configs.py
# APP_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJECT_PATH = os.path.dirname(APP_PATH)
#     EC = EnjoliverConfig("%s/configs.yaml" % os.path.dirname(__file__))
# class EnjoliverConfig:
#     def config_override(self, key: str, default):
#     def __init__(self, yaml_full_path=os.getenv("ENJOLIVER_CONFIGS_YAML",
#                                                 "%s/configs.yaml" % APP_PATH), importer=""):


import argparse
import multiprocessing
import os
import signal
import sys
import time
from app import (
    configs,
    smartdb,
    ops,
    gunicorn_conf
)
        "%s/plans/k8s_2t.py" % APP_PATH,
    ]
    print("exec[%s] -> %s\n" % (os.getpid(), " ".join(cmd)))
    with open(ec.plan_pid_file, "w") as f:
        f.write("%d" % os.getpid())
    os.execve(cmd[0], cmd, os.environ)


def validate():
    cmd = [
        PYTHON,
        "%s/validate.py" % PROJECT_PATH,
    ]
    print("exec[%s] -> %s\n" % (os.getpid(), " ".join(cmd)))
    os.execve(cmd[0], cmd, os.environ)


def show_configs(ec):
    for k, v in ec.__dict__.items():
        print("%s=%s" % (k, v))


if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog='Enjoliver')
    parser.add_argument('task', type=str, choices=["gunicorn", "plan", "matchbox", "show-configs", "validate"],
                        help="Choose the task to run")
    parser.add_argument('--configs', type=str, default="%s/configs.yaml" % APP_PATH,
                        help="Choose the yaml config file")
    task = parser.parse_args().task
    f = parser.parse_args().configs

# Path: app/configs.py
# APP_PATH = os.path.dirname(os.path.abspath(__file__))
# PROJECT_PATH = os.path.dirname(APP_PATH)
#     EC = EnjoliverConfig("%s/configs.yaml" % os.path.dirname(__file__))
# class EnjoliverConfig:
#     def config_override(self, key: str, default):
#     def __init__(self, yaml_full_path=os.getenv("ENJOLIVER_CONFIGS_YAML",
#                                                 "%s/configs.yaml" % APP_PATH), importer=""):


# Path: manage.py
import argparse
import multiprocessing
import os
import signal
import sys
import time
from app import (
    configs,
    smartdb,
    ops,
    gunicorn_conf
)

        "%s/plans/k8s_2t.py" % APP_PATH,
    ]
    print("exec[%s] -> %s\n" % (os.getpid(), " ".join(cmd)))
    with open(ec.plan_pid_file, "w") as f:
        f.write("%d" % os.getpid())
    os.execve(cmd[0], cmd, os.environ)


def validate():
    cmd = [
        PYTHON,
        "%s/validate.py" % PROJECT_PATH,
    ]
    print("exec[%s] -> %s\n" % (os.getpid(), " ".join(cmd)))
    os.execve(cmd[0], cmd, os.environ)


def show_configs(ec):
    for k, v in ec.__dict__.items():
        print("%s=%s" % (k, v))


if __name__ == '__main__':
    parser = argparse.ArgumentParser(prog='Enjoliver')
    parser.add_argument('task', type=str, choices=["gunicorn", "plan", "matchbox", "show-configs", "validate"],
                        help="Choose the task to run")
    parser.add_argument('--configs', type=str, default="%s/configs.yaml" % APP_PATH,
                        help="Choose the yaml config file")
    task = parser.parse_args().task
    f = parser.parse_args().configs

    ec = configs.EnjoliverConfig(yaml_full_path=f, importer=__file__)