# get image to process image = queue.pop_from_queue() if not image: time.sleep(0.25) continue logger.info('recieved image=%s', image) image_content = get_image_content(image) logger.info('getting tags for image=%s', image) tags = tagging.get_tags(image_binary=image_content) if config.get('translation', 'enabled') == 'true': logger.info('translating tags for image=%s', image) translated_tags = translater.translate_tags(target=config.get( 'translation', 'target'), tags=tags) # Prepare ElasticSearch Document doc['image_type'] = os.path.splitext(image)[1] doc['image_fname'] = os.path.basename(image) doc['image_path'] = image doc['uploaded_at'] = datetime.datetime.fromtimestamp( int(os.path.getmtime(image))).strftime('%Y-%m-%d %H:%M:%S') doc['timestamp'] = int(time.time()) doc['en_lables'] = tags if translated_tags: target_lang = config.get('translation', 'target') doc['%s_lables' % target_lang] = translated_tags logger.info('pusing all details to elasticsearch for image=%s', image) if not es_engine.push_to_es(doc=doc): queue.add_to_queue(queue_name='failed_queue', image=image)
new_linked_list.remove_from_list("Ron") new_linked_list.print_list() new_linked_list.find_element("Anna") print("\n---------------------- Queue -------------------------------") name = "Mary" phone = "1-890-562" person = NodeQ(name, phone) queue = Queue() queue.add_to_queue(person) queue.print_queue() persons = ("John", "1-675-657"), ("Ron", "1-908-089"), ("Anna", "1-987-987") queue = [NodeQ(name, phone) for name, phone in persons] new_queue = Queue() for person in queue: new_queue.add_to_queue(person) new_queue.print_queue() print("Queue size is {}".format(new_queue.get_size()))