python str has no attribute_python - AttributeError: 'str' object has no attribute 'isoformat'

up vote 1 down vote favorite I have code, and I don't know how to solve problem. Code: import dateutil.parser

import datetime

from novaclient.v2 import client as nova_client

from keystoneclient.auth.identity import v2

from keystoneclient import session

auth=v2.Password(auth_url="http://openstack2-prakt.in.linux.edu.lv:5000/v2.0",

username="***",

password="****",

tenant_name="********")

sess=session.Session(auth=auth)

nova=nova_client.Client(version="2", session=sess)

usage_list=nova.usage.get(tenant_id="**************",start='%Y-%m-%d', end='%Y-%m-%d')

for us in usage_list:

print us.total_vcpus_usage

After I execute code, there is next problem: No handlers could be found for logger "keystoneclient.auth.identity.base"

Traceback (most recent call last):

File "/home/eleonora/PycharmProjects/untitled/nova test.py", line 32, in

usage_list=nova.usage.get(tenant_id="c56f75091edc4480a204e5549ef11664",start='%Y-%m-%d', end='%Y-%m-%d')

File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/usage.py", line 60, in get

(tenant_id, start.isoformat(), end.isoformat()),

Agame, but I've immediately stumbled on a roadblock. class userInterface:

def __init__(self, roomID, roomDesc, dirDesc, itemDesc):

self.roomID = roomID

self.roomDesc = roomDesc

self.dirDesc = dirDesc

selfttributeError: 'str' object has no attribute 'isoformat'

python attributes openstack-nova

asked Mar 16 '15 at 11:26 Lera 31 7 closed as too broad by l4mpi, Antti Haapala, Odedra, HaveNoDisplayName, Andrew Arnold Mar 16 '15 at 15:41 Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.  |  2 Answers

up vote 2 down vote '%Y-%m-%d' is not datetime object but string but you (or some other code) are trying to use it as datetime object.

answered Mar 16 '15 at 11:33 iced 1,388 4 9  |  up vote 2 down vote The one of several answers is: now=datetime.datetime.now()

later=now+datetime.timedelta(seconds=30)

usage_list=nova.usage.get(tenant_id="cb076df2-6855-4988-95c0-e3ea2aa4729c",start=now, end=later)

answered Mar 16 '15 at 11:42 Lera 31 7  |  Not the answer you're looking for? Browse other questions tagged python attributes openstack-nova or ask your own question.

print("Only numeric digits: yes") else: print("Only numeric digits: no") answer 1 It would be string.isdigit() not string.isdigits() >>> '9'.isdigit()True>>> '9'.isdigits()Traceback (most recent call last): File "

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值