当前位置: 首页>>代码示例>>Python>>正文


Python environment.deployment_root函数代码示例

本文整理汇总了Python中woven.environment.deployment_root函数的典型用法代码示例。如果您正苦于以下问题:Python deployment_root函数的具体用法?Python deployment_root怎么用?Python deployment_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了deployment_root函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: deploy_project

def deploy_project():
    """
    Deploy to the project directory in the virtualenv
    """
    
    project_root = '/'.join([deployment_root(),'env',env.project_fullname,'project'])
    local_dir = os.getcwd()
    
    if env.verbosity:
        print env.host,"DEPLOYING project", env.project_fullname
    #Exclude a few things that we don't want deployed as part of the project folder
    rsync_exclude = ['local_settings*','*.pyc','*.log','.*','/build','/dist','/media*','/static*','/www','/public','/template*']

    #make site local settings if they don't already exist
    _make_local_sitesettings()
    created = deploy_files(local_dir, project_root, rsync_exclude=rsync_exclude)
    if not env.patch:
        #hook the project into sys.path
        pyvers = run('python -V').split(' ')[1].split('.')[0:2] #Python x.x.x
        sitepackages = ''.join(['lib/python',pyvers[0],'.',pyvers[1],'/site-packages'])
        link_name = '/'.join([deployment_root(),'env',env.project_fullname,sitepackages,env.project_package_name])
        target = '/'.join([project_root,env.project_package_name])
        run(' '.join(['ln -s',target,link_name]))
        
        #make sure manage.py has exec permissions
        managepy = '/'.join([target,'sitesettings','manage.py'])
        if exists(managepy):
            sudo('chmod ugo+x %s'% managepy)
    
    return created
开发者ID:andreypaa,项目名称:woven,代码行数:30,代码来源:project.py

示例2: deploy_project

def deploy_project():
    """
    Deploy to the project directory in the virtualenv
    """
    
    project_root = '/'.join([deployment_root(),'env',env.project_fullname,'project'])
    local_dir = os.getcwd()
    
    if env.verbosity:
        print env.host,"DEPLOYING project", env.project_fullname
    #Exclude a few things that we don't want deployed as part of the project folder
    rsync_exclude = ['local_settings*','*.pyc','*.log','.*','/build','/dist','/media*','/static*','/www','/public','/template*']

    #make site local settings if they don't already exist
    _make_local_sitesettings()
    created = deploy_files(local_dir, project_root, rsync_exclude=rsync_exclude)
    if not env.patch:
        #hook the project into sys.path
        remote_python_version = run('''python -c "import sys; print 'python%d.%d' % (sys.version_info.major, sys.version_info.minor)"''').strip()
        link_name = '/'.join([deployment_root(),'env',env.project_fullname,'lib', remote_python_version, 'site-packages',env.project_package_name])
        target = '/'.join([project_root,env.project_package_name])

        #create any missing dirs
        run('mkdir -p ' + os.path.dirname(link_name))
        run(' '.join(['ln -s',target,link_name]))
        
        #make sure manage.py has exec permissions
        managepy = '/'.join([target,'sitesettings','manage.py'])
        if exists(managepy):
            sudo('chmod ugo+x %s'% managepy)
    
    return created
开发者ID:popen2,项目名称:woven,代码行数:32,代码来源:project.py

示例3: migration

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_%s'% site)
            if env.verbosity:
                print output
    return           
开发者ID:wil,项目名称:woven,代码行数:27,代码来源:virtualenv.py

示例4: deploy_wsgi

def deploy_wsgi():
    """
    deploy python wsgi file(s)
    """
    remote_dir = "/".join([deployment_root(), "env", env.project_fullname, "wsgi"])
    deployed = []
    if env.verbosity:
        print env.host, "DEPLOYING wsgi", remote_dir
    domains = domain_sites()
    for domain in domains:
        deployed += mkdirs(remote_dir)
        with cd(remote_dir):
            u_domain = domain.replace(".", "_")
            filename = "%s.wsgi" % u_domain
            context = {
                "deployment_root": deployment_root(),
                "user": env.user,
                "project_name": env.project_name,
                "u_domain": u_domain,
                "root_domain": env.root_domain,
            }
            upload_template("/".join(["woven", "django-wsgi-template.txt"]), filename, context)
            if env.verbosity:
                print " * uploaded", filename
            # finally set the ownership/permissions
            # We'll use the group to allow www-data execute
            sudo("chown %s:www-data %s" % (env.user, filename))
            run("chmod ug+xr %s" % filename)
    return deployed
开发者ID:aweakley,项目名称:woven,代码行数:29,代码来源:webservers.py

示例5: _get_django_sites

def _get_django_sites():
    """
    Get a list of sites as dictionaries {site_id:'domain.name'}

    """
    deployed = version_state('deploy_project')
    if not env.sites and 'django.contrib.sites' in env.INSTALLED_APPS and deployed:
        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'])
            #since this is the first time we run ./manage.py on the server it can be
            #a point of failure for installations
            with settings(warn_only=True):
                output = run(' '.join(['source',venv,'&&',"./manage.py dumpdata sites"]))

                if output.failed:
                    print "ERROR: There was an error running ./manage.py on the node"
                    print "See the troubleshooting docs for hints on how to diagnose deployment issues"
                    if hasattr(output, 'stderr'):
                        print output.stderr
                    sys.exit(1)
            output = output.split('\n')[-1] #ignore any lines prior to the data being dumped
            sites = json.loads(output)
            env.sites = {}
            for s in sites:
                env.sites[s['pk']] = s['fields']['domain']
    return env.sites
开发者ID:wil,项目名称:woven,代码行数:26,代码来源:webservers.py

示例6: sync_db

def sync_db():
    """
    Runs the django syncdb command
    """
    with cd('/'.join([deployment_root(),'env',env.project_fullname,'project',env.project_name,'sitesettings'])):
        venv = '/'.join([deployment_root(),'env',env.project_fullname,'bin','activate'])
        if env.verbosity:
            print " * python manage.py syncdb --noinput"
        output = run(' '.join(['source',venv,'&&',"./manage.py syncdb --noinput"]))
        if env.verbosity:
            print output
开发者ID:aweakley,项目名称:woven,代码行数:11,代码来源:virtualenv.py

示例7: rmvirtualenv

def rmvirtualenv():
    """
    Remove the current or ``env.project_version`` environment and all content in it
    """
    path = '/'.join([deployment_root(),'env',env.project_fullname])
    link = '/'.join([deployment_root(),'env',env.project_name])
    if version_state('mkvirtualenv'):
        sudo(' '.join(['rm -rf',path]))
        sudo(' '.join(['rm -f',link]))
        sudo('rm -f /var/local/woven/%s*'% env.project_fullname)
        set_version_state('mkvirtualenv',delete=True)
开发者ID:wil,项目名称:woven,代码行数:11,代码来源:virtualenv.py

示例8: rmvirtualenv

def rmvirtualenv():
    """
    Remove the current or ``env.project_version`` environment and all content in it
    """
    path = '/'.join([deployment_root(),'env',env.project_fullname])
    if server_state('mkvirtualenv'):
        sudo(' '.join(['rm -rf',path]))
        set_server_state('mkvirtualenv',delete=True)
    #If there are no further remaining envs we'll delete the home directory to effectively teardown the project
    if not server_state('mkvirtualenv',prefix=True):
        sudo('rm -rf '+deployment_root())        
开发者ID:aweakley,项目名称:woven,代码行数:11,代码来源:virtualenv.py

示例9: deploy_static

def deploy_static():
    """
    Deploy static (application) versioned media
    """
    if (not env.STATIC_ROOT and not env.ADMIN_MEDIA_PREFIX) or 'http://' in env.STATIC_URL: return
        
    remote_dir = '/'.join([deployment_root(),'env',env.project_fullname,'static'])
    
    #if app media is not handled by django-staticfiles we can install admin media by default
    if 'django.contrib.admin' in env.INSTALLED_APPS and not env.STATIC_ROOT:
        if env.MEDIA_URL in env.ADMIN_MEDIA_PREFIX:
            print "ERROR: Your ADMIN_MEDIA_PREFIX must not be on the same path as your MEDIA_URL"
            print "for example you cannot use MEDIA_URL = /media/ and ADMIN_MEDIA_PREFIX = /media/admin/"
            sys.exit(1)
        env.STATIC_URL = env.ADMIN_MEDIA_PREFIX    
        admin = AdminMediaHandler('DummyApp')
        local_dir = admin.media_dir
        remote_dir =  ''.join([remote_dir,env.ADMIN_MEDIA_PREFIX])
    else:
        if env.MEDIA_URL in env.STATIC_URL:
            print "ERROR: Your STATIC_URL must not be on the same path as your MEDIA_URL"
            print "for example you cannot use MEDIA_URL = /media/ and STATIC_URL = /media/static/"
            sys.exit(1)
        elif env.STATIC_ROOT:
            local_dir = env.STATIC_ROOT
            static_url = env.STATIC_URL[1:]
            if static_url:
                remote_dir = '/'.join([remote_dir,static_url])
        else: return
    if env.verbosity:
        print env.host,"DEPLOYING static",remote_dir
    return deploy_files(local_dir,remote_dir)
开发者ID:aweakley,项目名称:woven,代码行数:32,代码来源:project.py

示例10: deploy_templates

def deploy_templates():
    """ Deploy any templates from your shortest TEMPLATE_DIRS setting. """
    deployed = None
    if not hasattr(env, 'project_template_dir'):
        # The normal pattern would mean the shortest path is the main
        # one. It's probably the last listed.
        length = 1000
        for directory in env.TEMPLATE_DIRS:
            if directory:
                len_dir = len(directory)
                if len_dir < length:
                    length = len_dir
                    env.project_template_dir = directory

    if hasattr(env, 'project_template_dir'):
        remote_dir = '/'.join([
                deployment_root(),
                'env',
                env.project_fullname,
                'templates',
                ])
        if env.verbosity:
            print env.host, "DEPLOYING templates", remote_dir
        deployed = deploy_files(env.project_template_dir, remote_dir)
    return deployed
开发者ID:depleater,项目名称:woven,代码行数:25,代码来源:project.py

示例11: deploy_webconf

def deploy_webconf():
    """ Deploy nginx and other wsgi server site configurations to the host """
    deployed = []
    log_dir = '/'.join([deployment_root(),'log'])
    #TODO - incorrect - check for actual package to confirm installation
    if webserver_list():
        if env.verbosity:
            print env.host,"DEPLOYING webconf:"
        if not exists(log_dir):
            run('ln -s /var/log log')
        #deploys confs for each domain based on sites app
        if 'apache2' in get_packages():
            deployed += _deploy_webconf('/etc/apache2/sites-available','django-apache-template.txt')
            deployed += _deploy_webconf('/etc/nginx/sites-available','nginx-template.txt')
        elif 'gunicorn' in get_packages():
            deployed += _deploy_webconf('/etc/nginx/sites-available','nginx-gunicorn-template.txt')
        
        if not exists('/var/www/nginx-default'):
            sudo('mkdir /var/www/nginx-default')
        upload_template('woven/maintenance.html','/var/www/nginx-default/maintenance.html',use_sudo=True)
        sudo('chmod ugo+r /var/www/nginx-default/maintenance.html')
    else:
        print env.host,"""WARNING: Apache or Nginx not installed"""
        
    return deployed
开发者ID:andreypaa,项目名称:woven,代码行数:25,代码来源:webservers.py

示例12: _make_local_sitesettings

def _make_local_sitesettings(overwrite=False):
    local_settings_dir = os.path.join(os.getcwd(),env.project_package_name,'sitesettings')
    if not os.path.exists(local_settings_dir) or overwrite:
        if overwrite:
            shutil.rmtree(local_settings_dir,ignore_errors=True)
        os.mkdir(local_settings_dir)
        f = open(os.path.join(local_settings_dir,'__init__.py'),"w")
        f.close()

    settings_file_path = os.path.join(local_settings_dir,'settings.py')
    if not os.path.exists(settings_file_path):
        root_domain = _root_domain()    
        u_domain = root_domain.replace('.','_')
        output = render_to_string('woven/sitesettings.txt',
                {"deployment_root":deployment_root(),
                "site_id":"1",
                "project_name": env.project_name,
                "project_fullname": env.project_fullname,
                "project_package_name": env.project_package_name,
                "u_domain":u_domain,
                "domain":root_domain,
                "user":env,
                "MEDIA_URL":env.MEDIA_URL,
                "STATIC_URL":env.STATIC_URL}
            )
                    
        f = open(settings_file_path,"w+")
        f.writelines(output)
        f.close()
        #copy manage.py into that directory
        manage_path = os.path.join(os.getcwd(),env.project_package_name,'manage.py')
        dest_manage_path = os.path.join(os.getcwd(),env.project_package_name,'sitesettings','manage.py')
        shutil.copy(manage_path, dest_manage_path)

    return
开发者ID:wil,项目名称:woven,代码行数:35,代码来源:project.py

示例13: mkvirtualenv

def mkvirtualenv():
    """
    Create the virtualenv project environment
    """
    root = '/'.join([deployment_root(), 'env'])
    path = '/'.join([root, env.project_fullname])
    dirs_created = []
    if env.verbosity:
        print env.host, 'CREATING VIRTUALENV', path
    if not exists(root):
        dirs_created += mkdirs(root)
    with cd(root):
        run(' '.join(["virtualenv", env.project_fullname]))
    with cd(path):
        dirs_created += mkdirs('egg_cache')
        sudo('chown -R %s:www-data egg_cache' % env.user)
        sudo('chmod -R g+w egg_cache')
        run(''.join([
                "echo 'cd ",
                path,
                '/',
                'project',
                '/',
                env.project_package_name,
                '/sitesettings',
                "' > bin/postactivate"]))
        sudo('chmod ugo+rwx bin/postactivate')

    #Create a state
    out = State(' '.join([env.host, 'virtualenv', path, 'created']))
    out.object = dirs_created + ['bin', 'lib', 'include']
    out.failed = False
    return out
开发者ID:depleater,项目名称:woven,代码行数:33,代码来源:virtualenv.py

示例14: deploy_static

def deploy_static():
    """
    Deploy static (application) versioned media
    """
    
    if not env.STATIC_URL or 'http://' in env.STATIC_URL: return
    from django.core.servers.basehttp import AdminMediaHandler
    remote_dir = '/'.join([deployment_root(),'env',env.project_fullname,'static'])
    m_prefix = len(env.MEDIA_URL)
    #if app media is not handled by django-staticfiles we can install admin media by default
    if 'django.contrib.admin' in env.INSTALLED_APPS and not 'django.contrib.staticfiles' in env.INSTALLED_APPS:
        
        if env.MEDIA_URL and env.MEDIA_URL == env.ADMIN_MEDIA_PREFIX[:m_prefix]:
            print "ERROR: Your ADMIN_MEDIA_PREFIX (Application media) must not be on the same path as your MEDIA_URL (User media)"
            sys.exit(1)
        admin = AdminMediaHandler('DummyApp')
        local_dir = admin.base_dir
        remote_dir =  ''.join([remote_dir,env.ADMIN_MEDIA_PREFIX])
    else:
        if env.MEDIA_URL and env.MEDIA_URL == env.STATIC_URL[:m_prefix]:
            print "ERROR: Your STATIC_URL (Application media) must not be on the same path as your MEDIA_URL (User media)"
            sys.exit(1)
        elif env.STATIC_ROOT:
            local_dir = env.STATIC_ROOT
            static_url = env.STATIC_URL[1:]
            if static_url:
                remote_dir = '/'.join([remote_dir,static_url])
        else: return
    if env.verbosity:
        print env.host,"DEPLOYING static",remote_dir
    return deploy_files(local_dir,remote_dir)
开发者ID:andreypaa,项目名称:woven,代码行数:31,代码来源:project.py

示例15: deploy_db

def deploy_db(rollback=False):
    """
    Deploy a sqlite database from development
    """
    db_name = ''.join([env.project_name,'.db'])
    db_dir = '/'.join([deployment_root(),'database'])
    db_path = '/'.join([db_dir,db_name])
    if not rollback:
        if env.DEFAULT_DATABASE_ENGINE=='django.db.backends.sqlite3' and not exists(db_path):
            if env.verbosity:
                print env.host,"DEPLOYING DEFAULT SQLITE DATABASE",db_path
            if not os.path.exists(env.DEFAULT_DATABASE_NAME) or not env.DEFAULT_DATABASE_NAME:
                print "ERROR: the database does not exist. Run python manage.py syncdb to create your database first."
                sys.exit(1)
            run('mkdir -p '+db_dir)
            put(env.DEFAULT_DATABASE_NAME,db_path)
            #directory and file must be writable by webserver
            sudo("chown -R %s:www-data %s"% (env.user,db_dir))
            sudo("chmod -R ug+w %s"% db_dir)
    elif rollback and env.DEFAULT_DATABASE_ENGINE=='django.db.backends.sqlite3':
        if env.INTERACTIVE:
            delete = confirm('DELETE the database on the host?',default=False)
            if delete:
                run('rm -f '+db_name)
    return
开发者ID:aweakley,项目名称:woven,代码行数:25,代码来源:project.py


注:本文中的woven.environment.deployment_root函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。