def get_config_path(): """Get the path of the indico config file. This may return the location of a symlink. Resolving a link is up to the caller if needed. """ # In certain environments (debian+uwsgi+no-systemd) Indico may run # with an incorrect $HOME (such as /root), resulting in the config # files being searched in the wrong place. By clearing $HOME, Python # will get the home dir from passwd which has the correct path. old_home = os.environ.pop('HOME', None) # env var has priority try: return os.path.expanduser(os.environ['INDICO_CONFIG']) except KeyError: pass # try finding the config in various common paths paths = [os.path.expanduser('~/.indico.conf'), '/etc/indico.conf'] # Keeping HOME unset wouldn't be too bad but let's not have weird side-effects if old_home is not None: os.environ['HOME'] = old_home # If it's an editable setup (ie usually a dev instance) allow having # the config in the package's root path if package_is_editable('indico'): paths.insert( 0, os.path.normpath( os.path.join(get_root_path('indico'), 'indico.conf'))) for path in paths: if os.path.exists(path): return path raise Exception( 'No indico config found. Point the INDICO_CONFIG env var to your config file or ' 'move/symlink the config in one of the following locations: {}'.format( ', '.join(paths)))
def get_config_path(): """Get the path of the indico config file. This may return the location of a symlink. Resolving a link is up to the caller if needed. """ # In certain environments (debian+uwsgi+no-systemd) Indico may run # with an incorrect $HOME (such as /root), resulting in the config # files being searched in the wrong place. By clearing $HOME, Python # will get the home dir from passwd which has the correct path. old_home = os.environ.pop('HOME', None) # env var has priority try: return os.path.expanduser(os.environ['INDICO_CONFIG']) except KeyError: pass # try finding the config in various common paths paths = [os.path.expanduser('~/.indico.conf'), '/etc/indico.conf'] # Keeping HOME unset wouldn't be too bad but let's not have weird side-effects if old_home is not None: os.environ['HOME'] = old_home # If it's an editable setup (ie usually a dev instance) allow having # the config in the package's root path if package_is_editable('indico'): paths.insert(0, os.path.normpath(os.path.join(get_root_path('indico'), 'indico.conf'))) for path in paths: if os.path.exists(path): return path raise Exception('No indico config found. Point the INDICO_CONFIG env var to your config file or ' 'move/symlink the config in one of the following locations: {}'.format(', '.join(paths)))
def get_config_path(): # env var has priority try: return os.path.expanduser(os.environ['INDICO_CONFIG']) except KeyError: pass # try finding the config in various common paths paths = [os.path.expanduser('~/.indico.conf'), '/etc/indico.conf'] # If it's an editable setup (ie usually a dev instance) allow having # the config in the package's root path if package_is_editable('indico'): paths.insert(0, os.path.normpath(os.path.join(get_root_path('indico'), 'indico.conf'))) for path in paths: if os.path.exists(path): return path raise Exception('No indico config found. Point the INDICO_CONFIG env var to your config file or or ' 'move/symlink the config in one of the following locations: {}'.format(', '.join(paths)))