Ejemplo n.º 1
0
                'from': 'users',
                'localField': 'owner',
                'foreignField': 'groups',
                'as': 'owners'
            }
        },
        {
            '$unwind': {
                'path': '$owners'
            }
        },
        {
            '$match': {
                'owners.settings.email_communications': {
                    '$ne': 0
                }
            }
        },
        {
            '$group': {
                '_id': '$owners.email'
            }
        },
    ])

    emails = ', '.join(sorted(result['_id'] for result in found))
    print(emails)


manager.add_command("flamenco", manager_flamenco)
Ejemplo n.º 2
0
Archivo: cli.py Proyecto: jonike/dillo
import logging

from flask import current_app
from flask_script import Manager

from pillar.api.utils import authentication
from pillar.cli import manager

import dillo.setup
import dillo.api.posts.rating

log = logging.getLogger(__name__)

manager_dillo = Manager(current_app, usage="Perform Dillo operations")

manager.add_command("dillo", manager_dillo)


@manager_dillo.command
def setup_db(admin_email):
    """Extends Pillar setup_db."""
    from pillar.cli.setup import setup_db as pillar_setup_db
    # Define the dillo_user_main group, which is automatically assigned
    # after every user creation.
    g = {'name': 'dillo_user_main'}
    current_app.post_internal('groups', g)
    # Execute the default user creation
    pillar_setup_db(admin_email)


@manager_dillo.command
Ejemplo n.º 3
0
        {'$match': {'url': {'$exists': False}}},
        {'$lookup': {
            'from': 'users',
            'localField': 'owner',
            'foreignField': 'groups',
            'as': 'owners'
        }},
        {'$unwind': {'path': '$owners'}},
        {'$match': {'owners.settings.email_communications': {'$ne': 0}}},
        {'$group': {'_id': '$owners.email'}},
    ])

    emails = ', '.join(sorted(result['_id'] for result in found))
    print(emails)


manager.add_command("flamenco", manager_flamenco)


@manager_flamenco.command
def runability_check():
    """Schedules Celery background tasks for job runability check.

    Creates a new celery archival task for each job that has status 'active'.
    """

    from flamenco.celery import job_runnability_check

    log.info('Creating Celery background tasks for runability checks of jobs')
    job_runnability_check.schedule_checks()
Ejemplo n.º 4
0
            with lock:
                do_update_subscription(local_user, bid_user)
                count_processed += 1

    with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
        future_to_user = {
            executor.submit(do_user, idx, user): user
            for idx, user in enumerate(found)
        }
        for future in concurrent.futures.as_completed(future_to_user):
            user = future_to_user[future]
            try:
                future.result()
            except Exception as ex:
                log.exception('Error updating user %s', user)

    log.info('Done reconciling %d subscribers', count_users)
    log.info('    processed: %d', count_processed)
    log.info('    skipped  : %d', count_skipped)


@manager_cloud.command
def setup_for_film(project_url):
    """Adds Blender Cloud film custom properties to a project."""

    authentication.force_cli_user()
    cloud.setup.setup_for_film(project_url)


manager.add_command("cloud", manager_cloud)
Ejemplo n.º 5
0
                                        grant=[(username, hashed)],
                                        revoke=[])
    log.info('Done')


@manager_svnman.command
def revoke(repo_id, username):
    """Revokes the user access from the repository."""

    from . import current_svnman

    log.info('Revoking access from repo %r', repo_id)
    current_svnman.remote.modify_access(repo_id, grant=[], revoke=[username])
    log.info('Done')


@manager_svnman.command
def delete(repo_id):
    """Deletes a repository. This cannot be undone via the API."""

    from . import current_svnman

    log.info('Deleting repository %r', repo_id)
    input('Press ENTER to continue irrevocable repository deletion')

    current_svnman.remote.delete_repo(repo_id)
    log.info('Done')


manager.add_command('svn', manager_svnman)