From fab61729b9d2f0fce64823d3529afbc1cd38e06a Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 19 Jul 2016 17:45:43 -0700 Subject: [PATCH] conf: throw a specific error when PyYAML is missing --- conf.py | 6 +++++- pylink | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index df283af..f47ec3d 100644 --- a/conf.py +++ b/conf.py @@ -5,7 +5,11 @@ This module is used to access the configuration of the current PyLink instance. It provides simple checks for validating and loading YAML-format configurations from arbitrary files. """ -import yaml +try: + import yaml +except ImportError: + raise ImportError("Please install PyYAML and try again.") + import sys from collections import defaultdict diff --git a/pylink b/pylink index 4af22c2..9067bdf 100755 --- a/pylink +++ b/pylink @@ -6,12 +6,13 @@ PyLink IRC Services launcher. import os import sys try: - from pylinkirc import world, conf, __version__ + from pylinkirc import world except ImportError: sys.stderr.write("ERROR: Failed to import PyLink main module (pylinkirc.world).\n\nIf you are " "running PyLink from source, please install PyLink first using 'python3 " "setup.py install [--user]'\n") sys.exit(1) +from pylinkirc import conf, __version__ if __name__ == '__main__': import argparse