import os

from configuration import DGKConfigSettings
from gui import DGKApplication, DGKWindow, DGKInfoWindow


def main():
    # Required file checking.
    if not os.path.exists(DGKConfigSettings.APP_COURSES):
        raise FileNotFoundError(
            "Cannot find the specified course list at '{}'".format(
                DGKConfigSettings.APP_COURSES
            )
        )
    if not os.path.exists(DGKConfigSettings.APP_DATABASE):
        raise FileNotFoundError(
            "Cannot find the specified database at '{}'".format(
                DGKConfigSettings.APP_DATABASE
            )
        )

    try:
        root = DGKApplication()
        DGKWindow(root)
        root.execute()
    except FileNotFoundError as err:
        DGKInfoWindow("Startup Error", err)
