Revision a813a251

b/snf-cyclades-app/synnefo/logic/dispatcher.py
36 36
handled in the dispatched functions.
37 37

  
38 38
"""
39
from django.core.management import setup_environ
40 39

  
41 40
# Fix path to import synnefo settings
42 41
import sys
43 42
import os
44 43
path = os.path.normpath(os.path.join(os.getcwd(), '..'))
45 44
sys.path.append(path)
46
from synnefo import settings
47
setup_environ(settings)
45
from synnefo import settings as snf_settings
46
from django.conf import settings
47
settings.configure(**snf_settings.__dict__)
48 48

  
49 49
from django.db import close_connection
50 50

  
......
113 113
        self.client.connect()
114 114

  
115 115
        # Declare queues and exchanges
116
        exchange = settings.EXCHANGE_GANETI
116
        exchange = snf_settings.EXCHANGE_GANETI
117 117
        exchange_dl = queues.convert_exchange_to_dead(exchange)
118 118
        self.client.exchange_declare(exchange=exchange,
119 119
                                     type="topic")
b/snf-cyclades-app/synnefo/logic/reconciliation.py
59 59
import logging
60 60
import sys
61 61
import itertools
62

  
63
from django.core.management import setup_environ
64
try:
65
    from synnefo import settings
66
except ImportError:
67
    raise Exception("Cannot import settings, make sure PYTHONPATH contains "
68
                    "the parent directory of the Synnefo Django project.")
69
setup_environ(settings)
70

  
71

  
72 62
from datetime import datetime, timedelta
73 63

  
74 64
from synnefo.db.models import (VirtualMachine, pooled_rapi_client)
75 65
from synnefo.logic.rapi import GanetiApiError
76 66
from synnefo.logic.backend import get_ganeti_instances, get_backends
77 67
from synnefo.logic import utils
68
from django.conf import settings
78 69

  
79 70

  
80 71
log = logging.getLogger()
......
338 329
        if group_list != groups:
339 330
            hanging[id] = groups - group_list
340 331
    return hanging
341

  
342

  
343
# Only for testing this module individually
344
def main():
345
    print get_instances_from_ganeti()
346

  
347

  
348
if __name__ == "__main__":
349
    sys.exit(main())
b/snf-webproject/synnefo/webproject/manage.py
48 48
- override of --version command to display the snf-webproject version
49 49
"""
50 50

  
51
from django.core.management import ManagementUtility, setup_environ, \
51
from django.core.management import ManagementUtility, \
52 52
BaseCommand, LaxOptionParser, handle_default_options, find_commands, \
53 53
load_command_class
54 54

  
55 55
from django.core import management
56
from django.utils.importlib import import_module
57 56
from optparse import Option, make_option
58 57
from synnefo.util.version import get_component_version
59 58
from synnefo.lib.dictconfig import dictConfig
......
174 173
        except (AttributeError, EnvironmentError, ImportError):
175 174
            apps = []
176 175

  
177
        # Find the project directory
178
        try:
179
            from django.conf import settings
180
            module = import_module(settings.SETTINGS_MODULE)
181
            project_directory = setup_environ(module, settings.SETTINGS_MODULE)
182
        except (AttributeError, EnvironmentError, ImportError, KeyError):
183
            project_directory = None
184

  
185 176
        # Find and load the management module for each installed app.
186 177
        for app_name in apps:
187 178
            try:
......
191 182
            except ImportError:
192 183
                pass  # No management module - ignore this app
193 184

  
194
        if project_directory:
185
        if apps:
195 186
            # Remove the "startproject" command from self.commands, because
196 187
            # that's a django-admin.py command, not a manage.py command.
197 188
            del _commands['startproject']
198 189

  
199
            # Override the startapp command so that it always uses the
200
            # project_directory, not the current working directory
201
            # (which is default).
202
            #from django.core.management.commands.startapp import ProjectCommand
203
            #_commands['startapp'] = ProjectCommand(project_directory)
204

  
205 190
    return _commands
206 191

  
207 192

  

Also available in: Unified diff