Exemplo n.º 1
0
def migration():
    """
    Integrate with south schema migration
    """

    #activate env        
    with cd('/'.join([deployment_root(),'env',env.project_fullname,'project',env.project_package_name,'sitesettings'])):
        #migrates all or specific env.migration
        venv = '/'.join([deployment_root(),'env',env.project_fullname,'bin','activate'])
        cmdpt1 = ' '.join(['source',venv,'&&'])
        
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        for site in site_ids:
            for settings_file in _sitesettings_files():
                site_settings = '.'.join([env.project_package_name,'sitesettings',settings_file.replace('.py','')])
                cmdpt2 = ' '.join(["python manage.py migrate",env.migration])
                if hasattr(env,"fakemigration"):
                    cmdpt2 = ' '.join([cmdpt2,'--fake'])
                cmdpt2 = ''.join([cmdpt2,'--settings=',site_settings])
                if env.verbosity:
                    print " *", cmdpt2
                output = sudo(' '.join([cmdpt1,cmdpt2]),user='******'% site)
            if env.verbosity:
                print output
    return           
Exemplo n.º 2
0
 def handle_host(self,*args, **options):
     if not hasattr(state.env,'sites_created'):
         local_settings_dir = os.path.join(os.getcwd(),state.env.project_name,'sitesettings')
         sites = _get_django_sites()
         site_ids = sites.keys()
         site_ids.sort()
         for id in site_ids:
             sitesetting_path = os.path.join(state.env.project_name,'sitesettings',''.join([sites[id].replace('.','_'),'.py']))
             if not os.path.exists(sitesetting_path):
                 f = open(sitesetting_path, "w+")
                 f.write("from %s.sitesettings.settings import *"% state.env.project_name)
                 f.write("\nSITE_ID=%s\n"% str(id))
                 f.close()
         state.env.sites_created = True
     created = deploy_sitesettings()
     with settings(patch=True):
         deploy_wsgi()
         deploy_webconf()
     
     #activate sites
     activate_sites = [''.join([d.replace('.','_'),'-',state.env.project_version,'.conf']) for d in domain_sites()]
     site_paths = ['/etc/apache2','/etc/nginx']
     
     #activate new sites
     for path in site_paths:
         for site in activate_sites:
             if not exists('/'.join([path,'sites-enabled',site])):
                 sudo("chmod 644 %s" % '/'.join([path,'sites-available',site]))
                 sudo("ln -s %s/sites-available/%s %s/sites-enabled/%s"% (path,site,path,site))
                 if state.env.verbosity:
                     print " * enabled", "%s/sites-enabled/%s"% (path,site)
     reload_webservers()
Exemplo n.º 3
0
def sync_db():
    """
    Runs the django syncdb command
    """
    with cd('/'.join([
            deployment_root(), 'env', env.project_fullname, 'project',
            env.project_package_name, 'sitesettings'
    ])):
        venv = '/'.join([
            deployment_root(), 'env', env.project_fullname, 'bin', 'activate'
        ])
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        for site in site_ids:
            for settings_file in _sitesettings_files():
                site_settings = '.'.join([
                    env.project_package_name, 'sitesettings',
                    settings_file.replace('.py', '')
                ])
                if env.verbosity:
                    print " * django-admin.py syncdb --noinput --settings=%s" % site_settings
                output = sudo(' '.join([
                    'source', venv, '&&',
                    "django-admin.py syncdb --noinput --settings=%s" %
                    site_settings
                ]),
                              user='******' % site)
                if env.verbosity:
                    print output
Exemplo n.º 4
0
def sync_db():
    """
    Runs the django syncdb command
    """
    with cd('/'.join([deployment_root(),'env',env.project_fullname,'project',env.project_package_name,'sitesettings'])):
        venv = '/'.join([deployment_root(),'env',env.project_fullname,'bin','activate'])
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        for site in site_ids:
            for settings_file in _sitesettings_files():
                site_settings = '.'.join([env.project_package_name,'sitesettings',settings_file.replace('.py','')])
                if env.verbosity:
                    print " * python manage.py syncdb --noinput --settings=%s"% site_settings
                output = sudo(' '.join(['source',venv,'&&',"./manage.py syncdb --noinput --settings=%s"% site_settings]),
                              user='******'% site)
                if env.verbosity:
                    print output
Exemplo n.º 5
0
def migration():
    """
    Integrate with south schema migration
    """

    #activate env
    with cd('/'.join([
            deployment_root(), 'env', env.project_fullname, 'project',
            env.project_package_name, 'sitesettings'
    ])):
        #migrates all or specific env.migration
        venv = '/'.join([
            deployment_root(), 'env', env.project_fullname, 'bin', 'activate'
        ])
        cmdpt1 = ' '.join(['source', venv, '&&'])

        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        for site in site_ids:
            for settings_file in _sitesettings_files():
                site_settings = '.'.join([
                    env.project_package_name, 'sitesettings',
                    settings_file.replace('.py', '')
                ])
                cmdpt2 = ' '.join(["django-admin.py migrate", env.migration])
                if hasattr(env, "fakemigration"):
                    cmdpt2 = ' '.join([cmdpt2, '--fake'])
                cmdpt2 = ''.join([cmdpt2, '--settings=', site_settings])
                if env.verbosity:
                    print " *", cmdpt2
                output = sudo(' '.join([cmdpt1, cmdpt2]),
                              user='******' % site)
            if env.verbosity:
                print output
    return