Exemple #1
0
def add_auth(c, user):
    """
    Create user for passwd authentication.
    """
    c.run(f'mkdir -p $(dirname {c.passwd_path})')
    c.run(f'htpasswd -c {c.passwd_path} {user}')
    console.done(f'Added user {user}')
Exemple #2
0
def restart_application(c, app_root):
    """Restart Cloudlinux Python application."""
    console.status(f'Restarting {app_root} application')
    c.run(
        f'{CLOUDLINUX_SELECTOR_PATH} restart --interpreter python '
        f'--app-root {app_root} --user tedxntua --json',
        hide='out')
    console.done('Restarted')
Exemple #3
0
def compile_translations(c):
    """Run `manage.py compilemessages` for supported languages."""
    for lang in TRANSLATIONS:
        c.run(
            f'{c.venv_bin_path}/manage.py compilemessages -l {lang}',
            hide='out',
        )
    console.done('Compiled Django translations')
Exemple #4
0
def install_python_deps(c):
    """Install Python dependencies from requirements.txt."""
    with source_profile(c):
        c.run(
            f'{c.venv_bin_path}/pip install -r '
            f'{c.code_path}/requirements.txt',
            hide='out')
    console.done('Installed Python dependencies from requirements.txt')
Exemple #5
0
console.colored(
    """Use this until ~01/01/2017,
then Howl will release a new
mirror with api and everything
""", bcolors.YELLOW)

console.print_n("> Reading config.json...")
glob.config = config.Config()
try:
    glob.config.read()
except FileNotFoundError:
    print("\nconfig.json doesn't exist. Generating a default one..")
    glob.config.write_default()
    sys.exit()
console.done()

console.print_n("> Connecting to db...")
db_config = glob.config.config["db"]
glob.db = pool.Pool(max_size=db_config["connections"],
                    host=db_config["host"],
                    user=db_config["username"],
                    passwd=db_config["password"],
                    db=db_config["database"],
                    charset="utf8mb4")
console.done()

print("> Web server started on 0.0.0.0:{}".format(
    glob.config.config["server"]["port"]))
glob.pool = ThreadPool(glob.config.config["server"]["threads"])
tornado.web.Application([
Exemple #6
0
def build_production(c):
    """Run `npm run build` in bundles directory."""
    with source_profile(c), c.cd(f'{c.code_path}/bundles'):
        c.run('npm run build', hide=True)
    console.done('Created production build')
Exemple #7
0
def install_npm_deps(c):
    """Install npm dependencies from package.json."""
    with source_profile(c), c.cd(f'{c.code_path}/bundles'):
        c.run('npm i', hide=True)
    console.done('Installed npm dependencies')
Exemple #8
0
def set_public(c):
    """Remove password protection from active stage."""
    with c.cd(c.subdomain_root):
        c.run('cp public.htaccess .htaccess', hide='out')
    console.done('Disabled password protection')
Exemple #9
0
def set_private(c):
    """Add password protection to active stage."""
    with c.cd(c.subdomain_root):
        c.run('cp private.htaccess .htaccess', hide='out')
    console.done('Enabled password protection')
Exemple #10
0
def install_python_deps_from_setup(c):
    """Install Python dependencies from setup.py."""
    with source_profile(c):
        c.run(f'{c.venv_bin_path}/pip install -e {c.code_path}', hide='out')
    console.done('Installed Python dependencies from setup.py')
Exemple #11
0
def collect_static(c):
    """Collect static files for Django."""
    c.run(f'{c.venv_bin_path}/manage.py collectstatic --noinput', hide='out')
    console.done('Collected static files')
Exemple #12
0
def migrate(c):
    """Run Django migrations."""
    c.run(f'{c.venv_bin_path}/manage.py migrate', hide='out')
    console.done('Ran Django migrations')