How to use the keepercommander.display.bcolors function in keepercommander

To help you get started, weā€™ve selected a few keepercommander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Keeper-Security / Commander / keepercommander / commands / enterprise.py View on Github external
if kwargs.get('lock') or kwargs.get('unlock'):
                    to_lock = not is_locked
                rq = {
                    'command': 'enterprise_user_lock',
                    'enterprise_user_id': user['enterprise_user_id'],
                    'lock': 'locked' if to_lock else 'unlocked'
                }
                rs = api.communicate(params, rq)
                if rs['result'] == 'success':
                    user['lock'] = 1 if to_lock else 0
                    logging.info('User %s is %s', user['username'], 'locked' if to_lock else 'unlocked')

            elif kwargs.get('expire'):
                answer = 'y' if  kwargs.get('force') else \
                    user_choice(
                        bcolors.BOLD + '\nConfirm\n' + bcolors.ENDC +
                        'User will be required to create a new Master Password on the next login.\n' +
                        'Are you sure you want to expire master password?', 'yn', 'n')
                if answer.lower() == 'y':
                    rq = {
                        'command': 'set_master_password_expire',
                        'email': user['username']
                    }
                    rs = api.communicate(params, rq)
                    if rs['result'] == 'success':
                        logging.info('User %s has master password expired', user['username'])

            elif kwargs.get('add_role') or kwargs.get('remove_role'):
                roles = {}
                for is_add in [False, True]:
                    l = kwargs.get('add_role') if is_add else kwargs.get('remove_role')
                    if l:
github Keeper-Security / Commander / keepercommander / commands / register.py View on Github external
if not kwargs.get('force'):
                table = []
                for shared_folder_uid in shared_folder_update:
                    commands = shared_folder_update[shared_folder_uid]
                    shared_folder = api.get_shared_folder(params, shared_folder_uid)
                    uid = shared_folder_uid
                    name = shared_folder.name[:32]
                    for record_uid in commands:
                        cmd = commands[record_uid]
                        record = api.get_record(params, record_uid)
                        row = [len(table) + 1, uid, name, record_uid, record.title[:32]]
                        if change_edit:
                            row.append((bcolors.BOLD + '   ' + ('Y' if should_have else 'N') + bcolors.ENDC)
                                       if 'can_edit' in cmd else '')
                        if change_share:
                            row.append((bcolors.BOLD + '   ' + ('Y' if should_have else 'N') + bcolors.ENDC)
                                       if 'can_share' in cmd else '')
                        table.append(row)
                        uid = ''
                        name = ''

                if len(table) > 0:
                    headers = ['#', 'Shared Folder UID', 'Shared Folder Name', 'Record UID', 'Record Title']
                    if change_edit:
                        headers.append('Can Edit')
                    if change_share:
                        headers.append('Can Share')
                    logging.info('')
                    title = (bcolors.OKGREEN + ' {0}' + bcolors.ENDC + ' Shared Folder Record Share permission(s)') \
                        .format('GRANT' if should_have else 'REVOKE')
                    dump_report_data(table, headers, title=title)
                    logging.info('')
github Keeper-Security / Commander / keepercommander / commands / enterprise.py View on Github external
node_id = node['node_id']
                break
            elif not node.get('parent_id') and node_name == params.enterprise['enterprise_name']:
                node_id = node['node_id']
                break
        if not node_id:
            logging.error('Node %s is not found.', node_name)
            return

        node = [x for x in params.enterprise['nodes'] if x['node_id'] == node_id][0]
        if not node.get('parent_id'):
            logging.error('Cannot wipe out root node')
            return

        answer = user_choice(
            bcolors.FAIL + bcolors.BOLD + '\nALERT!\n' + bcolors.ENDC +
            'This action cannot be undone.\n\n' +
            'Do you want to proceed with deletion?', 'yn', 'n')
        if answer.lower() != 'y':
            return

        sub_nodes = [node['node_id']]
        EnterpriseNodeCommand.get_subnodes(params, sub_nodes, 0)

        nodes = set(sub_nodes)

        commands = []

        if 'queued_teams' in params.enterprise:
            queued_teams = [x for x in params.enterprise['queued_teams'] if x['node_id'] in nodes]
            for qt in queued_teams:
                rq = {
github Keeper-Security / Commander / keepercommander / display.py View on Github external
def welcome():
    print('\n')
    print(bcolors.OKBLUE,' _  __  ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| |/ /___ ___ _ __  ___ _ _ ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| \' 
github Keeper-Security / Commander / keepercommander / commands / register.py View on Github external
record_uid = cmd['record_uid']
                    row = [i + 1, '', '', '']
                    if record_uid != last_record_uid:
                        last_record_uid = record_uid
                        record = params.record_cache[record_uid]
                        record_owners = [x['username'] for x in record['shares']['user_permissions'] if x['owner']]
                        record_owner = record_owners[0] if len(record_owners) > 0 else ''
                        rec = api.get_record(params, record_uid)
                        row[1] = record_uid
                        row[2] = rec.title[:32]
                        row[3] = record_owner
                    row.append(cmd['to_username'])
                    table.append(row)
                headers = ['#', 'Record UID', 'Title', 'Owner', 'Email']
                logging.info('')
                title = bcolors.FAIL + ' SKIP ' + bcolors.ENDC + 'Direct Record Share permission(s). Not permitted'
                dump_report_data(table, headers, title=title)
                logging.info('')
                logging.info('')

        if len(shared_folder_skip) > 0:
            if kwargs.get('dry_run'):
                table = []
                for shared_folder_uid in shared_folder_skip:
                    shared_folder = api.get_shared_folder(params, shared_folder_uid)
                    uid = shared_folder_uid
                    name = shared_folder.name[:32]
                    for record_uid in shared_folder_skip[shared_folder_uid]:
                        record = api.get_record(params, record_uid)
                        row = [len(table) + 1, uid, name, record_uid, record.title]
                        uid = ''
                        name = ''
github Keeper-Security / Commander / keepercommander / display.py View on Github external
def welcome():
    print('\n')
    print(bcolors.OKBLUE,' _  __  ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| |/ /___ ___ _ __  ___ _ _ ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| \' 
github Keeper-Security / Commander / keepercommander / display.py View on Github external
def welcome():
    print('\n')
    print(bcolors.OKBLUE,' _  __  ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| |/ /___ ___ _ __  ___ _ _ ' + bcolors.ENDC)
    print(bcolors.OKBLUE,'| \'