Exemplo n.º 1
0
    def install(self):
        print 'Installing ' + self.name + '...'
        
        p = subprocess.Popen("pwd", stdout=subprocess.PIPE)
        current_folder = p.communicate()[0].rstrip()

        """ Create app and modules """
        os.chdir( self.base_dir + '/' + self.domain_name + "/private/")
        run("django-admin.py startproject {{app_name}}")
        os.chdir( self.app_name)
         
        for app in self.modules:
            run("python manage.py startapp " + app)
       
        """ Install reload script """
        os.chdir(current_folder)
 
        """ Configure settings.py according to source file """
        load_template(self.django_settings_template, "{{base_dir}}/{{domain_name}}/private/{{app_name}}/settings.py")  

        f = open(self.django_reload_template_url, 'r')
        template = f.read()
        
        template = re.sub('{{base_dir}}',self.base_dir, template)
        template = re.sub('{{domain_name}}', self.domain_name, template)
        template = re.sub('{{app_name}}', self.app_name, template)
        
        f = open( '/usr/local/bin/' + self.app_name + "-reload", 'w')
        f.write(template)
        f.close()

	#result = call("chmod +rx /usr/local/bin/" + self.app_name + "-reload",shell=True)
        run('chmod +rx /usr/local/bin/{{app_name}}-reload') 
 
        return True
Exemplo n.º 2
0
import find_bbot, bbot
from master import BuildMaster
from slave import BuildSlave
from util import load_template
from bbot.util.repo import LocalGit
from monitor import Monitor

init_py = '__init__.py'
config_template = load_template('multirepo_config.py')

class multirepo_test(object):
    
    def setUp(self):
        self.monitor = Monitor()

        self.local_repos = []
        self.remote_repos = []

        for i in range(2):
            r = LocalGit(bare=True)
            r.install_post_receive_hook()
            self.remote_repos.append(r)
            l = LocalGit(clone=r)
            open(l/init_py, 'w')
            l.add(init_py)
            l.commit()
            self.local_repos.append(l)
            
        print 'creating master...'
        self.master = BuildMaster(config_fn = self.gen_config)
        self.master.bot_dir.preserve()
Exemplo n.º 3
0
import find_bbot

from master import BuildMaster
from bbot.util.quiet_process import check_call
from os.path import join as pjoin, dirname as pdir
from util import load_template
from bbot.util.path import Path

trivial_config_py_template = load_template('trivial-config.py')


class MasterTester(object):
    master = None

    def setUp(self):
        self.master = BuildMaster(self.gen_config)

    def test_checkconfig_in_src_dir(self):
        self.master.check_cmd(['checkconfig'], cwd=self.master.src_dir)

    def test_checkconfig_in_bot_dir(self):
        self.master.check_cmd(['checkconfig'])

    def test_life_cycle(self):
        self.master.check_cmd(['create-master'])
        self.master.check_cmd(['start'])
        self.master.check_cmd(['reconfig'])
        self.master.check_cmd(['stop'])


class trivial_config_tests(MasterTester):
Exemplo n.º 4
0
class BuildMaster(Bot):
    """
    Represents a test of a BuildMaster installation
    """

    #
    # constants
    #
    master_cfg_template = load_template('master.cfg')

    environ = dict(os.environ.items() +
                   [('PYTHONPATH', pdir(pdir(bbot.__file__)))])

    executable = 'buildbot'

    #
    # instance attributes
    #
    name = None
    """Name of the directory where the configuration sourcec lives"""

    bot_dir = None
    """Path to the directory where "buildbot create-master" gets run"""

    src_dir = None
    """Path to the directory containing the configuration source files"""
    def __init__(self, config_fn, name='buildmaster'):
        super(BuildMaster, self).__init__()
        self.name = name

        # Create a submodule
        self.src_dir = self.bot_dir / self.name
        os.mkdir(self.src_dir)
        open(self.src_dir / '__init__.py', 'w')

        # Create the master.cfg file
        master_cfg = self.src_dir / 'master.cfg'
        open(master_cfg,
             'w').write(self.master_cfg_template % dict(name=self.name))

        # Add a link to master.cfg in the bot directory
        _link_or_copy(master_cfg, self.bot_dir / 'master.cfg')

        # Generate config.py
        config_fn(self.src_dir)

    def check_cmd(self, *popenargs, **kwargs):
        cmd = kwargs.pop('args', None)
        if cmd is None:
            cmd = popenargs[0]
            popenargs = popenargs[1:]
        cwd = kwargs.pop('cwd', self.bot_dir)

        quietly.check_call(*popenargs,
                           args=['buildbot'] + cmd,
                           env=self.environ,
                           cwd=cwd,
                           **kwargs)

    def create_master(self):
        self.check_cmd(['create-master', '-r'])
Exemplo n.º 5
0
import find_bbot

from master import BuildMaster
from bbot.util.quiet_process import check_call
from os.path import join as pjoin, dirname as pdir
from util import load_template
from bbot.util.path import Path

trivial_config_py_template = load_template('trivial-config.py')

class MasterTester(object):
    master = None

    def setUp(self):
        self.master = BuildMaster(self.gen_config)

    def test_checkconfig_in_src_dir(self):
        self.master.check_cmd(['checkconfig'], cwd=self.master.src_dir)

    def test_checkconfig_in_bot_dir(self):
        self.master.check_cmd(['checkconfig'])

    def test_life_cycle(self):
        self.master.check_cmd(['create-master'])
        self.master.check_cmd(['start'])
        self.master.check_cmd(['reconfig'])
        self.master.check_cmd(['stop'])


class trivial_config_tests(MasterTester):
    def gen_config(self, where):
Exemplo n.º 6
0
import find_bbot, bbot
from master import BuildMaster
from slave import BuildSlave
from util import load_template
from bbot.util.repo import LocalGit
from monitor import Monitor

init_py = '__init__.py'
config_template = load_template('multirepo_config.py')


class multirepo_test(object):
    def setUp(self):
        self.monitor = Monitor()

        self.local_repos = []
        self.remote_repos = []

        for i in range(2):
            r = LocalGit(bare=True)
            r.install_post_receive_hook()
            self.remote_repos.append(r)
            l = LocalGit(clone=r)
            open(l / init_py, 'w')
            l.add(init_py)
            l.commit()
            self.local_repos.append(l)

        print 'creating master...'
        self.master = BuildMaster(config_fn=self.gen_config)
        self.master.bot_dir.preserve()