From 36a09ed129a3b5e032ae6decce08bdea7aa41160 Mon Sep 17 00:00:00 2001 From: Scott Baker <smbaker@gmail.com> Date: Tue, 16 Sep 2014 17:34:21 -0700 Subject: [PATCH] call django.setup in django 1.7 --- planetstack/planetstack-backend.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100755 => 100644 planetstack/planetstack-backend.py diff --git a/planetstack/planetstack-backend.py b/planetstack/planetstack-backend.py old mode 100755 new mode 100644 index 596ecdd..7d403c5 --- a/planetstack/planetstack-backend.py +++ b/planetstack/planetstack-backend.py @@ -3,7 +3,12 @@ import os import argparse os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings") from observer.backend import Backend -from planetstack.config import Config +from planetstack.config import Config + +try: + from django import setup as django_setup # django 1.7 +except: + django_setup = False config = Config() @@ -27,16 +32,19 @@ def daemon(): def main(): # Generate command line parser parser = argparse.ArgumentParser(usage='%(prog)s [options]') - parser.add_argument('-d', '--daemon', dest='daemon', action='store_true', default=False, + parser.add_argument('-d', '--daemon', dest='daemon', action='store_true', default=False, help='Run as daemon.') # smbaker: util/config.py parses sys.argv[] directly to get config file name; include the option here to avoid # throwing unrecognized argument exceptions parser.add_argument('-C', '--config', dest='config_file', action='store', default="/opt/planetstack/plstackapi_config", help='Name of config file.') args = parser.parse_args() - + if args.daemon: daemon() + if django_setup: # 1.7 + django_setup() + backend = Backend() backend.run() -- 2.47.0