コード例 #1
0
ファイル: conftest.py プロジェクト: aibon/django-fancypages
def pytest_configure():
    importer.install()

    # Setup command is only available in Django 1.7+ but is required
    # to properly initialise the Django app config.
    if django.VERSION[1] >= 7:
        django.setup()
コード例 #2
0
def pytest_configure():
    importer.install()

    # Setup command is only available in Django 1.7+ but is required
    # to properly initialise the Django app config.
    if django.VERSION[1] >= 7:
        django.setup()
コード例 #3
0
def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wither.config")
    os.environ.setdefault("DJANGO_CONFIGURATION", "Local")

    importer.install()

    if settings.DEBUG:
        if os.environ.get("RUN_MAIN") or os.environ.get("WERKZEUG_RUN_MAIN"):
            import ptvsd

            ptvsd.enable_attach(address=("0.0.0.0", 3000))
            print("Attached remote debugger")

    try:
        from configurations.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django  # noqa
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?")
        raise

    execute_from_command_line(sys.argv)
コード例 #4
0
ファイル: fabfile.py プロジェクト: kalpathy/codalab
def env_setup(config=env.CONFIG,settings_module='codalab.settings'):
    if config is None:
        
    sys.path.append('.')
    os.environ['DJANGO_CONFIGURATION'] = config
    os.environ["DJANGO_SETTINGS_MODULE"] = settings_module
    from fabric.contrib import django
    
    from configurations import importer

    importer.install()
    
    django.settings_module(settings_module)
    from django.conf import settings as django_settings

    env.roledefs = django_settings.DEPLOY_ROLES
    env.django_settings = django_settings

@task
def local(**kwargs):    
    env.run = lrun
    env_setup(**kwargs)

@task
def remote(**kwargs):    
    env.run = run
    env_setup(**kwargs)

@task
def clone_repo(repo_url='https://github.com/codalab/codalab.git',path=env.conf.DEPLOY_PATH):
    env.run('git clone %s %s' % (repo_url, path))
    
@task
def provision(config='Dev'):
    clone_repo()
    with cd(env.conf.DEPLOY_PATH):
        sudo('/bin/bash codalab/scripts/provision %s' % env.conf.DEPLOY_USER)
        sudo('python manage.py config_gen --configuration=%s' % config,
             user=env.conf.DEPLOY_USER)
        
@task
def bootstrap():
    make_virtualenv(path='venv', system_site_packages=False)
    with virtualenv('venv'):
        run('pip install --upgrade pip')
        run('pip install --upgrade distribute')
        run('rm -rf codalab_src')
        run("git clone %s codalab_src" % env.django_settings.SOURCE_GIT_URL)
    put(os.path.join(THIS_SETTINGS_DIR,'deploy.py'), 'codalab_src/codalab/codalab/settings')

    with virtualenv('venv'):
        run('cd codalab_src && bash ./requirements')
            
        
@task
def install():
    env.run('deploymentcmd')
コード例 #5
0
def setup(app):
    import django
    from configurations import importer

    importer.install()
    django.setup()

    # Register the docstring processor with sphinx
    app.connect('autodoc-process-docstring', process_docstring)
コード例 #6
0
ファイル: conf.py プロジェクト: aibon/django-fancypages
def setup(app):
    import django
    from configurations import importer

    importer.install()
    django.setup()

    # Register the docstring processor with sphinx
    app.connect('autodoc-process-docstring', process_docstring)
コード例 #7
0
ファイル: manage.py プロジェクト: NickSablukov/ubex_autoapi
def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
    os.environ.setdefault("DJANGO_CONFIGURATION", "ProjectConfiguration")
    importer.install()
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)
コード例 #8
0
def connect():
    from mongolog.handlers import MongoHandler
    from configurations import importer
    import os
    import logging
    from hbproject import settings
    import dotenv

    dotenv.read_dotenv()
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hbproject.settings')
    os.environ.setdefault('DJANGO_CONFIGURATION', 'Development')

    importer.install()

    log = logging.getLogger('heliosburn')
    log.setLevel(logging.DEBUG)
    log.addHandler(MongoHandler.to(db=settings.MONGODB_DATABASE['production'], collection='log'))
    return log
コード例 #9
0
def before_all(context):
    ### Take a TestRunner hostage.
    from django.test.simple import DjangoTestSuiteRunner
    # We'll use thise later to frog-march Django through the motions
    # of setting up and tearing down the test environment, including
    # test databases.
    importer.install(check_options=True)
    context.runner = DjangoTestSuiteRunner()

    ## If you use South for migrations, uncomment this to monkeypatch
    ## syncdb to get migrations to run.
    from south.management.commands import patch_for_test_db_setup
    patch_for_test_db_setup()

    from wsgi_intercept import requests_intercept
    import wsgi_intercept
    
    from django.core.handlers.wsgi import WSGIHandler
    from django.conf import settings
    
    host = context.host = '{{ cookiecutter.domain_name }}'
    port = context.port = getattr(settings, 'TESTING_INTERCEPT_PORT', 80)
    # NOTE: Nothing is actually listening on this port. wsgi_intercept
    # monkeypatches the networking internals to use a fake socket when
    # connecting to this port.
    requests_intercept.install()
    wsgi_intercept.add_wsgi_intercept(host, port, WSGIHandler)

    def browser_url(url):
        """Create a URL for the virtual WSGI server.

        e.g context.browser_url('/'), context.browser_url(reverse('my_view'))
        """
        return urlparse.urljoin('http://%s:%d/' % (host, port), url)

    context.browser_url = browser_url
    context.runner.setup_test_environment()
    context.old_db_config = context.runner.setup_databases()
    from django.core.management import call_command
    call_command('createsuperuser',
                 interactive=False,
                 username="******",
                 email="*****@*****.**")
    call_command('migrate')
コード例 #10
0
def connect():
    from mongolog.handlers import MongoHandler
    from configurations import importer
    import os
    import logging
    from hbproject import settings
    import dotenv

    dotenv.read_dotenv()
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hbproject.settings')
    os.environ.setdefault('DJANGO_CONFIGURATION', 'Development')

    importer.install()

    log = logging.getLogger('heliosburn')
    log.setLevel(logging.DEBUG)
    log.addHandler(
        MongoHandler.to(db=settings.MONGODB_DATABASE['production'],
                        collection='log'))
    return log
コード例 #11
0
ファイル: config.py プロジェクト: Rustem/nose2django
    def handleArgs(self, event):
        """Nose2 hook for the handling the command line args"""
        # settings resolution order:
        # command line > cfg file > environ
        if self.djsettings:
            os.environ['DJANGO_SETTINGS_MODULE'] = self.djsettings
        if self.djconfig:
            os.environ['DJANGO_CONFIGURATION'] = self.djconfig
        # test for django-configurations package
        try:
            from configurations import importer
            importer.install()
        except ImportError:
            pass
        from django.conf import settings

        try:
            from south.management.commands import patch_for_test_db_setup
            patch_for_test_db_setup()
        except ImportError:
            pass
コード例 #12
0
ファイル: celery.py プロジェクト: HEG-Arc/marmix
#
# You should have received a copy of the GNU General Public License
# along with MarMix. If not, see <http://www.gnu.org/licenses/>.

# Stdlib imports
from __future__ import absolute_import
import os

# Core Django imports
from django.conf import settings

# Third-party app imports
from celery import Celery

# MarMix imports


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config')
os.environ.setdefault('DJANGO_CONFIGURATION', 'Local')

from configurations import importer
importer.install()

app = Celery('config')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(bind=True)
def debug_task(self):
    print('Request: {0!r}'.format(self.request))
コード例 #13
0
ファイル: settings.py プロジェクト: gabelula/froide
# -*- coding: utf-8 -*-
from configurations import Configuration, importer, values
importer.install(check_options=True)

import os
import sys
import re

rec = lambda x: re.compile(x, re.I | re.U)

gettext = lambda s: s

# Django settings for froide project.


class Base(Configuration):
    DEBUG = values.BooleanValue(True)
    TEMPLATE_DEBUG = values.BooleanValue(DEBUG)

    DATABASES = values.DatabaseURLValue('sqlite:///dev.db')
    CONN_MAX_AGE = None

    INSTALLED_APPS = values.ListValue([
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
        'django.contrib.comments',
コード例 #14
0
def pytest_configure():
    importer.install()
    django.setup()
コード例 #15
0
ファイル: settings.py プロジェクト: tzwenn/froide
# -*- coding: utf-8 -*-
from configurations import Configuration, importer, values
importer.install(check_options=True)

import os
import sys
import re

rec = lambda x: re.compile(x, re.I | re.U)

gettext = lambda s: s

# Django settings for froide project.


class Base(Configuration):
    DEBUG = values.BooleanValue(True)
    TEMPLATE_DEBUG = values.BooleanValue(DEBUG)

    DATABASES = values.DatabaseURLValue('sqlite:///dev.db')
    CONN_MAX_AGE = None

    INSTALLED_APPS = values.ListValue([
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
        'django_comments',
コード例 #16
0
import os

from celery import Celery, signals
from configurations import importer
from django.conf import settings

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
os.environ.setdefault("DJANGO_CONFIGURATION", "Production")

app = Celery("{{ project_name }}")
app.config_from_object("django.conf:settings")
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

importer.install()
コード例 #17
0
def plugin(version):
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
    os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev')
    install()
    return main.plugin(version)