I am using the InstagramAPI module from this github to create a script that posts pictures at certain time. A snippet below shows part of the code:
Insta = InstagramAPI(account_name, password)
Insta.login()
InstagramAPI.uploadPhoto(post_path, caption)
InstagramAPI.logout()
This works fine, unless the picture is in the wrong format. If it is in the wrong format, nothing is posted and this is printed:
Request return 400 error!
{u'status': u'fail', u'message': u"Uploaded image isn't in the right format"}
I have a function that will re-size if it isn't in the correct format. However, it is just print and not an error. Therefor, I can not put this in a try/except. So if the file isn't in the right format, it just skips and posts nothing.
Does anyone know of a way I could have my code save the print output to a variable so I can check if it contains "Uploaded image isn't in the right format" and raise an error if so?
uis purely a Python2 thing.