#!@PYTHON@
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)

# Add pcs package.
PACKAGE_DIR = os.path.dirname(CURRENT_DIR)
BUNDLED_PACKAGES_DIR = os.path.join(PACKAGE_DIR, "@PCS_BUNDLED_DIR_LOCAL@", "packages")
sys.path.insert(0, BUNDLED_PACKAGES_DIR)
sys.path.insert(0, PACKAGE_DIR)


if "-d" in sys.argv:
    from pcs.daemon.run import main
    main()
else:
    from pcs import (
        app,
        settings,
    )

    settings.pcsd_exec_location = os.path.join(PACKAGE_DIR, "pcsd")
    settings.pcsd_gem_path = os.path.join(PACKAGE_DIR, "@PCSD_BUNDLED_DIR_ROOT_LOCAL@")
    app.main(sys.argv[1:])
