def generate():
    PIP_COMMAND = getvar('PIP_COMMAND')
    subprocess.call([PIP_COMMAND, 'install', '/pygments-lexer-babylon'])
    PYTHON_COMMAND = getvar('PYTHON_COMMAND')
    print('generating...')
    t0 = time.time()
    subprocess.call([PYTHON_COMMAND, '/pygments-lexer-babylon/test/runner.py'])
    t1 = time.time()
    print('ellapsed time: %s' % (t1 - t0, ))
def init(stopper=None):
    ensure_dir('/data/logs/', owner='developer', group=getvar('DEVELOPER_GID'))
    ensure_dir(os.path.split(PGDATA)[0], owner='postgres', group='postgres')
    ensure_dir(SOCKET_DIR, owner='postgres', group='postgres')
    ensure_dir(BACKUP_DIR, owner='postgres', group='postgres')
    ensure_dir('/data/logs/postgres', owner='postgres', group='postgres')

    if not os.path.isdir(PGDATA):
        _initdb()
        _setpwd('postgres', getvar('DB_PASSWORD'))
Beispiel #3
0
def run():
    ensure_dir('/data/static',
               owner='developer',
               group=getvar('DEVELOPER_GID'))
    ensure_dir('/data/static/react',
               owner='developer',
               group=getvar('DEVELOPER_GID'))
    run_cmd(['npm', 'config', 'set', 'static_root',
             getvar('STATIC_ROOT')],
            user='******')
    run_daemon(['npm', 'install'], user='******', exit_on_finish=False)
def init(stopper):
    ensure_dir('/data/logs/', owner='developer', group=getvar('DEVELOPER_GID'))
    ensure_dir('/data/logs/django', owner='developer', group=getvar('DEVELOPER_GID'))
    ensure_dir('/data/static', owner='developer', group=getvar('DEVELOPER_GID'))
    {% if cookiecutter.use_translation == 'True' -%}
    ensure_dir('/src/locale', owner='developer', group=getvar('DEVELOPER_GID'))
    {%- endif %}
    if not stopper.stopped:
        if settings.DEBUG is False:
            {%- if cookiecutter.use_react == 'True' %}
            cmd = ['django-admin', 'collectstatic', '--noinput', '-i', 'react']
            {% else %}
Beispiel #5
0
def waitfordb(stopper):
    """
    Wait for the database to accept connections.
    """
    tick = 0.1
    intervals = 10 * [5] + 100 * [10]

    for i in intervals:
        click.echo('checking semafor ...')
        if os.path.isfile(PG_SEMAFOR):
            click.echo('checking connection ...')
            try:
                psycopg2.connect(host='postgres',
                                 port=5432,
                                 database="postgres",
                                 user="******",
                                 password=getvar('DB_PASSWORD'))
            except:
                click.echo('could not connect yet')
            else:
                return
        else:
            click.echo('no semafor yet')

        for w in range(i):
            if stopper.stopped:
                return
            time.sleep(tick)
def init(stopper=None):
    ensure_dir(os.path.split(PGDATA)[0], owner='postgres', group='postgres')
    ensure_dir(SOCKET_DIR, owner='postgres', group='postgres')
    ensure_dir(BACKUP_DIR, owner='postgres', group='postgres')
    ensure_dir('/data/logs/postgres', owner='postgres', group='postgres')

    if not os.path.isdir(PGDATA):
        _initdb()
        _setpwd('postgres', getvar('DB_PASSWORD'))
Beispiel #7
0
def init(stopper):
    ensure_dir(PGDATA_PARENT,
               owner='root', group='root', permsission_str='777')
    ensure_dir(SOCKET_DIR,
               owner='root', group='root', permsission_str='777')
    ensure_dir(BACKUP_DIR,
               owner='postgres', group='postgres', permsission_str='700')

    if not os.path.isdir(PGDATA):
        _initdb()
        _setpwd('postgres', getvar('DB_PASSWORD'))
Beispiel #8
0
def init(stopper):
    ensure_dir(PGDATA_PARENT,
               owner='root',
               group='root',
               permsission_str='777')
    ensure_dir(SOCKET_DIR, owner='root', group='root', permsission_str='777')
    ensure_dir(BACKUP_DIR,
               owner='postgres',
               group='postgres',
               permsission_str='700')

    if not os.path.isdir(PGDATA):
        _initdb()
        _setpwd('postgres', getvar('DB_PASSWORD'))
def waitfordb(stopper):
    """ Wait for the database to accept connections. """
    tick = 0.1
    intervals = 100 * [10]
    for i in intervals:
        click.echo('checking connection ...')
        try:
            psycopg2.connect(host='postgres', port=5432, database="django",
                             user="******", password=getvar('DB_PASSWORD'))
        except Exception as e:
            click.echo('could not connect yet')
            click.echo(e)
        else:
            return

        for w in range(i):
            if stopper.stopped:
                return
            time.sleep(tick)
Beispiel #10
0
import signal
import hashlib
from contextlib import contextmanager
import re
import time

import click
import psycopg2

from runutils import (runbash, ensure_user, get_user_ids,
                      getvar, ensure_dir, call, copyfile, substitute,
                      run_daemon, setuser, run_cmd, Stopper)


USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('postgres', 5432)
PGDATA = getvar('PGDATA')
PGDATA_PARENT = os.path.split(PGDATA)[0]
SOCKET_DIR = getvar('SOCKET_DIR')
PG_MAJOR = getvar('PG_MAJOR')
MAIN_USER_PWD = getvar('MAIN_USER_PWD')

CONF_BASE = '/usr/share/postgresql/%s/%%s' % PG_MAJOR
CONF_FILE = CONF_BASE % 'postgresql.conf'
HBA_FILE = CONF_BASE % 'pg_hba.conf'
START_POSTGRES = ['postgres', '-c', 'config_file=%s' % CONF_FILE]
SEMAPHORE = getvar('SEMAPHORE', required=False)
BACKUP_DIR = getvar('BACKUP_DIR')
if SEMAPHORE:
    SEMAPHORE_PARENT = os.path.split(SEMAPHORE)[0]
else:
    SEMAPHORE_PARENT = None
Beispiel #11
0
# coding: utf-8
# Core and 3th party packages
import os
import re
import sys
import subprocess
import time
import signal
from contextlib import contextmanager
import click

# Utils Imports
from runutils import (run_daemon, getvar, runbash, id, run_cmd, setuser,
                      ensure_dir)

PGDATA = getvar('PGDATA')
CONFIG_FILE = '/config/postgresql.conf'
SOCKET_DIR = '/data/sock'
BACKUP_DIR = '/data/backup'
SEMAFOR = '/data/sock/pg_semafor'
start_postgres = ['postgres', '-c', 'config_file=%s' % CONFIG_FILE]

#############
# Functions #
#############


def psqlparams(command=None, database='django'):
    """Returns a list of command line arguments to run psql."""
    if command is None:
        return ['psql', '-d', database, '-h', SOCKET_DIR]
Beispiel #12
0
def run():
    ensure_dir('/data/static', owner='developer', group='developer')
    ensure_dir('/data/static/react', owner='developer', group='developer')
    run_cmd(['npm', 'config', 'set', 'static_root', getvar('STATIC_ROOT')],
            user='******')
    run_daemon(['npm', 'install'], user='******', exit_on_finish=False)
# Core and 3th party packages
import os
import re
import sys
import subprocess
import time
import signal
from contextlib import contextmanager
import click

# Utils Imports
from runutils import (
    run_daemon, getvar, runbash, id, run_cmd, setuser, ensure_dir)


PGDATA = getvar('PGDATA')
CONFIG_FILE = '/config/postgresql.conf'
SOCKET_DIR = '/data/sock'
BACKUP_DIR = '/data/backup'
SEMAFOR = '/data/sock/pg_semafor'
start_postgres = ['postgres', '-c', 'config_file=%s' % CONFIG_FILE]


#############
# Functions #
#############

def psqlparams(command=None, database='django'):
    """Returns a list of command line arguments to run psql."""
    if command is None:
        return ['psql', '-d', database, '-h', SOCKET_DIR]
def run():
    ensure_dir('/data/logs/', owner='developer', group=getvar('DEVELOPER_GID'))
    ensure_dir('/data/logs/nginx/',
               owner='developer',
               group=getvar('DEVELOPER_GID'))
Beispiel #15
0
import click

from runutils import (getvar, runbash, get_user_ids, ensure_user, copyfile,
                      substitute, run_daemon, ensure_dir, Stopper)


USER_NAME, USER_ID, GROUP_NAME, GROUP_ID = get_user_ids('nginx', 8080)
NGINX_CONF = getvar('NGINX_CONF')
MIME_TYPES = getvar('MIME_TYPES', default='nginx_mime.types')
STATIC_DIR = getvar('STATIC_DIR')
# make sure STATIC_DIR ends with '/'
STATIC_DIR = ('%s/' % STATIC_DIR).replace('//', '/')
DJANGO_UPSTREAM = getvar('DJANGO_UPSTREAM', default='django:8000')
UWSGI_PARAMS = getvar('UWSGI_PARAMS', required=False)
SOCKET_DIR = getvar('SOCKET_DIR', default='')


def _init(stopper):
    ensure_dir(STATIC_DIR,
               owner='root', group='root', permission_str='777')
    ensure_dir(
        SOCKET_DIR, owner='root', group='root', permission_str='777')

    # copy config files
    copyfile(NGINX_CONF, '/nginx.conf',
             owner=USER_NAME, group=GROUP_NAME, permission_str='400')
    copyfile(MIME_TYPES, '/nginx_mime.types',
             owner=USER_NAME, group=GROUP_NAME, permission_str='400')
    if UWSGI_PARAMS:
        copyfile(UWSGI_PARAMS, '/uwsgi_params',
                 owner=USER_NAME, group=GROUP_NAME, permission_str='400')