Commit 06a8b735c8275871370f5765111ec0c4b6f59845

Authored by hitier
1 parent e66e5366

Exit error if wrong db_config import

Showing 2 changed files with 10 additions and 4 deletions   Show diff stats
app/__init__.py
1   -import os
2 1 import sys
  2 +import os
3 3  
4 4 from flask import Flask
5 5 from flask_login import LoginManager
... ... @@ -35,8 +35,8 @@ def load_user(user_id):
35 35 try:
36 36 from pdc_config import Config, ProdConfig, DevConfig, TestConfig
37 37 except ImportError:
38   - print("Please set a pdc_config.py file in you PYTHON_PATH")
39   - print("See INSTALL.md for more info")
  38 + sys.stderr.write("ERROR: Please set a pdc_config.py file in you PYTHON_PATH\n")
  39 + sys.stderr.write("ERROR: See INSTALL.md for more info\n")
40 40 sys.exit(-1)
41 41  
42 42  
... ...
resources/pdc_config.py
  1 +import sys
1 2 import os
2   -from db_config import *
  3 +try:
  4 + from db_config import *
  5 +except ImportError:
  6 + sys.stderr.write("ERROR: Please set a db_config.py file in you PYTHON_PATH\n")
  7 + sys.stderr.write("ERROR: See INSTALL.md for more info\n")
  8 + sys.exit(-1)
3 9  
4 10 root_dir = os.path.abspath(os.path.dirname(__file__))
5 11  
... ...