示例#1
0
文件: webservers.py 项目: wil/woven
def domain_sites():
    """
    Get a list of domains
    
    Each domain is an attribute dict with name, site_id and settings
    """

    if not hasattr(env,'domains'):
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        domains = []
        
        for id in site_ids:

            for file in _sitesettings_files():
                domain = _AttributeDict({})

                if file == 'settings.py':
                    domain.name = sites[id]
                else: #prefix indicates subdomain
                    subdomain = file[:-12].replace('_','.')
                    domain.name = ''.join([subdomain,sites[id]])

                domain.settings = file
                domain.site_id = id
                domains.append(domain)
                
        env.domains = domains
        if env.domains: env.root_domain = env.domains[0].name
        else:
            domain.name = _root_domain(); domain.site_id = 1; domain.settings='settings.py'
            env.domains = [domain]
            
    return env.domains
示例#2
0
def domain_sites():
    """
    Get a list of domains
    
    Each domain is an attribute dict with name, site_id and settings
    """

    if not hasattr(env,'domains'):
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        domains = []
        
        for id in site_ids:

            for file in _sitesettings_files():
                domain = _AttributeDict({})

                if file == 'settings.py':
                    domain.name = sites[id]
                else: #prefix indicates subdomain
                    subdomain = file[:-12].replace('_','.')
                    domain.name = ''.join([subdomain,sites[id]])

                domain.settings = file
                domain.site_id = id
                domains.append(domain)
                
        env.domains = domains
        if env.domains: env.root_domain = env.domains[0].name
        else:
            domain.name = _root_domain(); domain.site_id = 1; domain.settings='settings.py'
            env.domains = [domain]
            
    return env.domains
示例#3
0
文件: project.py 项目: wil/woven
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
示例#4
0
文件: env.py 项目: depleater/woven
def test_env_root_domain():
    with settings(hosts=[H],
            host_string=HS,
            user=R,
            password=R):
        # In the event of noinput, the domain will default to
        # example.com.
        domain = _root_domain()
        print domain
        assert domain == 'example.com'
示例#5
0
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()
        if env.verbosity:
            print "Created local sitesettings folder and default settings file"
        #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
示例#6
0
文件: project.py 项目: aweakley/woven
def _make_local_sitesettings(overwrite=False):
    local_settings_dir = os.path.join(os.getcwd(),env.project_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,
                "u_domain":u_domain,
                "domain":root_domain,
                "user":env.user},
            )
                    
        f = open(settings_file_path,"w+")
        f.writelines(output)
        f.close()
        
        #create a convenience settings file link for the first site
        settings_file_path = os.path.join(local_settings_dir,''.join([u_domain,'.py']))
        if not os.path.exists(settings_file_path):
            f = open(settings_file_path, "w+")
            f.write("from %s.sitesettings.settings import *"% env.project_name)
            f.write("\nSITE_ID=1\n")
            f.close()
            #copy manage.py into that directory
            manage_path = os.path.join(os.getcwd(),env.project_name,'manage.py')
            dest_manage_path = os.path.join(os.getcwd(),env.project_name,'sitesettings','manage.py')
            shutil.copy(manage_path, dest_manage_path)
    return
示例#7
0
def domain_sites():
    """
    Get a list of the domains that have settings files
    """

    if not hasattr(env, "domains"):
        sites = _get_django_sites()
        site_ids = sites.keys()
        site_ids.sort()
        domains = []
        for id in site_ids:
            sitesetting_path = os.path.join(
                env.project_name, "sitesettings", "".join([sites[id].replace(".", "_"), ".py"])
            )
            if os.path.exists(sitesetting_path):
                domains.append(sites[id])
        env.domains = domains
        if env.domains:
            env.root_domain = env.domains[0]
        else:
            env.domains = [_root_domain()]
    return env.domains
示例#8
0
文件: env.py 项目: zbrdge/woven
def test_env_root_domain():
    with settings(hosts=[H], host_string=HS, user=R, password=R):
        #In the event of noinput, the domain will default to example.com
        domain = _root_domain()
        print domain
        assert domain == 'example.com'