In my code, I am trying to create an image from an AMI and then check the state of the new image. However, I am struggling to work out the state of the image. Here is the last thing I have tried:
package_name = "RAY"
promotion_id = "101-234"
print "[....] Package Install Complete"
print "[....] Proceeding to Bake AMI"
imagename = package_name + promotion_id
newimageid = conn.create_image(instance_id=bakeryinstanceid, name=imagename, description="Please Work" )
print "[....] The new Base AMI ID for ", package_name, "is", newimageid
image_status = newimageid.state
Here is the error I get:
Traceback (most recent call last):
File "./imagecreate.py", line 58, in <module>
image_status = newimageid.state
AttributeError: 'unicode' object has no attribute 'state'
What is the best way to see the status of my new image?
I believe create_image() returns a string with the image id in it, not an Image object. Using your example, you should do this instead:
image_status = get_image(newimageid)
image_status.state should then hold a string showing your image state, possible values include "pending", "available" and "failed".
http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.get_image
http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.create_image
Related
I am using sightengine API to detect child sexual abuse in images. In order to do that I am trying to detect the nudity level in an image using sightengine API. The following example is provided in the documentation itself.
from sightengine.client import SightengineClient
client = SightengineClient('api_user', 'api_key')
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
Apart from copying the same code I am getting the following error.
Traceback (most recent call last):
File "driver.py", line 3, in <module>
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
AttributeError: 'Check' object has no attribute 'image'
I have used both Python 2 and Python 3 for the same code but both raise the same error.
Try This:
from sightengine.client import SightengineClient
client = SightengineClient('API user', 'API secret')
checkNudity = client.check('nudity')
output1 = checkNudity.set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
print(output1)
I run a command in which it creates a new camera, however at the end of the said function, there is no selection nor does the function selects the object after it has run its course.
So are there any commands in which I could possible query for the last created item?
I tried using `cmds.listHistory' but that will only shows you results if there is already a selection..
Any ways in which I can get around with it?
Additionally, say I am using the following command using the
cameraShape...
aaa = "cameraShape1"
mel.eval('<Some mel-based command> cameraShape.transformX cameraShape.transformY cameraShape.transformZ;')
but when I tried writing that command in another way such as :
mel.eval('<Some mel-based command> %s.transformX %s.transformY %s.transformZ;' %aaa)
I got an error saying
# Error: not enough arguments for format string
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# TypeError: not enough arguments for format string #
Where am I writing it wrong exactly? I tried writing like %aaa, aaa, aaa still the same error occurs
Why can't you just stuff the new camera into a variable instead of relying on selection?
new_camera, new_camera_shape = cmds.camera()
You're not using the right syntax when formatting with %:
"My name is %s" % "Jon Snow" # Works for single
"My name is %s and I was born in %s" % ("Jon Snow", "Winterfell") # Multiple
Personally I prefer format() as it's suppose to be more forward compatible for Python 3:
"My name is {0} and I was born in {1}".format("Jon Snow", "Winterfell")
Detect new objects:
scene_before = cmds.ls(l=True, transforms=True)
# Run command to import object here
scene_after = cmds.ls(l=True, transforms=True)
new_objs = list( set(scene_after).difference(scene_before) )
If you want to keep the last created object. You can create a class that contain a variable history where your append in your other script the last object created.
class History:
idCounter = []
def __init__(self, name):
History.idCounter.append(name)
print(History.idCounter)
for name in ['nana', 'tata', 'zaza']:
objectCreated = History(name)
I have the python google maps for python. i have this code:
from googlemaps import GoogleMaps
place1 = raw_input("your address: ")
place = raw_input("Destination: ")
gmaps = GoogleMaps(api_key)
directions = gmaps.direction(place1, place)
for step in directions['Directions']['Routes']['seconds'][0]['Steps']:
print step['descriptionHtml']
and i get this error
Traceback (most recent call last):
File "C:\Python27\test.py", line 152, in <module>
directions = gmaps.direction(place1, place)
AttributeError: 'GoogleMaps' object has no attribute 'direction'
i'm trying to ask the user for their address and the Destination and then find the directions.
It looks like the method is actually GoogleMaps.directions(origin, destination, **kwargs), notice the "s" on the method name. Here's a link to the API docs.
Sounds like you don't have a Google Maps API key. You need to sign up for one here:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
By the way, when you say "the python google maps for python," what are you referring to exactly? Is it this project?
I installed everything as it says on the FlickrAPI homepage but when I try to run:
import flickrapi
api_key = '1a4c975fa83048436a2086bcab7d2290'
api_password = '5e069eae20e60297'
flickrclient = flickrapi.FlickAPI(api_key, api_password)
favourites = flickrClient.favorites_getPublicList(user_id='userid')
photos = flickr.photos_search(user_id='73509078#N00', per_page='10')
sets = flickr.photosets_getList(user_id='73509078#N00')
for photo in favourites.photos[0].photo:
print photo['title']
I get this message from the command prompt:
C:\Users\Desktop>python api.py
Traceback (most recent call last):
File "api.py", line 4, in <module>
flickrclient = flickrapi.FlickAPI(api_key, api_password)
AttributeError: 'module' object has no attribute 'FlickAPI'
Any ideas?? I have tried almost everything
FlickAPI is not the same as FlickrAPI. You're missing an r.
The file C:\Users\XXXXXX\Desktop\FLICKR API\flickrapi.py is not part of the flickrapi package. Please rename it, it is masking the real library. Right now it is being imported instead of the installed package.
The flickrapi package itself consists of a directory with a __init__.py file inside of it. Printing flickrapi.__file__ should result in a path ending in flickrapi\__init__.py.
In your "flickrclient = flickrapi.FlickAPI" line, you're missing an 'r' in FlickAPI.
Also, on the next line, your *"user_id='userid'"* argument needs an actual user ID, such as '999999#N99'
Hopefully you found that & got this working a few months ago! :)
I'm using libxml2 in a Python app I'm writing, and am trying to run some test code to parse an XML file. The program downloads an XML file from the internet and parses it. However, I have run into a problem.
With the following code:
xmldoc = libxml2.parseDoc(gfile_content)
droot = xmldoc.children # Get document root
dchild = droot.children # Get child nodes
while dchild is not None:
if dchild.type == "element":
print "\tAn element with ", dchild.isCountNode(), "child(ren)"
print "\tAnd content", repr(dchild.content)
dchild = dchild.next
xmldoc.freeDoc();
...which is based on the code example found on this article on XML.com, I receive the following error when I attempt to run this code on Python 2.4.3 (CentOS 5.2 package).
Traceback (most recent call last):
File "./xml.py", line 25, in ?
print "\tAn element with ", dchild.isCountNode(), "child(ren)"
AttributeError: xmlNode instance has no attribute 'isCountNode'
I'm rather stuck here.
Edit: I should note here I also tried IsCountNode() and it still threw an error.
isCountNode should read "lsCountNode" (a lower-case "L")