Commit fa33847d authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

wheezy: Remove setup_environ

From Django docs:
This function temporarily modified sys.path in order to make the parent
“project” directory importable under the old flat startproject layout.
This function is now deprecated, as its path workarounds are no longer
needed with the new and default project layout.

This function was never documented or part of the public API, but it was
widely recommended for use in setting up a “Django environment” for a
user script. These uses should be replaced by setting the
DJANGO_SETTINGS_MODULE environment variable or using

parent a9499b17
......@@ -36,15 +36,15 @@ and implements the message wait and dispatch loops. Actual messages are
handled in the dispatched functions.
from import setup_environ
# Fix path to import synnefo settings
import sys
import os
path = os.path.normpath(os.path.join(os.getcwd(), '..'))
from synnefo import settings
from synnefo import settings as snf_settings
from django.conf import settings
from django.db import close_connection
......@@ -113,7 +113,7 @@ class Dispatcher:
# Declare queues and exchanges
exchange = settings.EXCHANGE_GANETI
exchange = snf_settings.EXCHANGE_GANETI
exchange_dl = queues.convert_exchange_to_dead(exchange)
......@@ -59,22 +59,13 @@ For G, the operating state is True if the machine is up, False otherwise.
import logging
import sys
import itertools
from import setup_environ
from synnefo import settings
except ImportError:
raise Exception("Cannot import settings, make sure PYTHONPATH contains "
"the parent directory of the Synnefo Django project.")
from datetime import datetime, timedelta
from synnefo.db.models import (VirtualMachine, pooled_rapi_client)
from synnefo.logic.rapi import GanetiApiError
from synnefo.logic.backend import get_ganeti_instances, get_backends
from synnefo.logic import utils
from django.conf import settings
log = logging.getLogger()
......@@ -338,12 +329,3 @@ def hanging_networks(backend, GNets):
if group_list != groups:
hanging[id] = groups - group_list
return hanging
# Only for testing this module individually
def main():
print get_instances_from_ganeti()
if __name__ == "__main__":
......@@ -48,12 +48,11 @@ The extended class provides the following:
- override of --version command to display the snf-webproject version
from import ManagementUtility, setup_environ, \
from import ManagementUtility, \
BaseCommand, LaxOptionParser, handle_default_options, find_commands, \
from django.core import management
from django.utils.importlib import import_module
from optparse import Option, make_option
from synnefo.util.version import get_component_version
from synnefo.lib.dictconfig import dictConfig
......@@ -174,14 +173,6 @@ def get_commands():
except (AttributeError, EnvironmentError, ImportError):
apps = []
# Find the project directory
from django.conf import settings
module = import_module(settings.SETTINGS_MODULE)
project_directory = setup_environ(module, settings.SETTINGS_MODULE)
except (AttributeError, EnvironmentError, ImportError, KeyError):
project_directory = None
# Find and load the management module for each installed app.
for app_name in apps:
......@@ -191,17 +182,11 @@ def get_commands():
except ImportError:
pass # No management module - ignore this app
if project_directory:
if apps:
# Remove the "startproject" command from self.commands, because
# that's a command, not a command.
del _commands['startproject']
# Override the startapp command so that it always uses the
# project_directory, not the current working directory
# (which is default).
#from import ProjectCommand
#_commands['startapp'] = ProjectCommand(project_directory)
return _commands
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment