def update_weibo(self, wb_cnt): client = self.get_api() if not client: return None ret = None try: if wb_cnt.image_uri: img_type, img_data = ImageUtils.get_image_data(wb_cnt.image_uri) if img_type == 'http': ret = client.statuses.upload_url_text.post(status=wb_cnt.text, url=img_data) elif img_type == 'local': ret = client.statuses.upload.post(status=wb_cnt.text, pic=img_data) img_data.close() else: ret = client.statuses.update.post(status=wb_cnt.text) wb_cnt.do_sent() except Exception, e: ret = e