Example #1
0
    def run(self, q=''):

        # If `q` is specified we filter the list of accounts to only accounts
        # with names that contain the value of `q`.
        filter = {}
        if q:
            filter = Q.name == re.compile(re.escape(q), re.I)

        # Get the list of accounts
        accounts = Account.many(filter, sort=[('name', ASC)])

        # Print a list of accounts
        output = []

        if q:
            output.append(
                ("Accounts matching '{0}' ({1}):".format(q, len(accounts)),
                 'underline_bold_blue'))
        else:
            output.append(('Accounts ({0}):'.format(len(accounts)),
                           'underline_bold_blue'))

        for account in accounts:
            output.append(('- {name} (using {backend})'.format(
                name=account.name,
                backend=account.backend.get('backend', 'unknown')), 'blue'))

        self.out(*output)
Example #2
0
    def run(self):

        # Confirm the drop
        if not self.confirm('Enter the following string to confirm drop', \
                    'hangar51'):
            return

        # Delete all accounts, assets and files
        accounts = Account.many()
        for account in accounts:
            account.purge()

        # Drop the collections
        Asset.get_collection().drop()
        Account.get_collection().drop()