Example #1
0
from mediacrush.mcmanage.report import report
from mediacrush.mcmanage.files import files_delete

from mediacrush.email import send_report

def show_report(args):
    print report()

database_commands = {
    'clear': database_clear,
    'upgrade': database_upgrade,
}

report_commands = {
    'show': show_report,
    'email': lambda args: send_report(report())
}

files_commands = {
    'delete': files_delete,
}

mapping = {
    'database': database_commands,
    'report': report_commands,
    'files': files_commands,
    'admin': None,
}

def find_true(arguments, mapping_dict):
    return filter(lambda x: x is not None, [item if arguments[item] else None for item in mapping_dict])[0]
Example #2
0
from mediacrush.mcmanage.files import files_delete, files_nsfw
from mediacrush.mcmanage.shard import init, migrate

from mediacrush.email import send_report

def show_report(args):
    print(report())

database_commands = {
    'clear': database_clear,
    'sync': database_sync,
}

report_commands = {
    'show': show_report,
    'email': lambda args: send_report(report())
}

files_commands = {
    'delete': files_delete,
    'nsfw': files_nsfw
}

shard_commands = {
    'init': init,
    'migrate': migrate
}

mapping = {
    'database': database_commands,
    'report': report_commands,
Example #3
0
from mediacrush.mcmanage.database import database_clear, database_sync
from mediacrush.mcmanage.files import files_delete
from mediacrush.mcmanage.report import report
from mediacrush.mcmanage.shard import init, migrate


def show_report(args):
    print((report()))


database_commands = {
    "clear": database_clear,
    "sync": database_sync,
}

report_commands = {"show": show_report, "email": lambda args: send_report(report())}

files_commands = {"delete": files_delete}

shard_commands = {"init": init, "migrate": migrate}

mapping = {
    "database": database_commands,
    "report": report_commands,
    "files": files_commands,
    "shard": shard_commands,
    "admin": None,
}


def find_true(arguments, mapping_dict):
Example #4
0
from docopt import docopt

from mediacrush.mcmanage.database import database_clear, database_sync
from mediacrush.mcmanage.report import report
from mediacrush.mcmanage.files import files_delete

from mediacrush.email import send_report


def show_report(args):
    print(report())


database_commands = {"clear": database_clear, "sync": database_sync}

report_commands = {"show": show_report, "email": lambda args: send_report(report())}

files_commands = {"delete": files_delete}

mapping = {"database": database_commands, "report": report_commands, "files": files_commands, "admin": None}


def find_true(arguments, mapping_dict):
    return filter(lambda x: x is not None, [item if arguments[item] else None for item in mapping_dict])[0]


if __name__ == "__main__":
    arguments = docopt(__doc__, version="1.0")
    module = find_true(arguments, mapping)
    commands = mapping[module]
    command = find_true(arguments, commands)