Helper to output an account information.
516419
def output_account(gandi, account, output_keys, justify=17):
    
    output_generic(gandi, account, output_keys, justify)

    if 'prepaid' in output_keys:
        prepaid = '%s %s' % (account['prepaid_info']['amount'],
                             account['prepaid_info']['currency'])
        output_line(gandi, 'prepaid', prepaid, justify)

    if 'credit' in output_keys:
        output_line(gandi, 'credits', None, justify)
        available = account.get('credits')
        output_line(gandi, '        available', available, justify)
        # sometimes rating is returning nothing
        usage_str = left_str = 'not available'
        usage = account.get('credit_usage', 0)
        left = account.get('left')
        if usage:
            usage_str = '%d/h' % usage

            years, months, days, hours = left
            left_str = ('%d year(s) %d month(s) %d day(s) %d hour(s)' %
                        (years, months, days, hours))

        output_line(gandi, '        usage', usage_str, justify)
        output_line(gandi, '        time left', left_str, justify)
509221
def accountValues(self, account: str = '') -> List[AccountValue]:
        
        if account:
            return [v for v in self.wrapper.accountValues.values()
                    if v.account == account]
        else:
            return list(self.wrapper.accountValues.values())
323207
def dump_info():
    ''''''
    vultr = Vultr(API_KEY)

    try:
        logging.info('Listing account info:\n%s', dumps(
            vultr.account.info(), indent=2
        ))

        logging.info('Listing apps:\n%s', dumps(
            vultr.app.list(), indent=2
        ))

        logging.info('Listing backups:\n%s', dumps(
            vultr.backup.list(), indent=2
        ))

        logging.info('Listing DNS:\n%s', dumps(
            vultr.dns.list(), indent=2
        ))

        logging.info('Listing ISOs:\n%s', dumps(
            vultr.iso.list(), indent=2
        ))

        logging.info('Listing OSs:\n%s', dumps(
            vultr.os.list(), indent=2
        ))

        logging.info('Listing plans:\n%s', dumps(
            vultr.plans.list(), indent=2
        ))

        logging.info('Listing regions:\n%s', dumps(
            vultr.regions.list(), indent=2
        ))

        logging.info('Listing servers:\n%s', dumps(
            vultr.server.list(), indent=2
        ))

        logging.info('Listing snapshots:\n%s', dumps(
            vultr.snapshot.list(), indent=2
        ))

        logging.info('Listing SSH keys:\n%s', dumps(
            vultr.sshkey.list(), indent=2
        ))

        logging.info('Listing startup scripts:\n%s', dumps(
            vultr.startupscript.list(), indent=2
        ))
    except VultrError as ex:
        logging.error('VultrError: %s', ex)
1072622
def cli(env, account_id):
    """"""

    manager = SoftLayer.CDNManager(env.client)
    account = manager.get_account(account_id)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', account['id']])
    table.add_row(['account_name', account['cdnAccountName']])
    table.add_row(['type', account['cdnSolutionName']])
    table.add_row(['status', account['status']['name']])
    table.add_row(['created', account['createDate']])
    table.add_row(['notes',
                   account.get('cdnAccountNote', formatting.blank())])

    env.fout(table)
1243037
def parse_account_key():
    """"""
    LOGGER.info("Parsing account key...")
    cmd = [
        'openssl', 'rsa',
        '-in', os.path.join(gettempdir(), 'account.key'),
        '-noout',
        '-text'
    ]
    devnull = open(os.devnull, 'wb')
    return subprocess.check_output(cmd, stderr=devnull)
617641
def print_entitlements(opts, data, page_info=None, show_list_info=True):
    """"""
    if utils.maybe_print_as_json(opts, data, page_info):
        return

    headers = ["Name", "Token", "Created / Updated", "Identifier"]

    rows = []
    for entitlement in sorted(data, key=itemgetter("name")):
        rows.append(
            [
                click.style(
                    "%(name)s (%(type)s)"
                    % {
                        "name": click.style(entitlement["name"], fg="cyan"),
                        "type": "user" if entitlement["user"] else "token",
                    }
                ),
                click.style(entitlement["token"], fg="yellow"),
                click.style(entitlement["updated_at"], fg="blue"),
                click.style(entitlement["slug_perm"], fg="green"),
            ]
        )

    if data:
        click.echo()
        utils.pretty_print_table(headers, rows)

    if not show_list_info:
        return

    click.echo()

    num_results = len(data)
    list_suffix = "entitlement%s" % ("s" if num_results != 1 else "")
    utils.pretty_print_list_info(num_results=num_results, suffix=list_suffix)
171103
def state_preorder_put_account_payment_info( nameop, account_addr, token_type, amount ):
    
    assert amount is None or isinstance(amount, (int,long)), 'Amount is {} (type {})'.format(amount, type(amount))
    assert account_addr is None or isinstance(account_addr, (str,unicode))
    assert token_type is None or isinstance(token_type, (str,unicode))
    nameop['__account_payment_info__'] = {
            'address': str(account_addr) if account_addr is not None else None,
            'type': str(token_type) if token_type is not None else None,
            'amount': int(amount) if amount is not None else None
    }
680265
def sign(ctx, file, account):
    
    if not file:
        print_message("Prompting for message. Terminate with CTRL-D", "info")
        file = click.get_text_stream("stdin")
    m = Message(file.read(), bitshares_instance=ctx.bitshares)
    print_message(m.sign(account), "info")
56290
def _print_jobs(jobs, token_manager, app_url, options):
    
    accountids = set()
    for job in jobs:
        if job['user'] != 'jut.internal.user':
            accountids.add(job['user'])

    account_lookup = {
        'jut.internal.user': {
            'username': 'Jut Internal'
        }
    }

    if accountids:
        accounts_details = accounts.get_accounts(accountids,
                                                 token_manager=token_manager,
                                                 app_url=app_url)

        for account in accounts_details['accounts']:
            account_lookup[account['id']] = account

    if options.format == 'text':
        labels = OrderedDict()
        labels['id'] = 'Job ID'
        labels['alias'] = 'Juttle Name'
        labels['username'] = 'Owner'
        labels['_start_time'] = 'Start Date'
        labels['persistent'] = 'Persistent'

        max_lengths = {
            'id': 0,
            'alias': 0,
            'username': 0,
            '_start_time': 0,
            'persistent': 0,
        }

        for key in max_lengths.keys():
            max_lengths[key] = len(labels[key]) + 1

        # retrieve username and fix up persistent marker
        for job in jobs:
            job['username'] = account_lookup[job['user']]['username']
            job['persistent'] = 'YES' if job['timeout'] == 0 else 'NO'

        # calculate max length of each column
        for job in jobs:
            for key in labels.keys():
                if max_lengths[key] < len(job[key]):
                    max_lengths[key] = len(job[key]) + 1

        # print labels
        header = ''
        for key in labels.keys():
            header += (labels[key] + ' ' * (max_lengths[key] - len(labels[key])))

        info(header)

        for job in jobs:
            line = ''

            for key in labels.keys():
                line += (job[key] + ' ' * (max_lengths[key] - len(job[key])))

            info(line)

    elif options.format == 'table':
        headers = ['Job ID', 'Juttle Name', 'Owner', 'Start Date', 'Persistent']

        table = []
        for job in jobs:
            owner = account_lookup[job['user']]['username']
            persistent = 'YES' if job['timeout'] == 0 else 'NO'
            name = ''

            if 'alias' in job:
                name = job['alias']

            table.append([job['id'],
                          name,
                          owner,
                          job['_start_time'],
                          persistent])

        info(tabulate.tabulate(table, headers, tablefmt="orgtbl"))

    else:
        raise JutException('Unsupported output format "%s"' %
                           options.format)
495779
def get_account_info(self):
        
        headers = self._manager.get_account_headers()
        return (headers.get("x-account-container-count"),
                headers.get("x-account-bytes-used"))
363850
def get_account_info(self):
        
        attrs = {sconstant.A_BY: sconstant.V_NAME}
        account = SOAPpy.Types.stringType(data=self.auth_token.account_name,
                                          attrs=attrs)

        params = {sconstant.E_ACCOUNT: account}

        res = self.invoke(zconstant.NS_ZIMBRA_ACC_URL,
                          sconstant.GetAccountInfoRequest,
                          params)

        info = AccountInfo()
        info.parse(res)

        return info
25288
def update_account_info(self):
        ''' 

        '''
        request = self._get_request()
        return request.post(self.ACCOUNT_UPDATE_URL, {
            'callback_url': self.account.callback_url
        })
772171
def info(self, msg=None, *args, **kwargs):
        """"""

        return self._log(logging.INFO, msg, args, kwargs)
447838
def info(name):
    '''
    
    '''
    try:
        data = pwd.getpwnam(name)
        return {'name': data.pw_name,
                'passwd': data.pw_passwd,
                'account_created': get_account_created(name),
                'login_failed_count': get_login_failed_count(name),
                'login_failed_last': get_login_failed_last(name),
                'lstchg': get_last_change(name),
                'max': get_maxdays(name),
                'expire': get_expire(name),
                'change': get_change(name),
                'min': 'Unavailable',
                'warn': 'Unavailable',
                'inact': 'Unavailable'}

    except KeyError:
        log.debug('User not found: %s', name)
        return {'name': '',
                'passwd': '',
                'account_created': '',
                'login_failed_count': '',
                'login_failed_last': '',
                'lstchg': '',
                'max': '',
                'expire': '',
                'change': '',
                'min': '',
                'warn': '',
                'inact': ''}
577326
def cli(env):
    """"""

    mask = ('openTicketCount, closedTicketCount, '
            'openBillingTicketCount, openOtherTicketCount, '
            'openSalesTicketCount, openSupportTicketCount, '
            'openAccountingTicketCount')
    account = env.client['Account'].getObject(mask=mask)
    table = formatting.Table(['Status', 'count'])

    nested = formatting.Table(['Type', 'count'])
    nested.add_row(['Accounting',
                    account['openAccountingTicketCount']])
    nested.add_row(['Billing', account['openBillingTicketCount']])
    nested.add_row(['Sales', account['openSalesTicketCount']])
    nested.add_row(['Support', account['openSupportTicketCount']])
    nested.add_row(['Other', account['openOtherTicketCount']])
    nested.add_row(['Total', account['openTicketCount']])
    table.add_row(['Open', nested])
    table.add_row(['Closed', account['closedTicketCount']])

    env.fout(table)
1138121
def process_account(account_info):
    """"""
    log = logging.getLogger('salactus.bucket-iterator')
    log.info("processing account %s", account_info)
    session = get_session(account_info)
    client = session.client('s3', config=s3config)
    buckets = client.list_buckets()['Buckets']

    connection.hset(
        'bucket-accounts', account_info['name'], json.dumps(account_info))

    for b in buckets:
        connection.hset(
            'bucket-ages', bucket_id(account_info, b['Name']),
            b['CreationDate'].isoformat())

    account_buckets = account_info.pop('buckets', None)
    buckets = [n['Name'] for n in buckets
               if not account_buckets or
               n['Name'] in account_buckets]
    account_not_buckets = account_info.pop('not-buckets', None)
    buckets = [n for n in buckets
               if not account_not_buckets or
               n not in account_not_buckets]
    log.info("processing %d buckets in account %s",
             len(buckets), account_info['name'])
    for bucket_set in chunks(buckets, 50):
        invoke(process_bucket_set, account_info, bucket_set)
1015271
def get_account_details(self):
        
        return self.make_api_request(
            'Account',
            'getAccountDetails',
            utils.get_kwargs(locals()),
            model=models.AccountDetailsResponse,
        )