def init_django(argv): try: from django import VERSION if VERSION[0] == 1 and VERSION[1] < 4: django_lt_14 = True else: django_lt_14 = False except: django_lt_14 = True try: from django.conf import settings try: # Needed in Django 1.8+; not sure if it fails in earlier versions import django django.setup() except: pass from django.core.management import import_module module = import_module(settings.SETTINGS_MODULE) if django_lt_14: from django.core.management import setup_environ manage_dir = setup_environ(module, settings.SETTINGS_MODULE) else: manage_dir = get_manage_dir_from_settings(module) except: project_dir = get_project_dir_from_argv(argv) sys.path.insert(0, os.path.abspath(project_dir)) sys.path.append(os.path.abspath(os.path.join(project_dir, '..'))) import settings if django_lt_14: from django.core.management import setup_environ manage_dir = setup_environ(settings) else: manage_dir = get_manage_dir_from_settings(settings) return manage_dir
__copyright__ = 'Copyright 2009, Daniel Mizyrycki' __license__ = 'BSD' __version__ = '0.1.0' __maintainer__ = __author__ __email__ = '*****@*****.**' __status__ = 'Development' __url__ = 'http://pypi.python.org/pypi/django-selenium-test-runner' __summary__ = __doc__ from django.conf import settings from django.core.management import setup_environ, import_module, call_command if not hasattr(settings, 'SETTINGS_MODULE'): settings.configure() else: PROJECT_PATH = setup_environ(import_module(settings.SETTINGS_MODULE), settings.SETTINGS_MODULE) import os, sys, re, threading, unittest, shutil from urlparse import urlparse from subprocess import Popen, PIPE from signal import SIGHUP from time import sleep from django.db import connection from django.db.models import get_app, get_apps from django.test.simple import run_tests as base_run_tests from django.core.handlers.wsgi import WSGIHandler from django.contrib import admin from wsgiserver import CherryPyWSGIServer, WSGIPathInfoDispatcher from mediahandler import MediaHandler