From 45c0cfd10cbd3829f5028ce9c0ec622e4b3ea90a Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Fri, 20 Mar 2015 22:23:02 -0500 Subject: [PATCH] hack to make bins work without PYTHONPATH --- bin/_pathfix.py | 11 +++++++++++ bin/fcgi_server.py | 2 ++ bin/mhprob.py | 2 ++ bin/mhrewards.py | 2 ++ bin/test_server.py | 2 ++ 5 files changed, 19 insertions(+) create mode 100644 bin/_pathfix.py diff --git a/bin/_pathfix.py b/bin/_pathfix.py new file mode 100644 index 0000000..8581f96 --- /dev/null +++ b/bin/_pathfix.py @@ -0,0 +1,11 @@ +""" +Hack to get scripts to run from source checkout without having to set +PYTHONPATH. +""" + +import sys +from os.path import dirname, join, abspath + +bin_path = dirname(__file__) +project_path = abspath(join(bin_path, "..")) +sys.path.insert(0, project_path) diff --git a/bin/fcgi_server.py b/bin/fcgi_server.py index 035d149..44e2568 100755 --- a/bin/fcgi_server.py +++ b/bin/fcgi_server.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +# Set PYTHONPATH in lighttpd or other server config. + from flup.server.fcgi import WSGIServer from mhapi.web.wsgi import application diff --git a/bin/mhprob.py b/bin/mhprob.py index 1b62793..62c70ce 100755 --- a/bin/mhprob.py +++ b/bin/mhprob.py @@ -47,6 +47,8 @@ For great luck, replace 69 with 90 import sys +import _pathfix + from mhapi import stats if __name__ == '__main__': diff --git a/bin/mhrewards.py b/bin/mhrewards.py index bb6fb84..9c32ff7 100755 --- a/bin/mhrewards.py +++ b/bin/mhrewards.py @@ -2,6 +2,8 @@ import codecs +import _pathfix + from mhapi.db import MHDB from mhapi import rewards diff --git a/bin/test_server.py b/bin/test_server.py index 3aa0569..4a89fc3 100755 --- a/bin/test_server.py +++ b/bin/test_server.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import _pathfix + from mhapi.web.wsgi import application LISTEN_HOST = ""