#!/usr/bin/python3
import os
import os.path
import sys

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))

# We prevent to import some module from this dir instead of e.g. standard
# module. There is no reason to import anything from this module.
sys.path.remove(CURRENT_DIR)

TEST_INSTALLED = os.environ.get("PCS_TEST.TEST_INSTALLED", "0") == "1"
PACKAGE_DIR = os.path.dirname(CURRENT_DIR)

if not TEST_INSTALLED:
    # Add pcs package.
    sys.path.insert(0, PACKAGE_DIR)

# pylint: disable=wrong-import-position
from pcs import (
    app,
    settings,
)

if not TEST_INSTALLED:
    settings.pcsd_exec_location = os.path.join(PACKAGE_DIR, "pcsd")

settings.corosync_conf_file = None
settings.corosync_uidgid_dir = None
prefix = "PCS.SETTINGS."

for opt, val in os.environ.items():
    if opt.startswith(prefix):
        setattr(settings, opt[len(prefix):], val)

app.main(sys.argv[1:])
