json - KeyError: 'Name' Python dicts and AWS sdk -


soo here piece of code form yesterday, regardless of not being able django_settings_module continue cooperating, have hardcoded of our aws credentials test...
anywho, yesterday worked fine , output serverinfo.json info such:

[     {         "develop-env": {             "id": "i-xxxx",             "imageid": "ami-xxxxx",             "ipaddress": "54.xxx.xx.xxx.xx",             "keypair": xxx,             "publicdnsname": "ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com",             "region": "us-east-1c",             "size/type": "t1.micro"         }     },     {         "deploymenttesting": {             "id": "i-xxxxxx",             "imageid": "ami-xxxxx",             "ipaddress": "5x.x.xx.xxx",             "keypair": "xxxxx",             "publicdnsname": "ec2-xx-x-xx-xxx.compute-1.amazonaws.com",             "region": "us-east-1b",             "size/type": "t1.micro"         }     }, 

.. , forth, think idea. code run create that:

#from django.conf import settings #import gomoto.settings import json import boto import os  # os.environ.setdefault("django_settings_module", "gomoto.settings")  #aki = settings.aws_access_key_id #sak = settings.aws_secret_access_key aki = 'xxxxx' sak = 'xxxxx'  # clears content in serverinfo.json open('serverinfo.json') f:     data = json.load(f)     item in data:         del item f.close()  # object holds connection instance. c = boto.connect_ec2(aki, sak) # retrive instances associated account allinstances = c.get_only_instances()  servercontent = []  # iterate through instance objects, building json object , inserting proper instance attributes in allinstances:     instancecontent = {}     instancecontent ={         i.tags['name']: {             'id': i.id,             'publicdnsname': i.public_dns_name,             'region': str(i._placement),             'ipaddress': i.ip_address,             'imageid': i.image_id,             'size/type': i.instance_type,             'keypair': i.key_name,             # 'groups': i.groups,             # 'groupname': i.group_name         }     }     # append py dict py list     servercontent.append(instancecontent)  # json dump contents of servercontent array open('serverinfo.json', 'wb') f:     f.write(         json.dumps(servercontent, sort_keys=true, indent=4, separators=(',', ': '))     ) f.close() 

today, in doing further testing, script not run , instead produces error:

traceback (most recent call last):   file "update.py", line 42, in <module>     'groupname': i.group_name keyerror: 'name' 

can point me in right direction can troubleshoot this? appreciated, thank you!


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -