diff --git a/src/linkahead/configuration.py b/src/linkahead/configuration.py index d5ec414141126f2bf85e6563ebf53742f31e3e82..75e36d9ba1e0dd016174ad1eecb74cd41d649101 100644 --- a/src/linkahead/configuration.py +++ b/src/linkahead/configuration.py @@ -23,8 +23,10 @@ # import os -import yaml import warnings + +import yaml + try: optional_jsonschema_validate = None from jsonschema import validate as optional_jsonschema_validate @@ -32,9 +34,8 @@ except ImportError: pass from configparser import ConfigParser - from os import environ, getcwd -from os.path import expanduser, join, isfile +from os.path import expanduser, isfile, join def _reset_config(): @@ -108,6 +109,20 @@ def _read_config_files(): """ return_var = [] + if "PYCAOSDBINI" in environ: + raise RuntimeError("You have set the old PYCAOSDBINI environment variable. Please use the " + "new PYLINKAHEADINI variable instead and unset the old one.") + if os.path.exists(expanduser('~/.pycaosdb.ini')): + raise RuntimeError("You have a config file with the old naming scheme (pycaosdb.ini). " + f"Please use the new version and rename\n" + f"{expanduser('~/.pycaosdb.ini')}\n" + f"to\n{expanduser('~/.pylinkahead.ini')}") + if os.path.exists(join(getcwd(), "pycaosdb.ini")): + raise RuntimeError("You have a config file with the old naming scheme (pycaosdb.ini). " + f"Please use the new version and rename\n" + f"{join(getcwd(), 'pycaosdb.ini')}\n" + f"to\n{join(getcwd(), 'pylinkahead.ini')}") + if "PYLINKAHEADINI" in environ: return_var.extend(configure(expanduser(environ["PYLINKAHEADINI"]))) else: