Ejemplo n.º 1
0
    def fab_criar_crons(self):
        ''' Insere tarefa definida em ../cron/cronconf no crontab do servidor '''
        crontab_location = '/etc/crontab'
        with cd(env.code_root):
            if os.path.exists('cron'):
                from cron.cronconf import CRONS
                import re
                sudo('chmod 646 ' + crontab_location)

                for cron in CRONS:

                    if cron['comando_de_projeto'] and not cron['django_management']:
                        linha_cron = cron['tempo'] + ' ' + cron['usuario'] + ' ' + env.code_root +'/'+ cron['comando']
                    else:
                        if cron['comando_de_projeto'] and cron['django_management']:
                            linha_cron =  cron['tempo'] + ' ' + cron['usuario'] + ' /usr/bin/python ' + env.code_root + '/' + cron['comando'] + ' --settings=med_alliance.settings.' + env.ambiente
                        else:
                            linha_cron =  cron['tempo'] + ' ' + cron['usuario'] + ' ' + cron['comando']
                    if cron['ligado']:
                        if not contains(crontab_location, re.escape(linha_cron)):
                            append(crontab_location, linha_cron, use_sudo=False)
                        else:
                            uncomment(crontab_location, re.escape(linha_cron))
                    else:
                        if contains(crontab_location, re.escape(linha_cron)):
                            comment(crontab_location, re.escape(linha_cron))

                sudo('chmod 644 ' + crontab_location)

__all__ = initialize(MedAllianceFabric(), __name__)
Ejemplo n.º 2
0
class ProjectFabric(DjangoCMS3):
    import wolderwijd.settings as settings
    DB = settings.DATABASES['default']['NAME']
    MEDIA_ROOT = settings.MEDIA_ROOT
    VIRTUAL_ENVIRONMENT = '~/.virtualenvs/wolderwijd/bin/activate'
    REPOSITORY = '[email protected]:corallus/allure-wolderwijd.git'

    def fab_live(self):
        """ chooses live environment """
        env.domain = 'allure-zeewolde.nl'
        env.hosts = ['109.70.6.143']
        env.environment = "wolderwijd"
        env.user = '******'
        env.path = '/home/%(user)s/domains/%(domain)s/%(environment)s' % env
        env.settings_path = '%s/wolderwijd' % env.path
        env.media_path = '%s/media' % env.path
        env.virtual_env = '%s/venv' % env.path
        env.activate = '%s/bin/activate' % env.virtual_env
        env.debug = False

    def fab_compileless(self):
        print(red(" * compiling less files..."))
        run('cd %s '
            '&& lessc --clean-css static/less/style.less static/css/style.min.css '
            '&& lessc --clean-css static/less/home.less static/css/home.min.css '
            '&& lessc --clean-css static/less/sanitair.less static/css/sanitair.min.css '
            '&& lessc --clean-css static/less/partners.less static/css/partners.min.css' % env.settings_path)

__all__ = initialize(ProjectFabric(), __name__)

Ejemplo n.º 3
0
                    if cron['comando_de_projeto'] and not cron[
                            'django_management']:
                        linha_cron = cron['tempo'] + ' ' + cron[
                            'usuario'] + ' ' + env.code_root + '/' + cron[
                                'comando']
                    else:
                        if cron['comando_de_projeto'] and cron[
                                'django_management']:
                            linha_cron = cron['tempo'] + ' ' + cron[
                                'usuario'] + ' /usr/bin/python ' + env.code_root + '/' + cron[
                                    'comando'] + ' --settings=med_alliance.settings.' + env.ambiente
                        else:
                            linha_cron = cron['tempo'] + ' ' + cron[
                                'usuario'] + ' ' + cron['comando']
                    if cron['ligado']:
                        if not contains(crontab_location,
                                        re.escape(linha_cron)):
                            append(crontab_location,
                                   linha_cron,
                                   use_sudo=False)
                        else:
                            uncomment(crontab_location, re.escape(linha_cron))
                    else:
                        if contains(crontab_location, re.escape(linha_cron)):
                            comment(crontab_location, re.escape(linha_cron))

                sudo('chmod 644 ' + crontab_location)


__all__ = initialize(MedAllianceFabric(), __name__)
Ejemplo n.º 4
0
#
#    def fab_restore_data(self):
#        '''
#        Load content data from dump file to the DB
#        '''
#        local('gunzip %s' % self.dump_file)
#        local('psql -U movister -d movister < %s' % self.dump_file)
#
#    def fab_update_css(self):
#        '''
#        Put remote dirs with css files to the repository and get them on development
#        '''
#        with cd(self.remote_project_path):
#            run('git add %s' % ' '.join(self.media_css_dirs))
#            run('git commit -nm "updated css"')
#            run('git push')
#        local('git pull', capture=False)
#
#    def i18n(self):
#        '''
#        Make i18n files and compile them after finishing translating
#        '''
#        langs = ['ru','en']
#        for lang in langs:
#            local('./manage.py makemessages -sl %s --ignore=*/magnolia/* --ignore=*/django/contrib/flatpages/forms.py --ignore=*/debug_toolbar/js/* --traceback' % lang, capture=False)
#            local('./manage.py makemessages -l %s -d djangojs --ignore=*js/all.r* --traceback' % lang, capture=False)
#        if confirm(u'Are messages ready for compiling?'):
#            local('./manage.py compilemessages', capture=False)

__all__ = initialize(Fabric(), __name__)
Ejemplo n.º 5
0
    test_settings = 'settings_test'
    shell_plus = True

    remote_user = '******'
    remote_project_path = '/var/www/vaccination'
    local_project_path = '/Users/ramusus/workspace/vaccination'
    applications_dir = 'project/apps'

    def fab_deploy(self, migrate=False, update=False):
        '''
        Deploy project to the remote host
            `migrate` boolean argument if neccesary to run syncdb and migrate (south) management commands
            `upgrade` list of applications separated by commas need to upgrade using pip
        '''
        local('git push')
        with cd(self.remote_project_path):
            run('git pull')
            if update:
                self.run_pip('install -r requirements.txt')
            if migrate:
                self.run_manage('syncdb')
                self.run_manage('migrate')

            sudo('supervisorctl restart vaccination')
            sudo('chown -R www-data:www-data logs')
            sudo('chmod -R 775 logs')
            self.run_manage('collectstatic --noinput')


__all__ = initialize(Fabric(), __name__)