示例#1
0
    def begin(self):
        if not os.path.exists(PLAYDOH):
            container = os.path.abspath(os.path.join(PLAYDOH, '..'))
            if not os.path.exists(container):
                os.mkdir(container)
            check_call(['git', 'clone', '--recursive',
                        '--branch', FF_PLAYDOH_BRANCH,
                        FF_PLAYDOH_REMOTE,
                        PLAYDOH])
        else:
            proj_sh = partial(shell, cwd=PLAYDOH)
            proj_sh('git pull origin %s' % FF_PLAYDOH_BRANCH)
            proj_sh('git submodule sync -q')
            proj_sh('git submodule update --init --recursive')

        st = os.path.join(PLAYDOH, 'settings', 'local.py')
        if os.path.exists(st):
            os.unlink(st)
        shutil.copy(os.path.join(PLAYDOH, 'settings', 'local.py-dist'),
                    st)

        with open(st, 'r') as f:
            new_st = f.read()
            new_st = new_st.replace("'USER': '******'",
                                    "'USER': '******'" % DB_USER)
            new_st = new_st.replace("'PASSWORD': ''",
                                    "'PASSWORD': '******'" % DB_PASS)
            new_st = new_st.replace("'NAME': 'playdoh_app'",
                                    "'NAME': '%s'" % DB_NAME)
            new_st = new_st.replace("SECRET_KEY = ''",
                                    "SECRET_KEY = 'testinglolz'")
            new_st = new_st + "\nfrom . import base\nINSTALLED_APPS = list(base.INSTALLED_APPS) + " \
                     "['django.contrib.admin']\n"

        with open(st, 'w') as f:
            f.write(new_st)

        extra = ''
        if DB_PASS:
            extra = '--password=%s' % DB_PASS
        shell('mysql -u %s %s -e "create database if not exists %s"'
              % (DB_USER, extra, DB_NAME))
        check_call([sys.executable, 'manage.py', 'syncdb', '--noinput'],
                   cwd=PLAYDOH)

        # For in-process tests:
        wd = os.getcwd()
        os.chdir(PLAYDOH)  # Simulate what happens in a real app.
        try:
            manage.setup_environ(os.path.join(PLAYDOH, 'manage.py'))
        finally:
            os.chdir(wd)
        # Puts path back to this dev version of funfactory:
        sys.path.insert(0, ROOT)
示例#2
0
    def begin(self):
        if not os.path.exists(PLAYDOH):
            container = os.path.abspath(os.path.join(PLAYDOH, ".."))
            if not os.path.exists(container):
                os.mkdir(container)
            check_call(["git", "clone", "--recursive", "--branch", FF_PLAYDOH_BRANCH, FF_PLAYDOH_REMOTE, PLAYDOH])
        else:
            proj_sh = partial(shell, cwd=PLAYDOH)
            proj_sh("git pull origin %s" % FF_PLAYDOH_BRANCH)
            proj_sh("git submodule sync -q")
            proj_sh("git submodule update --init --recursive")

        st = os.path.join(PLAYDOH, "project", "settings", "local.py")
        if os.path.exists(st):
            os.unlink(st)
        shutil.copy(os.path.join(PLAYDOH, "project", "settings", "local.py-dist"), st)

        with open(st, "r") as f:
            new_st = f.read()
            new_st = new_st.replace("'USER': '******'", "'USER': '******'" % DB_USER)
            new_st = new_st.replace("'PASSWORD': ''", "'PASSWORD': '******'" % DB_PASS)
            new_st = new_st.replace("'NAME': 'playdoh_app'", "'NAME': '%s'" % DB_NAME)
            new_st = new_st.replace("SECRET_KEY = ''", "SECRET_KEY = 'testinglolz'")
            new_st = (
                new_st + "\nfrom . import base\nINSTALLED_APPS = list(base.INSTALLED_APPS) + "
                "['django.contrib.admin']\n"
            )

        with open(st, "w") as f:
            f.write(new_st)

        extra = ""
        if DB_PASS:
            extra = "--password=%s" % DB_PASS
        shell('mysql -u %s %s -e "create database if not exists %s"' % (DB_USER, extra, DB_NAME))
        check_call([sys.executable, "manage.py", "syncdb", "--noinput"], cwd=PLAYDOH)

        # For in-process tests:
        wd = os.getcwd()
        os.chdir(PLAYDOH)  # Simulate what happens in a real app.
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
        try:
            manage.setup_environ(os.path.join(PLAYDOH, "manage.py"))
        finally:
            os.chdir(wd)
        # Puts path back to this dev version of funfactory:
        sys.path.insert(0, ROOT)
示例#3
0
# Edit this if necessary or override the variable in your environment.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webpay.settings')

# Add a temporary path so that we can import the funfactory
tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        'vendor', 'src', 'funfactory')
# Comment out to load funfactory from your site packages instead
sys.path.insert(0, tmp_path)

from funfactory import manage

# Let the path magic happen in setup_environ() !
sys.path.remove(tmp_path)

manage.setup_environ(__file__, more_pythonic=True)

# Specifically importing once the environment has been setup.
from django.conf import settings
newrelic_ini = getattr(settings, 'NEWRELIC_INI', None)

from webpay.utils import update_csp, validate_settings
update_csp()
validate_settings()

if newrelic_ini and os.path.exists(newrelic_ini):
    import newrelic.agent
    try:
        newrelic.agent.initialize(newrelic_ini)
    except newrelic.api.exceptions.ConfigurationError:
        import logging
示例#4
0
文件: manage.py 项目: rik/affiliates
#!/usr/bin/env python
import os
import sys

# Add a temporary path so that we can import the funfactory
tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'vendor',
                        'src', 'funfactory')
sys.path.append(tmp_path)

from funfactory import manage

# Let the path magic happen in setup_environ() !
sys.path.remove(tmp_path)

manage.setup_environ(__file__)

if __name__ == "__main__":
    manage.main()
示例#5
0
#!/usr/bin/env python
import os
import sys

# Add a temporary path so that we can import the funfactory
tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        'vendor', 'src', 'funfactory')
sys.path.append(tmp_path)

from funfactory import manage

# Let the path magic happen in setup_environ() !
sys.path.remove(tmp_path)


manage.setup_environ(__file__)

if __name__ == "__main__":
    manage.main()
示例#6
0
文件: conf.py 项目: ngokevin/cyder
    # For local development in a virtualenv:
    from funfactory import manage
except ImportError, e:
    # Production:
    # Add a temporary path so that we can import the funfactory
    tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'vendor', 'src', 'funfactory')
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)


manage.setup_environ("../manage.py", more_pythonic=True)

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'
示例#7
0
    def begin(self):
        if os.path.exists(ENVIRONMENT_NOTE):
            if self._read_last_environment() != self._this_environment():
                shutil.rmtree(PLAYDOH)

        if not os.path.exists(PLAYDOH):
            container = os.path.abspath(os.path.join(PLAYDOH, '..'))
            if not os.path.exists(container):
                os.mkdir(container)
            check_call(['git', 'clone', '--recursive',
                        '--branch', FF_PLAYDOH_BRANCH,
                        FF_PLAYDOH_REMOTE,
                        PLAYDOH])
        else:

            proj_sh = partial(shell, cwd=PLAYDOH)
            proj_sh('git pull origin %s' % FF_PLAYDOH_BRANCH)
            proj_sh('git submodule sync -q')
            proj_sh('git submodule update --init --recursive')

        self._write_last_environment()

        st = os.path.join(PLAYDOH, 'project', 'settings', 'local.py')
        if os.path.exists(st):
            os.unlink(st)
        shutil.copy(os.path.join(PLAYDOH, 'project', 'settings',
                                 'local.py-dist'),
                    st)

        with open(st, 'r') as f:
            new_st = f.read()
            new_st = new_st.replace("'USER': '******'",
                                    "'USER': '******'" % DB_USER)
            new_st = new_st.replace("'PASSWORD': ''",
                                    "'PASSWORD': '******'" % DB_PASS)
            new_st = new_st.replace("'HOST': ''",
                                    "'HOST': '%s'" % DB_HOST)
            new_st = new_st.replace("'NAME': 'playdoh_app'",
                                    "'NAME': '%s'" % DB_NAME)
            new_st = new_st.replace("SECRET_KEY = ''",
                                    "SECRET_KEY = 'testinglolz'")
            new_st = new_st + "\nfrom . import base\nINSTALLED_APPS = list(base.INSTALLED_APPS) + " \
                     "['django.contrib.admin']\n"

        with open(st, 'w') as f:
            f.write(new_st)

        extra = ''
        if DB_PASS:
            extra = '--password=%s' % DB_PASS
        if DB_HOST:
            extra += ' -h %s' % DB_HOST
        shell('mysql -u %s %s -e "create database if not exists %s"'
              % (DB_USER, extra, DB_NAME))
        check_call([sys.executable, 'manage.py', 'syncdb', '--noinput'],
                   cwd=PLAYDOH)

        # For in-process tests:
        wd = os.getcwd()
        os.chdir(PLAYDOH)  # Simulate what happens in a real app.
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
        try:
            manage.setup_environ(os.path.join(PLAYDOH, 'manage.py'))
        finally:
            os.chdir(wd)
        # Puts path back to this dev version of funfactory:
        sys.path.insert(0, ROOT)

        # simulate what django does, which is to import the root urls.py
        # once everything has been set up (e.g. setup_environ())
        from funfactory.monkeypatches import patch
        patch()
示例#8
0
    def begin(self):
        if os.path.exists(ENVIRONMENT_NOTE):
            if self._read_last_environment() != self._this_environment():
                shutil.rmtree(PLAYDOH)

        if not os.path.exists(PLAYDOH):
            container = os.path.abspath(os.path.join(PLAYDOH, '..'))
            if not os.path.exists(container):
                os.mkdir(container)
            check_call(['git', 'clone', '--recursive',
                        '--branch', FF_PLAYDOH_BRANCH,
                        FF_PLAYDOH_REMOTE,
                        PLAYDOH])
        else:

            proj_sh = partial(shell, cwd=PLAYDOH)
            proj_sh('git pull origin %s' % FF_PLAYDOH_BRANCH)
            proj_sh('git submodule sync -q')
            proj_sh('git submodule update --init --recursive')

        self._write_last_environment()

        st = os.path.join(PLAYDOH, 'project', 'settings', 'local.py')
        if os.path.exists(st):
            os.unlink(st)
        shutil.copy(os.path.join(PLAYDOH, 'project', 'settings',
                                 'local.py-dist'),
                    st)

        with open(st, 'r') as f:
            new_st = f.read()
            new_st = new_st.replace("'USER': '******'",
                                    "'USER': '******'" % DB_USER)
            new_st = new_st.replace("'PASSWORD': ''",
                                    "'PASSWORD': '******'" % DB_PASS)
            new_st = new_st.replace("'HOST': ''",
                                    "'HOST': '%s'" % DB_HOST)
            new_st = new_st.replace("'NAME': 'playdoh_app'",
                                    "'NAME': '%s'" % DB_NAME)
            new_st = new_st.replace("SECRET_KEY = ''",
                                    "SECRET_KEY = 'testinglolz'")
            new_st = new_st + "\nfrom . import base\nINSTALLED_APPS = list(base.INSTALLED_APPS) + " \
                     "['django.contrib.admin']\n"
            new_st = new_st + "\nSITE_URL = ''\n"

        with open(st, 'w') as f:
            f.write(new_st)

        extra = ''
        if DB_PASS:
            extra = '--password=%s' % DB_PASS
        if DB_HOST:
            extra += ' -h %s' % DB_HOST
        shell('mysql -u %s %s -e "create database if not exists %s"'
              % (DB_USER, extra, DB_NAME))
        check_call([sys.executable, 'manage.py', 'syncdb', '--noinput'],
                   cwd=PLAYDOH)

        # For in-process tests:
        wd = os.getcwd()
        os.chdir(PLAYDOH)  # Simulate what happens in a real app.
        os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
        try:
            manage.setup_environ(os.path.join(PLAYDOH, 'manage.py'))
        finally:
            os.chdir(wd)
        # Puts path back to this dev version of funfactory:
        sys.path.insert(0, ROOT)

        # simulate what django does, which is to import the root urls.py
        # once everything has been set up (e.g. setup_environ())
        from funfactory.monkeypatches import patch
        patch()
示例#9
0
文件: test.py 项目: osunws/cyder
    # For local development in a virtualenv:
    from funfactory import manage
except ImportError, e:
    # Production:
    # Add a temporary path so that we can import the funfactory
    tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'vendor', 'src', 'funfactory')
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)


manage.setup_environ("/nfs/milo/u1/uberj/cyder_env/cyder/manage.py", more_pythonic=True)
from django.core.exceptions import ValidationError

from cyder.cydns.domain.models import Domain
from cyder.cydns.reverse_domain.models import ReverseDomain
from cyder.cydns.soa.models import SOA
from cyder.cydns.ip.models import Ip
from cyder.cydns.address_record.models import AddressRecord
from cyder.cydns.nameserver.models import Nameserver
from cyder.cybind.build import *

def add_some_records():
    s1, s1_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="foo.gaz2")
    s2, s2_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="baz.gaz2")
    d, _ = Domain.objects.get_or_create(name="gaz")
    d.soa = None
示例#10
0
# Edit this if necessary or override the variable in your environment.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings_local')

try:
    # For local development in a virtualenv:
    from funfactory import manage
except ImportError:
    # Production:
    # Add a temporary path so that we can import the funfactory
    tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'vendor', 'src', 'funfactory')
    sys.path.append(tmp_path)

    from funfactory import manage

    # Let the path magic happen in setup_environ() !
    sys.path.remove(tmp_path)

if 'harvest' in sys.argv:
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_test'
    import datetime_stub
    import paypal_stub
    datetime_stub.patch_step1()
    paypal_stub.patch()

manage.setup_environ(__file__, more_pythonic=False) # False as we don't use new Playdoh pattern

if __name__ == "__main__":
    manage.main()